Skip to content

Commit

Permalink
fix ask query for full url (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsavchenko authored May 17, 2024
1 parent b998c29 commit 73e0e8d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion oda_api/ontology_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,5 +460,6 @@ def resources():
yield dict(resource=str(resource).split('#')[-1], required=required, env_vars=env_vars)

def is_optional(self, uri: str) -> bool:
s_qres = self.g.query("ASK { %s rdfs:subClassOf? oda:optional. }" % uri )
if uri.startswith("http"): uri = f"<{uri}>"
s_qres = self.g.query("ASK {%s rdfs:subClassOf? oda:optional .}" % uri )
return cast(bool, list(s_qres)[0])
1 change: 1 addition & 0 deletions tests/test_ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ def test_is_optional(onto):
extra_ttl = add_prefixes + 'oda:OptFloat rdfs:subClassOf oda:Float, oda:optional .'
onto.parse_extra_triples(extra_ttl)

assert onto.is_optional(f'{oda_prefix}Float') is False
assert onto.is_optional('oda:Float') is False
assert onto.is_optional('oda:OptFloat') is True
assert onto.is_optional('oda:optional') is True
Expand Down

0 comments on commit 73e0e8d

Please sign in to comment.