ontology2dot not working with foaf ontology
ontology2dot foaf
[...]
Traceback (most recent call last):
File "/home/dea/venv/bin/ontology2dot", line 11, in <module>
load_entry_point('osp-core', 'console_scripts', 'ontology2dot')()
File "/mnt/c/Users/dea/Documents/Projects/simphony/osp-core/osp/core/tools/ontology2dot.py", line 208, in run_from_terminal
converter.render()
File "/mnt/c/Users/dea/Documents/Projects/simphony/osp-core/osp/core/tools/ontology2dot.py", line 66, in render
self._add_namespace(namespace)
File "/mnt/c/Users/dea/Documents/Projects/simphony/osp-core/osp/core/tools/ontology2dot.py", line 79, in _add_namespace
self._add_entity(entity)
File "/mnt/c/Users/dea/Documents/Projects/simphony/osp-core/osp/core/tools/ontology2dot.py", line 94, in _add_entity
self._add_relationship(entity, graph)
File "/mnt/c/Users/dea/Documents/Projects/simphony/osp-core/osp/core/tools/ontology2dot.py", line 133, in _add_relationship
if not rel.inverse.name.startswith("INVERSE_OF") \
File "/mnt/c/Users/dea/Documents/Projects/simphony/osp-core/osp/core/ontology/relationship.py", line 45, in inverse
return self.namespace._namespace_registry.from_iri(o)
File "/mnt/c/Users/dea/Documents/Projects/simphony/osp-core/osp/core/ontology/namespace_registry.py", line 174, in from_iri
raise KeyError(f"IRI {iri} not found in graph or not of any "
KeyError: "IRI http://xmlns.com/foaf/0.1/isPrimaryTopicOf not found in graph or not of any type in the set frozenset({rdflib.term.URIRef('http://www.w3.org/2002/07/owl#Class'), rdflib.term.URIRef('http://www.w3.org/2002/07/owl#ObjectProperty'), rdflib.term.URIRef('http://www.w3.org/2002/07/owl#DatatypeProperty')})"
The problem is that the specified type of isPrimaryTopicOf is InverseFunctionalProperty, a subclass of ObjectProperty. OSP-core does not recognize this subclass relationship between InverseFunctionalProperty and ObjectProperty and doesn't know whether to instantiate an OntologyClass, OntologyRelationship or OntologyAttribute.
See https://github.com/simphony/osp-core/blob/master/osp/core/ontology/namespace_registry.py#L162-L172
Potential solution: Load the ontology that describes the subclass relationship between InverseFunctionalProperty and ObjectProperty and evaluate this

The transitive_hull method won't work here because it is meant to be applied on an already instantiated OntologyEntity. There is however a more primitive method Graph.transitiveClosure from rdflib that we can take advantage of.
As @urbanmatthias pointed, there is also the issue that the OWL ontology is not loaded in the graph. I would like to note however, that, to the user, when running pico list it looks like the OWL ontology is "installed", but it is in fact not, as its information is not on the graph.
Therefore there are actually three issues to solve here: including OWL with osp-core (which could be merged with #455), modifying from_iri on namespace_registry.py in a way similar to the following
if o == rdflib.OWL.DatatypeProperty: -> if rdflib.OWL.DatatypeProperty in rdflibtrasitivehull(o):
and lastly, not display OWL and others as installed in pico list when in fact this is not the case.