Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating an ObjectIndex, fixes https://github.com/linkml/linkml/issues/1009 #211

Merged
merged 7 commits into from
Oct 14, 2022

Conversation

cmungall
Copy link
Member

Given a tree-root/container object, this will create an index,
and allow for retrieval of proxy objects that shadow domain
YAMLRoot classes. These operate in the same way, except that
object references are automatically dereferenced.

For example, given a container object following the standard
personinfo schema, an index can be created and queried:

    >>> ix = ObjectIndex(container, schemaview=schemaview)
    >>> container = ix.bless(container)
    >>> for p in container.persons:
    >>>    for r in p.has_familial_relationships():
    >>>        print(f"{p.name} {p.type} {r.related_to.name}")

Note this will work even if related_to is *not* inlined.

This means naive traversal of the object tree is not guaranteed
to be bounded, unlike with a YAMLRoot object. E.g.

    >>> person.has_familial_relationships[0].
    >>>    related_to.has_familial_relationships[0].
    >>>    related_to.has_familial_relationships[0].name

In the above, the same proxy object is reused for any
object with an identifier.

Given a tree-root/container object, this will create an index,
    and allow for retrieval of *proxy objects* that shadow domain
    YAMLRoot classes. These operate in the same way, except that
    object references are automatically dereferenced.

    For example, given a container object following the standard
    personinfo schema, an index can be created and queried:

        >>> ix = ObjectIndex(container, schemaview=schemaview)
        >>> container = ix.bless(container)
        >>> for p in container.persons:
        >>>    for r in p.has_familial_relationships():
        >>>        print(f"{p.name} {p.type} {r.related_to.name}")

    Note this will work even if related_to is *not* inlined.

    This means naive traversal of the object tree is not guaranteed
    to be bounded, unlike with a YAMLRoot object. E.g.

        >>> person.has_familial_relationships[0].
        >>>    related_to.has_familial_relationships[0].
        >>>    related_to.has_familial_relationships[0].name

    In the above, the same proxy object is reused for any
    object with an identifier.
@codecov-commenter
Copy link

codecov-commenter commented Oct 12, 2022

Codecov Report

Merging #211 (40ed5dd) into main (7a53613) will decrease coverage by 0.90%.
The diff coverage is 56.48%.

@@            Coverage Diff             @@
##             main     #211      +/-   ##
==========================================
- Coverage   63.33%   62.43%   -0.91%     
==========================================
  Files          50       52       +2     
  Lines        5501     5997     +496     
  Branches     1567     1697     +130     
==========================================
+ Hits         3484     3744     +260     
- Misses       1598     1791     +193     
- Partials      419      462      +43     
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/utils/introspection.py 68.75% <37.50%> (-31.25%) ⬇️
linkml_runtime/utils/csvutils.py 84.61% <40.00%> (-1.50%) ⬇️
linkml_runtime/linkml_model/meta.py 52.74% <52.27%> (+<0.01%) ⬆️
linkml_runtime/linkml_model/units.py 76.00% <76.00%> (ø)
linkml_runtime/utils/pattern.py 88.57% <85.18%> (+2.85%) ⬆️
... and 12 more

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

@cmungall cmungall merged commit 9bc877b into main Oct 14, 2022
cmungall added a commit that referenced this pull request Oct 18, 2022
Continuation of #211
Fixes linkml/linkml#1009

Moving location from utils into a dedicated package.

Including eval_expr in ObjectIndex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants