Skip to content

Fix detection of CURIES vs. absolute paths on Windows #391

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

Merged
merged 5 commits into from
May 19, 2025

Conversation

dalito
Copy link
Member

@dalito dalito commented May 15, 2025

upstream_repo: dalito/linkml
upstream_branch: issue2696-remove-windows-special-casing

Fixes issues in utils/context_utils.py:

  • Avoids that absolute filepaths are treated as CURIES on Windows
  • Fixes wrongly typed callable in map_import function
  • Fixes test-upstream action to install linkml with --all-extras (else the pandera tests fail)

@ialarmedalien , @sierra-moxon - This was the problem you hit in linkml/linkml#2675

Related to linkml/linkml#2696

@dalito dalito force-pushed the issue2696-curie-vs-path-on-windows branch from 662b1ad to a7a5102 Compare May 15, 2025 13:47
Copy link

codecov bot commented May 15, 2025

Codecov Report

Attention: Patch coverage is 57.14286% with 3 lines in your changes missing coverage. Please review.

Project coverage is 63.76%. Comparing base (b2206a4) to head (cd17c76).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
linkml_runtime/utils/context_utils.py 57.14% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #391      +/-   ##
==========================================
- Coverage   63.79%   63.76%   -0.03%     
==========================================
  Files          63       63              
  Lines        8938     8942       +4     
  Branches     2584     2586       +2     
==========================================
  Hits         5702     5702              
- Misses       2629     2631       +2     
- Partials      607      609       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@ialarmedalien ialarmedalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for tracking this down so quickly!

Can you add some tests?

@@ -73,7 +73,8 @@ def map_import(importmap: dict[str, str], namespaces: Callable[[None], "Namespac
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
if ':' in sname and not ":\\" in sname: # Don't interpret Windows paths as CURIEs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know there's at least one other place (apart from the one below) where there's a similar check to try to determine if something is a CURIE or not. I wonder if it'd be better to extract this out into a separate function -- I know it's an extremely simple check, but maybe it would lessen the chance of similar errors occurring elsewhere. There's a bug in the SchemaViewer that stops remote schemas being imported from other remote schemas, and it's due to this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if it is worth to move the check into a function. I still hope that one day we will use more specific types (Path, URI, CURIE) instead of string. This would make the code much cleaner.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, that's the best way to fix the issue. One day...!

@dalito
Copy link
Member Author

dalito commented May 16, 2025

Test added! ...and converted other tests in the file from unittest to pytest.

I also made a corresponding PR for linkml: linkml/linkml#2698 which can only be merged after a new release of linkml-runtime with this fix.

@dalito dalito force-pushed the issue2696-curie-vs-path-on-windows branch from cf714ab to fa6d966 Compare May 16, 2025 00:19
@@ -103,7 +110,7 @@ def parse_import_map(map_: Optional[Union[str, dict[str, str], TextIOWrapper]],
if base:
outmap = dict()
for k, v in rval.items():
if ':' not in v:
if ':' not in v or ":\\" in v: # Don't interpret Windows paths as CURIEs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@sierra-moxon sierra-moxon merged commit 9501812 into linkml:main May 19, 2025
16 checks passed
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