-
Notifications
You must be signed in to change notification settings - Fork 23
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
function to return schema elements by id_prefixes #36
Conversation
sierra-moxon
commented
Sep 9, 2021
- remove extra refactoring from PR add a convenience method for retrieving model elements by the prefix … #35
linkml_runtime/utils/schemaview.py
Outdated
@@ -529,6 +531,40 @@ def expand_curie(self, uri: str) -> str: | |||
return ns[pfx] + local_id | |||
return uri | |||
|
|||
@lru_cache(CACHE_SIZE) | |||
def get_element_by_prefix( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps decompose this:
- a method that takes an actual prefix as input and returns element names,
get_elements_applicable_for_prefix
- a method that splits CURIEs (or URIs?) and. extracts the prefix
- a wrapper that composes these
get_elements_applicable_for_identifier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and broke this up into 3 methods and added support (by utilizing an existing function! - thanks for the pointer :) ) for URIs as well. Also added a test for URI -- which meant adding monarch_context to the kitchen_sink_no_imports.yaml.
linkml_runtime/utils/schemaview.py
Outdated
the id_prefixes mapped to that element. | ||
|
||
""" | ||
categories = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: categories is a biolinkism - use elements instead? not a big deal as this is not exposed to the caller but still good to use internally consistent variable names
linkml_runtime/utils/schemaview.py
Outdated
""" | ||
Get a Model element by prefix. | ||
|
||
Parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: can you change to the rst format used for other methods?
fixed up doc and moved categories -> elements |