Repository navigation
Conversation
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.
Adds a read-only
uriproperty to the file controllers. The subject moves here from OpenSemanticLab/osw-python#158, because osw-python re-exports the file controllers of this package after OpenSemanticLab/osw-python#214, which is merged into itsstagebranch and not yet intomain.Changes
src/opensemantic/core/_file_controller_mixin.py:FileControllerMixin.uri: returnsNoneby default. It is not abstract: pydantic v1'sModelMetaclassextendsABCMeta, so an abstract property would stop every existing file controller outside this package from being instantiated.LocalFileControllerMixin.uri: thefile://URI oflocal_path(resolve_path().absolute().as_uri()),Noneiflocal_pathis unset.InMemoryControllerMixin.uri:None, a stream in memory has no location.RemoteFileControllerMixin.uri: what_url()returns (download_url, elseaccess_url),Noneif neither is set. A subclass that overrides_url()is honored.tests/test_file_controller_uri.py: 25 tests over the v1 and v2 controllers. They cover each controller, a third-party subclass that defines onlygetandput, and thaturiappears neither in.dict()/model_dump(), nor in the JSON output, nor in the JSON schema.Design note for review: a Python-only property
uriis derived on every access and never stored. It is a property of the Python class only and has no counterpart in the JSON schema of the page package. The tests check that it does not reach the schema or the serialized data.@propertyin this package: before this change,grep -rn "@property" src/opensemantic/corefound nothing, and the generated_model.pyfiles contain none.WikiFileController.url(https://github.com/OpenSemanticLab/osw-python/blob/main/src/osw/controller/file/wiki.py), on a class built onmodel.WikiFile. Please decide whether this is the intended pattern for the generated classes.Follow-up in osw-python
WikiFileControllerinherits thisuri, which returnsdownload_urloraccess_url. #158 returned the wiki page URL fromWikiFileController.urlinstead. With refactor: take the file controllers from opensemantic.core OpenSemanticLab/osw-python#214, that property opens a wiki session on first access, so a property here should not depend on it. WhetherWikiFileControllershould overrideuriis open for osw-python.Tests
pytest --no-cov -q: 101 passed (76 before, 25 new).pre-commit run --all-files: passed.