Skip to content

feat(user-sync): sync OSW User items from MediaWiki and ORCID - #174

Open
raederan wants to merge 14 commits into
mainfrom
user-item-upd
Open

raederan wants to merge 14 commits into
mainfrom
user-item-upd

Conversation

@raederan

Copy link
Copy Markdown
Contributor

Summary

Adds osw.tools.user_sync: a maintenance tool that creates/updates OSW User
items from an OSL instance's MediaWiki accounts, enriching ORCID users from the
public ORCID API. Idempotent, with an interactive preview and confirm before any
write.

  • Enumerates MW accounts; excludes bots, privileged groups, and reserved system accounts.
  • Core identity always written (username, name, orcid, email); website/organization are opt-in (--with-websites / --with-organizations); employment_contract_status is never written.
  • --prune removes disabled/protected fields from existing items; --dry-run, --auto-apply, --orcid-only / --mw-only.
  • Creates User:<name> redirects; warns (never fails) on users with no ORCID email.
  • Unit tests with mocked MediaWiki/ORCID, plus examples/user_sync.py and a docs page.

Limitations

  • MediaWiki's API exposes no real name or email for other users, so MediaWiki-native (non-ORCID) users get username-based placeholder names and no email (that data lives only in the user DB table).
  • Removing fields requires --prune (stores with remove_empty=False); employment_contract_status ends as an empty list, not fully absent (the model re-applies its default when the key is missing).
  • Unlinking organizations leaves the Organization items orphaned (not deleted).

@raederan raederan self-assigned this Sep 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Release preview

Merging this PR would release v2.4.0 (current: v2.3.3).

Changelog preview (truncated)
## v2.4.0 (2026-09-17)

### Bug Fixes

- **user-sync**: Actually remove pruned fields via empty relations and remove_empty
  ([`87cf85b`](https://github.com/OpenSemanticLab/osw-python/commit/87cf85b31cbfec6b80e2e30b92852c359586133c))

### Chores

- Relicense to Apache-2.0 ([#173](https://github.com/OpenSemanticLab/osw-python/pull/173),
  [`848615c`](https://github.com/OpenSemanticLab/osw-python/commit/848615cbd1e06401922eda88231a51028440a242))

- **user-sync**: Scaffold module, example and tracking
  ([`217b101`](https://github.com/OpenSemanticLab/osw-python/commit/217b1017b46295340bc79cee050a91c45c0d379d))

### Documentation

- **user-sync**: Add user sync guide and finalize example
  ([`830d120`](https://github.com/OpenSemanticLab/osw-python/commit/830d12072f9acfcbbaa265e5b75e6db38ca0a0d1))

- **user-sync**: Document prune and opt-in extras
  ([`1899d7f`](https://github.com/OpenSemanticLab/osw-python/commit/1899d7f2c070a3bee614602509109bc97ea19f79))

### Features

- **user-sync**: Add interactive preview and resolution
  ([`e0c54db`](https://github.com/OpenSemanticLab/osw-python/commit/e0c54db9845447a62de544c4651e7d512a6ead74))

- **user-sync**: Add orcid public api client
  ([`5e40525`](https://github.com/OpenSemanticLab/osw-python/commit/5e40525b826713d37af47602d0542f957fba0e94))

- **user-sync**: Add reconciliation engine
  ([`54711e9`](https://github.com/OpenSemanticLab/osw-python/commit/54711e96f36c74ac125a4411b7b2cf7b33d23d04))

- **user-sync**: Enumerate and classify mediawiki users
  ([`90bf3da`](https://github.com/OpenSemanticLab/osw-python/commit/90bf3daf68639af2a1f133472ced70d0c8d2af71))

- **user-sync**: Exclude system accounts and complete idempotent sync
  ([`f2d011d`](https://github.com/OpenSemanticLab/osw-python/commit/f2d011d61bf4dfe1ea445cdfc78bd3f6b69af520))

- **user-sync**: Gate optional fields and opt-in prune removals
  ([`4e38b29`](https://github.com/OpenSemanticLab/osw-python/commit/4e38b292972bb57faaafbb66feeed55a9822cea6))

- **user-sync**: Map sources to user and organization items
  ([`59b5610`](https://github.com/OpenSemanticLab/osw-python/commit/59b56109baf330e20aae1fc277c1381435fc6230))

- **user-sync**: Opt-in extras, standard email, --auto-apply
  ([`31c2f82`](https://github.com/OpenSemanticLab/osw-python/commit/31c2f82bae2f47502557098d4f7d9d82c8466f14))

- **user-sync**: Store items, redirects, orgs and verify
  ([`a2a9d8c`](https://github.com/OpenSemanticLab/osw-python/commit/a2a9d8c524d77e4f8266bf210c022db2b4a85263))

- **user-sync**: Strip employment status and warn on missing email
  ([`828f02c`](https://github.com/OpenSemanticLab/osw-python/commit/828f02c1df1ca525dc040f89fbd5d1b5232db4dd))

Preview via python-semantic-release and conventional commits.

@simontaurus

Copy link
Copy Markdown
Contributor

user properties may be available via https://www.mediawiki.org/wiki/API:Userinfo

@raederan

Copy link
Copy Markdown
Contributor Author

user properties may be available via https://www.mediawiki.org/wiki/API:Userinfo

only works for logged in users, not even admins can read real name or email
name mapping can only work if username is the realname on MW side created accounts for user items.
email must be provided by each user themselves

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants