You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit bc6b0d6
Browse filesBrowse the repository at this point in the historyBrowse files
fix(user-sync): align with stage and the tools docs
- list the page in the existing Tools nav group, describe scripts there
- page through all User items and adopt pages at the deterministic title
- skip blocked accounts by default, never propose placeholder names
- prune via a second jsondata edit; oold 2.3 ignores __iris__ edits
- never write employment_contract_status; add store and prune tests
Copy file name to clipboardExpand all lines: docs/tools/index.md
+5-2Lines changed: 5 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,10 @@
2
2
3
3
Besides the Python API, osw ships two adapters that talk to a live instance:
4
4
the `osw` command line client, and an MCP server for agent clients such as
5
-
Claude Code. Both run the same operations from one shared, SDK-free core
6
-
(`osw.service`), so a command and its matching tool behave identically. They
5
+
Claude Code. This section also covers standalone scripts built on the Python
6
+
API. The current one is the [user sync](user-sync.md). The two adapters run
7
+
the same operations from one shared, SDK-free core (`osw.service`), so a
8
+
command and its matching tool behave identically. They
7
9
differ in exactly one way: only the CLI accepts filesystem paths.
8
10
9
11
## Setup
@@ -49,4 +51,5 @@ extras are listed in the [Get Started guide](../get-started.md#optional-extras).
49
51
| ---- | -------- |
50
52
|[CLI](cli.md)| The `.env` quick start, the full command reference, and the global flags |
51
53
|[MCP server](mcp.md)| The tool surface, the no-filesystem-access and one-server-per-instance rules, and how to register the server with a client such as Claude Code |
54
+
|[User Sync (script)](user-sync.md)| A Python script that creates or updates `User` items from the MediaWiki accounts of an instance, with the options, the data it writes and how it reconciles existing items |
52
55
|[Configuration](configuration.md)| What both adapters share: where credentials and settings come from, and the full environment-variable reference |
Copy file name to clipboardExpand all lines: docs/tools/user-sync.md
+39-18Lines changed: 39 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,10 @@ Create or update OSW `User` items from the MediaWiki accounts of an OSL
4
4
instance, enriching ORCID users from the public ORCID API. The run is
5
5
idempotent and previews every change before writing.
6
6
7
+
This is a Python script built on the osw library. It is not a command of the
8
+
`osw` CLI and not an MCP tool, see [Tools](index.md). It runs from a source
9
+
checkout, because `examples/` is not part of the installed package.
10
+
7
11
## When to use it
8
12
9
13
OSL instances gain accounts from manual creation and from whitelisted ORCID
@@ -16,12 +20,20 @@ semantic `User` item until this tool reconciles them.
16
20
uv run python examples/user_sync.py --domain your-instance.example.org --dry-run
17
21
```
18
22
19
-
Credentials are read from `accounts.pwd.yaml` (or `--cred-filepath`), the same
20
-
mechanism as `OswExpress`. Start with `--dry-run` to preview, then run without
21
-
it to write after confirming at the prompt.
22
-
23
-
To also remove data no longer wanted (disabled optional fields and
24
-
`employment_contract_status`) from existing items, add `--prune`:
23
+
The script reads the credential file given by `--cred-filepath`, otherwise
24
+
`accounts.pwd.yaml` in the working directory, otherwise the file named by the
25
+
`OSW_CRED_FILEPATH` environment variable. It does not read a `.env` file.
26
+
`--domain` falls back to the `OSW_DOMAIN` environment variable. See
27
+
[Credentials](configuration.md#credentials) for the file format. Start with
28
+
`--dry-run` to preview, then run without it to write after confirming at the
29
+
prompt.
30
+
31
+
To also clean up existing items, add `--prune`. Without it, the sync never
32
+
writes `employment_contract_status` and never removes anything. With it,
33
+
`employment_contract_status` on existing items is overwritten with an empty
34
+
value. So are `website` and `organization`, unless `--with-websites` or
35
+
`--with-organizations` enables them. This happens in a second edit of the
36
+
page's jsondata after the store:
25
37
26
38
```bash
27
39
uv run python examples/user_sync.py --domain your-instance.example.org --prune --dry-run
@@ -49,11 +61,14 @@ only core identity plus email.
49
61
|`--with-websites`| Also store ORCID researcher URLs (opt-in). |
50
62
|`--with-organizations`| Also create and link Organization items from ORCID affiliations (opt-in). |
51
63
|`--with-extras`| Enable both websites and organizations. |
52
-
|`--prune`| Remove disabled optional fields and `employment_contract_status` from existing items (default off; a normal run only adds). |
64
+
|`--include-blocked`| Do not skip blocked MediaWiki accounts. |
65
+
|`--prune`| Overwrite `employment_contract_status`, and `website` or `organization` when their opt-in flag is not given, on existing items with an empty value, in a second edit of the page's jsondata after the store (default off; a normal run never writes `employment_contract_status` and never removes anything). |
53
66
54
67
## What it does
55
68
56
-
1. Enumerate MediaWiki accounts, skipping bots and privileged groups
|`email`| Standard: always attempted; missing email is warned, not fatal; never removed. |
79
-
|`website`| Opt-in (`--with-websites`); removed from existing only with `--prune`. |
80
-
|`organization`| Opt-in (`--with-organizations`); removed from existing only with `--prune`. |
81
-
|`employment_contract_status`| Never written; removed from existing only with `--prune`. |
98
+
|`website`| Opt-in (`--with-websites`); without that flag, on existing items overwritten with an empty value only with `--prune`, in a second jsondata edit after the store. |
99
+
|`organization`| Opt-in (`--with-organizations`); without that flag, on existing items overwritten with an empty value only with `--prune`, in a second jsondata edit after the store. |
100
+
|`employment_contract_status`| Never written without `--prune`; with `--prune`, overwritten with an empty value on existing items in a second jsondata edit after the store. |
82
101
83
102
## Notes
84
103
85
104
- MediaWiki does not expose other users' email or real name, so ORCID is the
86
105
only source of rich data. Non-ORCID accounts get username-based placeholder
87
-
names, flagged in the preview.
88
-
- On a first accepted run the library autofetches schemas and may regenerate
89
-
`src/osw/model/entity.py`; restore it if you do not want that change.
106
+
names, flagged in the preview. Placeholder names are written only for new
107
+
items and are never proposed for an existing item.
108
+
- In a source checkout (for developers), the first accepted run autofetches
109
+
schemas and may regenerate `src/osw/model/entity.py`. Restore it if you do not
0 commit comments