Fix network-dependent test failures from upstream linkml-model changes#3215
Fix network-dependent test failures from upstream linkml-model changes#3215
Conversation
The upstream linkml-model (served from w3id.org/linkml/) changed in two ways: 1. Whitespace normalization in type descriptions (double space to single) 2. URI-typed slots now serialize as Literal(xsd:anyURI) instead of URIRef Update stale snapshots and adjust two test assertions to compare string values rather than relying on rdflib node type identity. Fixes #3214
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3215 +/- ##
===========================================
+ Coverage 18.84% 83.84% +65.00%
===========================================
Files 147 148 +1
Lines 16724 16973 +249
Branches 3474 3504 +30
===========================================
+ Hits 3151 14231 +11080
+ Misses 13556 1954 -11602
- Partials 17 788 +771
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Updates network-dependent LinkML tests/snapshots to match upstream linkml-model serialization changes (whitespace tweaks in schema text and URI-typed values appearing as Literal(xsd:anyURI) in RDF output), unblocking currently failing @pytest.mark.network tests.
Changes:
- Refreshed multiple RDF/Turtle and JSON snapshot fixtures to align with the current upstream
linkml-modelschema/serialization. - Adjusted RDF assertions in
test_issue_3to compare URI values by lexical form (string) rather than strict RDF term type. - Relaxed
test_rdfgen’slinkml:tagassertion to tolerate URIRef-vs-typed-Literal differences.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/linkml/test_utils/snapshots/import_test_1.json | Snapshot update for upstream whitespace change in type notes. |
| tests/linkml/test_issues/test_issue_3.py | Loosens RDF term comparison for XSD date/datetime URIs. |
| tests/linkml/test_issues/snapshots/linkml_issue_388.ttl | Updates expected TTL output reflecting URI-typed literals and other upstream formatting changes. |
| tests/linkml/test_issues/snapshots/linkml_issue_388.owl | Snapshot update for restriction serialization ordering/structure changes. |
| tests/linkml/test_issues/snapshots/linkml_issue_384.ttl | Updates expected personinfo TTL snapshot for upstream URI literal behavior and ordering. |
| tests/linkml/test_issues/snapshots/issue_163d.ttl | Updates expected TTL snapshot for upstream URI literal behavior and ordering. |
| tests/linkml/test_generators/test_rdfgen.py | Adjusts annotation extension assertions to handle upstream URI serialization changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # tag may be a URIRef or a Literal with xsd:anyURI datatype, | ||
| # depending on the upstream linkml-model serialization | ||
| assert str(tag).startswith("my_tag") |
There was a problem hiding this comment.
The new assertion str(tag).startswith("my_tag") no longer verifies that linkml:tag is serialized as a URI node (either a URIRef or a Literal typed as xsd:anyURI). As written, the test would also pass if the tag were incorrectly serialized as a plain string literal, which weakens the protection this test provides for RDF serialization behavior. Consider asserting (1) the term type is URIRef OR a Literal with datatype xsd:anyURI, and (2) its value is exactly one of the expected tags (my_tag1 / my_tag2).
| assert str(XSD.date) == str(g.value(LINKML.date, LINKML.uri)) | ||
| assert str(XSD.dateTime) == str(g.value(LINKML.datetime, LINKML.uri)) |
There was a problem hiding this comment.
Casting RDF terms to str makes the assertion insensitive to whether linkml:uri is a proper URI node vs an incorrectly-typed literal (e.g., an xsd:string literal that happens to contain the same lexical form). To keep the test resilient to the upstream URIRef vs Literal(xsd:anyURI) change while still validating RDF typing, consider asserting the object is either a URIRef equal to XSD.date/XSD.dateTime or a Literal with datatype xsd:anyURI whose lexical value matches.
cmungall
left a comment
There was a problem hiding this comment.
Thanks @turbomam
This is logical, however, I think we should modify the behavior of the rdf serializer such that curies and uris are represented as RDF nodes rather than literals. We can introduce behavior where people can customize this.
This does require an unusual reading of what is in types.yaml, but let's take that conversation here: #2213
amc-corey-cox
left a comment
There was a problem hiding this comment.
This looks like a good spot-fix to get main working again until we agree on implementation in #3221. I'm going to try to skip this and merge the more comprehensive PR instead but I may fall back to this one.
|
I'm closing this as superseded by #3221 |
Summary
Literal(xsd:anyURI)instead ofURIRefThe upstream linkml-model changed whitespace in type descriptions and how URI-typed slots are represented in RDF. These 6
@pytest.mark.networktests fail on all branches.Test plan
--with-networkFixes #3214