-
Notifications
You must be signed in to change notification settings - Fork 555
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
Fix prov ns #1318
Fix prov ns #1318
Conversation
5 similar comments
This PR is failing tests with the "Cannot assign requested address" error so it the reviews are OK, I'll merge it (i.e. don't take the tests seriously). |
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.
Looks good to me.
I ran a check with: Namespace.test_prov and it passes, also check sorting.
With this change rdflib.namespace.PROV
will contain all terms matching [] rdfs:isDefinedBy <http://www.w3.org/ns/prov-o#>
from http://www.w3.org/ns/prov.ttl
.
For reference the exact test I ran against it: def test_prov(self) -> None:
graph = Graph()
graph.parse(source=(SCRIPT_PATH.parent / "data" / "prov.ttl"), format="turtle")
qres = graph.query(
r"""
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT DISTINCT ?term ?ontology WHERE {
?term ?p [].
# MINUS { ?term rdf:type owl:AnnotationProperty }
FILTER isIRI(?term).
FILTER strStarts(str(?term), "http://www.w3.org/ns/prov#").
FILTER (str(?term) != "http://www.w3.org/ns/prov#")
OPTIONAL { ?term rdfs:isDefinedBy ?ontology }
}
"""
)
owl_terms = {}
for row in qres:
owl_terms[row["term"]] = row["ontology"]
owl_term_set = set(owl_terms.items())
provo_uri = URIRef("http://www.w3.org/ns/prov-o#")
# provo_term_set is terms matching :
# [] rdfs:isDefinedBy <http://www.w3.org/ns/prov-o#>
provo_term_set = set([term for term in owl_term_set if term[1] == provo_uri])
rdflib_term_set = set(
[
(PROV[termword], owl_terms.get(PROV[termword], None))
for termword in dir(PROV)
]
)
self.assertLessEqual(provo_term_set, rdflib_term_set)
self.assertGreaterEqual(owl_term_set, rdflib_term_set) I won't mind making a PR for it, but it is rather slow and does not necessarily make sense to run every time, could maybe add them conditional on an environment variable like |
Merging as the only error is the old annoying one of not being able to assign an address (i.e. not a real error). |
Fixes #1308
Proposed Changes
@aucampia please review since you motivated this fix. Just want you to make sure I got it right.