Skip to content

Commit

Permalink
Do not attempt to use expanded prefix if it is not found in importmap
Browse files Browse the repository at this point in the history
  • Loading branch information
pkalita-lbl committed Sep 14, 2023
1 parent 67fe2e1 commit b04b0e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions linkml_runtime/utils/context_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ def map_import(importmap: Dict[str, str], namespaces: Callable[[None], "Namespac
# the importmap may contain mappings for prefixes
prefix, lname = sname.split(':', 1)
prefix += ':'
expanded_prefix = importmap.get(prefix, prefix)
if expanded_prefix.startswith("http"):
sname = expanded_prefix + lname
else:
sname = os.path.join(expanded_prefix, lname)
expanded_prefix = importmap.get(prefix)
if expanded_prefix is not None:
if expanded_prefix.startswith("http"):
sname = expanded_prefix + lname

Check warning on line 72 in linkml_runtime/utils/context_utils.py

View check run for this annotation

Codecov / codecov/patch

linkml_runtime/utils/context_utils.py#L72

Added line #L72 was not covered by tests
else:
sname = os.path.join(expanded_prefix, lname)
sname = importmap.get(sname, sname) # Import map may use CURIE
sname = str(namespaces().uri_for(sname)) if ':' in sname else sname
return importmap.get(sname, sname) # It may also use URI or other forms
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils/test_schemaview.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ def test_non_linkml_remote_import(self):
prefixes=[
Prefix(
prefix_prefix="foo",
prefix_reference="https://w3id.org/linkml"
prefix_reference="https://w3id.org/linkml/"
)
],
imports=[
Expand Down

0 comments on commit b04b0e3

Please sign in to comment.