simphony / simphony-osp

A framework that aims to achieve interoperability between software such as simulation engines, databases and data repositories using a knowledge graph as the common language.
https://simphony.readthedocs.io
Other
16 stars 12 forks source link

_check_duplicate_labels in ontology parser raises Keyerror #607

Closed MBueschelberger closed 3 years ago

MBueschelberger commented 3 years ago

When installing an inferred EMMO-onology with osp-core v3.5.2 and this configuration file, I get the following traceback:

root@74b5473bc5ad:/shared/cfd-ontology/application/inferred-ontologies# pico install gmshwrapper.yml 
INFO 2021-04-13 10:56:04,465 [osp.core.ontology.installation]: Will install the following namespaces: ['emmo']
INFO 2021-04-13 10:56:04,471 [osp.core.ontology.parser]: Parsing gmshwrapper.yml
INFO 2021-04-13 10:56:04,471 [osp.core.ontology.parser]: Parsing gmshwrapper-inferred.owl
ERROR 2021-04-13 10:56:06,349 [osp.core.pico]: An Exception occurred during installation.
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/osp/core/pico.py", line 63, in install_from_terminal
    ontology_installer.install(*args.files)
  File "/usr/local/lib/python3.6/site-packages/osp/core/ontology/installation.py", line 34, in install
    self._install(files, self._get_new_packages, False)
  File "/usr/local/lib/python3.6/site-packages/osp/core/ontology/installation.py", line 149, in _install
    parser.parse(file)
  File "/usr/local/lib/python3.6/site-packages/osp/core/ontology/parser.py", line 63, in parse
    file=f)
  File "/usr/local/lib/python3.6/site-packages/osp/core/ontology/parser.py", line 270, in _parse_rdf
    self._check_duplicate_labels(iri, identifier)
  File "/usr/local/lib/python3.6/site-packages/osp/core/ontology/parser.py", line 378, in _check_duplicate_labels
    conflicting_labels[labels[i]] |= {iris[i - 1], iris[i]}
KeyError: ('AbsorbedDose', 'en')
ERROR 2021-04-13 10:56:06,350 [osp.core.pico]: Consider running 'pico --log-level debug install ...'

The error obviously occurs in the _check_duplicate_labels of the osp.core.ontology.parser, even though AbsorbedDose only appears once as skos:prefLabel in the inferred-gmshwrapper.owl.

The error is obviously not related to the global SimPhoNy-graph, since it also appears if no other ontology is installed so far.

See the pico list:

root@74b5473bc5ad:/shared/cfd-ontology/application/inferred-ontologies# pico list
Packages:

Namespaces:
        - xml
        - rdf
        - rdfs
        - xsd
        - owl
        - cuba

While running the same command ("pico install --overwrite gmshwrapper.yml") in the cli for osp-core v3.5.1, the installation works seamessly.

kysrpex commented 3 years ago

Note to self and other developers: this is NOT a duplicate of issue #593.

There indeed a bug in the code that makes it not show the actual traceback that should be shown when there are duplicate labels. I have created pull request #608 to fix this bug.

This does not mean that there are not any items with duplicate labels, just that the wrong error is being thrown. You can try to install the ontology again with the first commit of the pull request to find the offenders. Just clone the OSP-core repository, enter it and git fetch && git checkout 2da6b87 && pip uninstall -y osp-core && pip install ., then you will get the correct traceback listing the offenders.

kysrpex commented 3 years ago

As the changes on the pull request branch are working correctly, I am closing the issue.