Repository navigation
fix(core): restore the page cache state once per fetch_schema call - #180
Merged
Merged
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.9.2 (current: Changelog preview (truncated)## v2.9.2 (2026-11-12)
### Bug Fixes
- Follow properties and items when collecting category templates
([#220](https://github.com/OpenSemanticLab/osw-python/pull/220),
[`55e500e`](https://github.com/OpenSemanticLab/osw-python/commit/55e500efb896f0a3d6bde98409b3a6f43a652bdc))
- Keep the stored jsonschema when store_entity regenerates it
([`9b76a8f`](https://github.com/OpenSemanticLab/osw-python/commit/9b76a8fbeb813b34c4881b54d329e9e837b08f95))
- Select category templates from the schema allOf like the wiki
([#220](https://github.com/OpenSemanticLab/osw-python/pull/220),
[`9f606f4`](https://github.com/OpenSemanticLab/osw-python/commit/9f606f48fefd640cca48e6718f1a92eca118da6b))
### Continuous Integration
- Run Main on pushes to stage and Integration on PRs into stage
([`1b55f02`](https://github.com/OpenSemanticLab/osw-python/commit/1b55f02c90cae646d690f83d6208c01f0e26e62b))
### Documentation
- State which schema references the template walk follows
([#220](https://github.com/OpenSemanticLab/osw-python/pull/220),
[`799bc07`](https://github.com/OpenSemanticLab/osw-python/commit/799bc07952aac7e6ab579bc127c5cb3000710491))
### Testing
- Drop the FileController type check, it is no longer a model
([`1eddbe8`](https://github.com/OpenSemanticLab/osw-python/commit/1eddbe867559e14806ad72eb076172cd41c7767e))
- Set subclass_of for oold 2 in the jsonschema tests
([`bd4ffdb`](https://github.com/OpenSemanticLab/osw-python/commit/bd4ffdb3e950f43f4eea0151d19d07f621eb14e0))
Preview via python-semantic-release and conventional commits. |
This was referenced Sep 18, 2026
Closed
…-cache # Conflicts: # src/osw/core.py
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.
if fetchSchemaParam.final:keeps thereload_module_or_restore(...)call fromstage. Only the cache restorethat followed it is removed.
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, including an exception raised by
reload_module_or_restore._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
_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.
stage,make checkpasses andmake testreports 872passed.
Related
OSW.load_entityhad the same save and restore pattern without afinally.fix(core): report dropped entities and restore the cache on error #185 fixed that, and this
branch contains that change after the merge of
stage.