Conversation
- fetch_schema takes the cache state before the loop over schema titles - the restore runs in a finally block, so an early return or an exception in _fetch_schema can no longer leave the cache enabled - _fetch_schema no longer snapshots a state its predecessor has changed - add unit tests for the multi-title, exception and early-return paths Closes #176
Contributor
Release previewMerging this PR would release v2.3.4 (current: Changelog preview (truncated)## v2.3.4 (2026-09-18)
### Bug Fixes
- **core**: Restore the page cache state once per fetch_schema call
([`f09dcf6`](https://github.com/OpenSemanticLab/osw-python/commit/f09dcf6b9d0e0bf3baf04107d9e1acf56e755c8d))
### Chores
- Relicense to Apache-2.0 ([#173](https://github.com/OpenSemanticLab/osw-python/pull/173),
[`848615c`](https://github.com/OpenSemanticLab/osw-python/commit/848615cbd1e06401922eda88231a51028440a242))
Preview via python-semantic-release and conventional commits. |
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.
Fixes #176.
Changes
OSW.fetch_schemareads the cache state once, enables the cache, andrestores the state in a
finallyblock around the loop over schema titles.OSW._fetch_schemano longer reads or restores the cache state. A note inits docstring says where that now happens.
importlib.reload(model)call underif fetchSchemaParam.final:staysunchanged.
tests/test_fetch_schema_cache.py.Rationale
site_cache_statewas a local of_fetch_schema, which runs once per titleand again recursively per
$ref. From the second title on, the snapshotalready read the state the previous call had set, so
if not site_cache_statewas false anddisable_cache()was never called.missing schema page, and any exception. A
finallyin the caller coversboth.
_fetch_schemais private and only called fromfetch_schemaand fromitself, so moving the cache handling to the public method keeps the caching
benefit for the whole operation.
enable_cache/disable_cacheare plain boolean setters with no nestingcounter, so a single enable and a single restore around the operation is the
correct shape.
Verification
src/osw/core.py, including the testfor a worker that enables the cache and does not restore it.
_fetch_schemawith a stub, so they assert the cachecontract of
fetch_schema. They do not execute the body of_fetch_schema,which needs a wiki.
Related
OSW.load_entityhas the same save and restore pattern athttps://github.com/OpenSemanticLab/osw-python/blob/main/src/osw/core.py#L1235
and #L1325. It restores unconditionally at the end but not in a
finally,so an exception still skips it. Not changed here.