linkml / linkml-runtime

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

implement method to get classes associated with slot #197

Closed sujaypatil96 closed 2 years ago

sujaypatil96 commented 2 years ago

Implement a method to get all classes that use a given slot.

codecov-commenter commented 2 years ago

Codecov Report

Merging #197 (934e77e) into main (7a53613) will decrease coverage by 1.15%. The diff coverage is 46.01%.

@@            Coverage Diff             @@
##             main     #197      +/-   ##
==========================================
- Coverage   63.33%   62.17%   -1.16%     
==========================================
  Files          50       52       +2     
  Lines        5501     5888     +387     
  Branches     1567     1674     +107     
==========================================
+ Hits         3484     3661     +177     
- Misses       1598     1771     +173     
- Partials      419      456      +37     
Impacted Files Coverage Δ
linkml_runtime/linkml_model/annotations.py 90.38% <ø> (ø)
linkml_runtime/linkml_model/extensions.py 85.45% <ø> (ø)
linkml_runtime/linkml_model/mappings.py 0.00% <ø> (ø)
linkml_runtime/linkml_model/types.py 100.00% <ø> (ø)
linkml_runtime/linkml_model/validation.py 0.00% <0.00%> (ø)
linkml_runtime/linkml_model/meta.py 52.66% <52.27%> (-0.09%) :arrow_down:
linkml_runtime/linkml_model/units.py 76.00% <76.00%> (ø)
linkml_runtime/utils/formatutils.py 83.14% <100.00%> (+1.66%) :arrow_up:
linkml_runtime/utils/inference_utils.py 94.02% <100.00%> (+0.37%) :arrow_up:
linkml_runtime/utils/schemaview.py 84.69% <100.00%> (+0.28%) :arrow_up:

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

turbomam commented 2 years ago

A slot can be used legally within a class if

we could create a single method with flags for each case, returning a single unqualified list.

if any of those conditions are difficult to process, that case could be omitted for now (good idea, @kevinschaper)

sujaypatil96 commented 2 years ago

@turbomam: thank you for breaking up the various possible use cases in which we can determine the classes associated with a slot.

turbomam commented 2 years ago

@turbomam: thank you for breaking up the various possible use cases in which we can determine the classes associated with a slot.

  • when direct is set to True, we are computing the first use case, i.e., slots mentioned in slots property of a class
  • when induced is True, we are computing the second and third use cases together, slots mentioned under attributes and slot_usage properties on a class

OK, does that mean that slots asserted by ancestors won't appear in this first solution? We should come up with some test cases.