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

Interpret `rdfs:Class` as classes on SimPhoNy v3, include dcmitype and dcterms namespaces #760

Closed kysrpex closed 2 years ago

kysrpex commented 2 years ago

@MBueschelberger just made the PR myself from your branch. As said, I will look into merging this.

MBueschelberger commented 2 years ago

Hi @kysrpex, thanks for regarding my commits!

I will have a meeting on Friday this week in order to discuss the inluded yml-specs. If there are no further suggestions on the implementation, I would consider this PR to be ready from my side.

kysrpex commented 2 years ago

@MBueschelberger I think with the latest changes most things are OK. I am still unsure about the requirements declared on the new yml files (they look OK at first sight though) and whether defining the relationships you chose as active makes sense or not. I might ask tomorrow for some assistance from somebody else that has used these ontologies.

kysrpex commented 2 years ago

@pablo-de-andres @yoavnash Please read this comment and judge whether this should be documented or not. It is essentially incomplete support for RDFS vocabularies (only classes). Also if you consider yourself experienced enough with the ontologies that @MBueschelberger has introduced, please consider reviewing these aspects.

@MBueschelberger please consider also making a PR on the docs and documenting it yourself if @pablo-de-andres or @yoavnash require documentation, because within the coming days I have not much flexibility to do this + look at the requirements and active relationships issue and your PR can be delayed even further.

kysrpex commented 2 years ago

@yoavnash @pablo-de-andres I am aware that tests are failing for Python 3.6, but there are a lot of things that can be reviewed already.

pablo-de-andres commented 2 years ago

Maybe a point could be added to this section with the predicates that are used to define classes?

kysrpex commented 2 years ago

Maybe a point could be added to this section with the predicates that are used to define classes?

Done (see docs PR)

kysrpex commented 2 years ago

@yoavnash @pablo-de-andres I am aware that tests are failing for Python 3.6, but there are a lot of things that can be reviewed already.

This has been solved now, the PR is fully ready to review together with docs.

kysrpex commented 2 years ago

Added quick and dirty dependency resolution as @yoavnash requested here, together with a lot of technical debt. Thank god it is on SimPhoNy v3.

Examples:

$ pico install dcat2
INFO 2022-03-24 17:52:19,681 [osp.core.ontology.installation]: Additional ontology packages were queued for installation because some of the packages to be installed depend on them: dcmitype was queued because dcterms depends on it; dcterms was queued because dcat2 depends on it; foaf was queued because dcat2 depends on it; prov was queued because dcat2 depends on it.
INFO 2022-03-24 17:52:19,681 [osp.core.ontology.installation]: Will install the following namespaces: ['prov', 'foaf', 'dcmitype', 'dcterms', 'dcat2']
INFO 2022-03-24 17:52:19,682 [osp.core.ontology.namespace_registry]: Loading namespaces prov, http://www.w3.org/ns/prov#.
INFO 2022-03-24 17:52:19,682 [osp.core.ontology.parser.owl.parser]: Downloading http://www.w3.org/ns/prov-o.
INFO 2022-03-24 17:52:25,624 [osp.core.ontology.namespace_registry]: Loading namespaces foaf, http://xmlns.com/foaf/0.1/.
INFO 2022-03-24 17:52:25,624 [osp.core.ontology.parser.owl.parser]: Downloading http://xmlns.com/foaf/spec/index.rdf.
INFO 2022-03-24 17:52:26,382 [osp.core.ontology.namespace_registry]: Loading namespaces dcmitype, http://purl.org/dc/dcmitype/.
INFO 2022-03-24 17:52:26,382 [osp.core.ontology.parser.owl.parser]: Downloading https://www.dublincore.org/specifications/dublin-core/dcmi-terms/dublin_core_type.ttl.
INFO 2022-03-24 17:52:26,547 [osp.core.ontology.namespace_registry]: Loading namespaces dcterms, http://purl.org/dc/terms/.
INFO 2022-03-24 17:52:26,547 [osp.core.ontology.parser.owl.parser]: Downloading https://www.dublincore.org/specifications/dublin-core/dcmi-terms/dublin_core_terms.ttl.
WARNING 2022-03-24 17:52:26,746 [osp.core.ontology.parser.owl.parser]: The ontology package dcterms contains the following RDF properties: http://purl.org/dc/terms/accessRights, http://purl.org/dc/terms/accrualPolicy, http://purl.org/dc/terms/accrualPeriodicity, http://purl.org/dc/terms/abstract, http://purl.org/dc/terms/accrualMethod and 50 more. 
As RDF properties are not supported by OSP-core, the aforementioned properties will be ignored.
INFO 2022-03-24 17:52:26,792 [osp.core.ontology.namespace_registry]: Loading namespaces dcat2, http://www.w3.org/ns/dcat#.
INFO 2022-03-24 17:52:26,792 [osp.core.ontology.parser.owl.parser]: Downloading https://www.w3.org/ns/dcat2.rdf.
INFO 2022-03-24 17:52:28,170 [osp.core.ontology.installation]: Installation successful
$ pico uninstall dcmitype
ERROR 2022-03-24 17:53:03,996 [osp.core.pico]: An Exception occurred during installation.
Traceback (most recent call last):
  File "/home/jose/.local/lib/python3.10/site-packages/osp/core/pico.py", line 114, in terminal
    uninstall(*args.packages)
  File "/home/jose/.local/lib/python3.10/site-packages/osp/core/pico.py", line 42, in uninstall
    ontology_installer.uninstall(*package_names)
  File "/home/jose/.local/lib/python3.10/site-packages/osp/core/ontology/installation.py", line 71, in uninstall
    self._install(files_or_namespaces, self._get_remaining_packages, True)
  File "/home/jose/.local/lib/python3.10/site-packages/osp/core/ontology/installation.py", line 278, in _install
    files = self._sort_for_installation(filter_func(files),
  File "/home/jose/.local/lib/python3.10/site-packages/osp/core/ontology/installation.py", line 176, in _get_remaining_packages
    raise RuntimeError(message)
RuntimeError: Cannot remove package dcmitype, because other installed packages depend on it: package dcat2 depends on dcterms; package dcterms depends on dcmitype. Please remove the packages dcterms, dcat2 and dcmitype all together.
ERROR 2022-03-24 17:53:03,997 [osp.core.pico]: Consider running 'pico --log-level debug uninstall ...'
$ pico uninstall prov
ERROR 2022-03-24 17:53:32,505 [osp.core.pico]: An Exception occurred during installation.
Traceback (most recent call last):
  File "/home/jose/.local/lib/python3.10/site-packages/osp/core/pico.py", line 114, in terminal
    uninstall(*args.packages)
  File "/home/jose/.local/lib/python3.10/site-packages/osp/core/pico.py", line 42, in uninstall
    ontology_installer.uninstall(*package_names)
  File "/home/jose/.local/lib/python3.10/site-packages/osp/core/ontology/installation.py", line 71, in uninstall
    self._install(files_or_namespaces, self._get_remaining_packages, True)
  File "/home/jose/.local/lib/python3.10/site-packages/osp/core/ontology/installation.py", line 278, in _install
    files = self._sort_for_installation(filter_func(files),
  File "/home/jose/.local/lib/python3.10/site-packages/osp/core/ontology/installation.py", line 176, in _get_remaining_packages
    raise RuntimeError(message)
RuntimeError: Cannot remove package prov, because other installed packages depend on it: dcat2. Please remove the packages prov and dcat2 all together.
ERROR 2022-03-24 17:53:32,505 [osp.core.pico]: Consider running 'pico --log-level debug uninstall ...'
$ pico uninstall foaf
ERROR 2022-03-24 17:54:20,238 [osp.core.pico]: An Exception occurred during installation.
Traceback (most recent call last):
  File "/home/jose/.local/lib/python3.10/site-packages/osp/core/pico.py", line 114, in terminal
    uninstall(*args.packages)
  File "/home/jose/.local/lib/python3.10/site-packages/osp/core/pico.py", line 42, in uninstall
    ontology_installer.uninstall(*package_names)
  File "/home/jose/.local/lib/python3.10/site-packages/osp/core/ontology/installation.py", line 71, in uninstall
    self._install(files_or_namespaces, self._get_remaining_packages, True)
  File "/home/jose/.local/lib/python3.10/site-packages/osp/core/ontology/installation.py", line 278, in _install
    files = self._sort_for_installation(filter_func(files),
  File "/home/jose/.local/lib/python3.10/site-packages/osp/core/ontology/installation.py", line 176, in _get_remaining_packages
    raise RuntimeError(message)
RuntimeError: Cannot remove package foaf, because other installed packages depend on it: dcat2. Please remove the packages dcat2 and foaf all together.
ERROR 2022-03-24 17:54:20,238 [osp.core.pico]: Consider running 'pico --log-level debug uninstall ...'
$ pico uninstall foaf prov dcmitype foaf dcat2 dcterms
INFO 2022-03-24 17:55:09,448 [osp.core.ontology.installation]: Will install the following namespaces: []
INFO 2022-03-24 17:55:09,451 [osp.core.ontology.installation]: Uninstallation successful

@yoavnash If this is not enough, I would say to drop the idea of automatic dependency resolution for SimPhoNy v3. It would be much more worthwile to invest the time in a long-term solution for SimPhoNy v4. This is already consuming a lot of time that is not being invested in SimPhoNy v4.

kysrpex commented 2 years ago

For reference: the last commit implements additional changes requested on the docs PR.