-
Notifications
You must be signed in to change notification settings - Fork 29
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
lexical_index_to_sssom()
EPM param
#697
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,6 +247,7 @@ def lexical_index_to_sssom( | |
ruleset: MappingRuleCollection = None, | ||
meta: Optional[Dict[str, t.Any]] = None, | ||
prefix_map: Union[None, Converter, t.Mapping[str, str]] = None, | ||
extended_prefix_map: t.Iterable[Dict[str, t.Any]] = None, | ||
subjects: Collection[CURIE] = None, | ||
objects: Collection[CURIE] = None, | ||
symmetric: bool = False, | ||
|
@@ -265,6 +266,9 @@ def lexical_index_to_sssom( | |
:param ensure_strict_prefixes: If true, prefixes & mappings in SSSOM MappingSetDataFrame will be filtred. | ||
:return: SSSOM MappingSetDataFrame object. | ||
""" | ||
if prefix_map and extended_prefix_map: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exception handlingThrows error if both |
||
raise ValueError("Can only pass prefix_map or extended_prefix_map, but not both.") | ||
|
||
mappings = [] | ||
logging.info("Converting lexical index to SSSOM") | ||
if subjects: | ||
|
@@ -313,7 +317,11 @@ def lexical_index_to_sssom( | |
|
||
converter = curies.chain( | ||
[ | ||
Converter.from_prefix_map((meta or {}).pop(CURIE_MAP, {})), | ||
Converter.from_extended_prefix_map(extended_prefix_map) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How the param is usedThis is handles the various scenarios in which a user might pass a prefix map. Before my changes there were already 2 ways in which a user might pass it, either within |
||
if extended_prefix_map | ||
else Converter.from_prefix_map(prefix_map) | ||
if prefix_map | ||
else Converter.from_prefix_map((meta or {}).pop(CURIE_MAP, {})), | ||
ensure_converter(prefix_map, use_defaults=False), | ||
oi.converter, | ||
] | ||
|
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.
extended_prefix_map
param addedI also wanted it to have the same type signature as in
curies
, which isLocationOr[Iterable[Union[Record, Dict[str, Any]]]] = None
. However, when I didfrom curies.mapping_service.utils import Records
, I gotModuleNotFoundError: No module named 'defusedxml'
. I definitely don't think it's worth installing an additional package in OAK simply for better / more consistent typing.I suppose an alternative to adding a new param would simply to overload the
prefix_map
param even more, but I opted not because itis already overloaded. I actually don't like this param because it supports either a prefix mapDict
or aConverter
object, and I think that makes it a little unclear / poorly named.