pyLODE icon indicating copy to clipboard operation
pyLODE copied to clipboard

pyLODE in supermodel mode returns ValueError: Can't split 'ontologyURI'

Open nataschake opened this issue 9 months ago • 5 comments

Hi, I try to follow the exem-ont example and to create a similar view for cityrdf repo. I created pylode-config.ttl and pylode.ttl (although its name can be changed not to interfere with pylode ontology) and run a command like

python pylode -p supermodel pylode-config.ttl

It correctly reads the file and fails with ValueError:

Traceback (most recent call last): File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/home/nata/work/pyLODE/pylode/main.py", line 6, in main() File "/home/nata/work/pyLODE/pylode/cli.py", line 66, in main html = Supermodel(args.input, sort_subjects = sort_subjects) File "/home/nata/work/pyLODE/pylode/profiles/supermodel/html.py", line 103, in init self.query = QueryClass(self.ont) File "/home/nata/work/pyLODE/pylode/profiles/supermodel/query/init.py", line 413, in init self.ns = self.get_ns() File "/home/nata/work/pyLODE/pylode/profiles/supermodel/query/init.py", line 666, in get_ns prefix = ont.compute_qname(default_iri, True)[0] File "/usr/local/lib/python3.10/dist-packages/rdflib/graph.py", line 1186, in compute_qname return self.namespace_manager.compute_qname(uri, generate) File "/usr/local/lib/python3.10/dist-packages/rdflib/namespace/init.py", line 571, in compute_qname raise e File "/usr/local/lib/python3.10/dist-packages/rdflib/namespace/init.py", line 565, in compute_qname namespace, name = split_uri(uri) File "/usr/local/lib/python3.10/dist-packages/rdflib/namespace/init.py", line 872, in split_uri raise ValueError("Can't split '{}'".format(uri)) ValueError: Can't split 'https://www.opengis.net/ont/citygml/'

Any idea of what to do with this?

nataschake avatar Feb 12 '25 12:02 nataschake

Can you try changing the profile IRI here to something that does not end with a slash?

Pylode is trying to use it as the default IRI for the main model and if possible, create a CURIE using the compute_qname function. But because the IRI here ends in a slash, it's failing to split correctly (I think).

Try changing it to something like <https://www.opengis.net/ont/citygml/profile>.

edmondchuc avatar Feb 12 '25 13:02 edmondchuc

Ok, now the error is:

Traceback (most recent call last): File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/home/nata/work/pyLODE/pylode/main.py", line 6, in main() File "/home/nata/work/pyLODE/pylode/cli.py", line 66, in main html = Supermodel(args.input, sort_subjects = sort_subjects) File "/home/nata/work/pyLODE/pylode/profiles/supermodel/html.py", line 103, in init self.query = QueryClass(self.ont) File "/home/nata/work/pyLODE/pylode/profiles/supermodel/query/init.py", line 419, in init self.component_models = self.load_component_models() File "/home/nata/work/pyLODE/pylode/profiles/supermodel/query/init.py", line 729, in load_component_models component_model = self.load_component_model(iri, self.db) File "/home/nata/work/pyLODE/pylode/profiles/supermodel/query/init.py", line 681, in load_component_model profile_graph = db.get_graph(iri) File "/usr/local/lib/python3.10/dist-packages/rdflib/graph.py", line 2166, in get_graph return [x for x in self.contexts() if x.identifier == identifier][0] IndexError: list index out of range

nataschake avatar Feb 12 '25 14:02 nataschake

This error is due to your resources of type lode:Module are not also typed as prof:Profile. Sorry about the error messages. Perhaps any resources that pylode finds with lode:Module should check that they all have the required prof:Profile class.

In your pylode.ttl, can you please add a prof:Profile to each instance of lode:Module please.

You might want to add the / back in your pylode.ttl. The previous error you had was due to the slash existing on pylode-config.ttl. Again, sorry about the error messages :(

Lastly, pylode supermodel will also import any ontologies specified with owl:imports. I noticed you have a few imports that are returning 404. For example, in appearance.ttl, this import will fail <http://def.isotc211.org/iso19150/-2/2012/base>. You may want to either remove or comment these lines out for now to get an initial working version.

edmondchuc avatar Feb 12 '25 14:02 edmondchuc

Thank you! I finally asked here https://github.com/ISO-TC211/StandardsTracker/issues/522. It is not correct to sacrifice semantics (iso19150-2 is not just mentioned, it is used) , is it? Anyway, some redirect/substitute/ whatever would be much appreciated in pyLODE settings to avoid such situations.

nataschake avatar Feb 25 '25 11:02 nataschake

Can we have something similar to what Protege has for owl:imports handling, ako config file catalog-001.xml where the actual links are substituted by a human selecting proper file locally or somewhere from agreed space.

nataschake avatar Apr 10 '25 10:04 nataschake