Repository navigation
Give each WikibaseIntegrator its own configuration - #1227
Merged
Merged
Conversation
#1193, as decided on 2026-11-15: WikibaseIntegrator(config=...) takes the options of wbi_config that differ for this instance, and reads the others from wbi_config when they're used. wbi.config is read-only. The entities of an instance use its MEDIAWIKI_API_URL, USER_AGENT and MAX_REQUEST_SIZE for their requests, its WIKIBASE_URL for get_entity_url(), its DEFAULT_LEXEME_LANGUAGE for new lexemes, and its SPARQL_ENDPOINT_URL and WIKIBASE_URL for write_required(). The fast run containers are told apart by their Wikibase URL and MediaWiki API URL too, and wbi_fastrun.clear_fastrun_store() empties the store. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 1 of #1193, with your answers: a
config=dict overlay, and the entities plus fast run use it. Part 2, the datatype IRIs resolved when they're serialized, comes in a separate PR on top of this one. It touches everyget_json()and the equality checks, so it's easier to review on its own. #1193 stays open until part 2 merges.WikibaseIntegrator(config=...)wbi_config. An unknown key raisesValueError, so a typo doesn't pass silently.wbi_configwhen they're used, so changingwbi_configstill applies to them.WikibaseIntegrator()withoutconfigbehaves exactly as before.wbi.config: read-only, typedMapping[str, Any]. Making it writable in 1.x wouldn't break anything.deepcopyincluded. AMappingProxyTypecan't be deep-copied, which brokeClaims.add, so it's a small privateMapping.What uses it
MEDIAWIKI_API_URL,USER_AGENTget(),get(revision=),get_claims(),write(),delete(), the lexeme form and sense methods,mediainfo.get_by_title()MAX_REQUEST_SIZEwrite()WIKIBASE_URLget_entity_url(), fast runSPARQL_ENDPOINT_URLwrite_required())DEFAULT_LEXEME_LANGUAGEAn argument given to a method (
mediawiki_api_url=...) still takes precedence. An argument passed asNonetakes the configuration.What still reads
wbi_config(documented):wbi_helpersfunctions, as you chose;MEDIAWIKI_REST_URLandMEDIAWIKI_INDEX_URLare accepted, sincemanifest.config()has them, but the entities don't use them. A login has its own URLs.Fast run
get_fastrun_container()andFastRunContainertakewikibase_url,mediawiki_api_urlanduser_agent, all optional. The property types (for a graph without the properties) are read from the MediaWiki API of the container. Its SPARQL queries send its user agent.wbi_fastrun.clear_fastrun_store(): empties the store, which otherwise keeps every container for the whole process.Not breaking
No signature loses anything, and the defaults are unchanged. Label:
enhancement.Docs
installation.md: a "Several instances in one process" section, with what uses the instance configuration and what doesn't.fastrun.md: the new defaults, andclear_fastrun_store().Tests
test/test_instance_config.py: 24 tests with twoMockWikibaseinstances side by side.wbi_config.clear_fastrun_store().test_instance_configuration):wbi_configpoints to an unreachable host, and an instance configured for the real Wikibase reads, runs fast run against its query service, writes, and deletes.🤖 Generated with Claude Code