linkml / linkml-runtime

Runtime support for linkml generated models
https://linkml.io/linkml/
Creative Commons Zero v1.0 Universal
24 stars 23 forks source link

CurieNamespace catalog that is not a singleton and that uses curies #251

Open kervel opened 1 year ago

kervel commented 1 year ago

This PR introduces a new class CurieNamespaceCatalog that can convert between uries and curies using https://github.com/cthoyt/curies

Its main reason of existence is the detection of uri and curie synonyms in the given CurieNamespaces to create the converter in the correct way.

It is based on linkml #1244 with two modifications:

This PR is needed to complete https://github.com/linkml/linkml/pull/1257

after merging this PR, we will need to update poetry.lock (can't do it here or we will get merge conflicts)

codecov-commenter commented 1 year ago

Codecov Report

Merging #251 (814b03e) into main (b992fe0) will increase coverage by 0.61%. The diff coverage is 70.70%.

:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main     #251      +/-   ##
==========================================
+ Coverage   63.54%   64.16%   +0.61%     
==========================================
  Files          53       53              
  Lines        6117     6284     +167     
  Branches     1650     1701      +51     
==========================================
+ Hits         3887     4032     +145     
+ Misses       1774     1770       -4     
- Partials      456      482      +26     
Impacted Files Coverage Δ
linkml_runtime/index/object_index.py 88.28% <12.50%> (-3.53%) :arrow_down:
linkml_runtime/dumpers/rdflib_dumper.py 94.94% <40.00%> (-2.97%) :arrow_down:
linkml_runtime/utils/context_utils.py 68.33% <50.00%> (-1.85%) :arrow_down:
linkml_runtime/utils/schemaview.py 83.29% <54.83%> (-3.11%) :arrow_down:
linkml_runtime/utils/curienamespace.py 93.44% <92.72%> (+8.82%) :arrow_up:
linkml_runtime/__init__.py 100.00% <100.00%> (ø)
linkml_runtime/utils/namespaces.py 73.37% <100.00%> (+2.48%) :arrow_up:
linkml_runtime/utils/yamlutils.py 79.44% <100.00%> (+1.29%) :arrow_up:

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

kervel commented 1 year ago

i just discovered we also have "namespacegen.py" which generates a python file that ... can be used to do expand/compress. so i have the impression that we have 100 ways to fix the "how to expand/compress uri's" problems.

so for an outsider it would be a bit strange to say look with namespacegen you can generate a Namespace object (which doesn't use the Namespaces class , which also can serve the same purpose btw), but if you then use pythongen we won't use that file to do exactly this.

so we have:

Update i tried to use Namespaces, it misses a few convenience functions: i have to deal with values that are uriorcurie which means they might be an uri or a curie. Namespaces doesn't have a function that goes from uriorcurie to uri or to curie, you have to know in advance if its an uri or a curie. I could add those instead of this PR.

capsulecorplab commented 1 year ago

Should we perhaps open an issue for implementing a Namespace function that goes from uriorcurie to uri or curie?