Skip to content

Commit

Permalink
Change the session and ontology architecture to base it completely on…
Browse files Browse the repository at this point in the history
… graphs, use RDFLib stores as interfaces for external software (#765)

Summary

* Drop support for Python 3.6.

* Overhaul of ontology entities. All entities are just an interface to a session.

* Unified session and ontology. The session can fetch T-Box related entities either from itself or from another session.

* The session becomes just a layer on top of an RDFLib graph. Therefore, the session registry, and the neighbor dicts disappear. Everything is now done on the graph.

* Replaced vectors by hashable custom class based on numpy arrays.

* The wrapper functionality now goes to an RDFLib Store (the interface driver). The driver manages the wrappers. The wrapper developer implements wrappers. There is one single kind of wrapper.

* Container implementation.

* Change the wrapper so that it is both a session and a container when no root IRI is provided. Let a wrapper be a specific ontology individual.

* Wrapper unit tests from a user's perspective.

* Update the cuba and city ontologies, Wrapper -> Container. Added more comments.

* Allow setting the label of an ontology entity (which includes containers).

* Bump OSP-core version to 4.0.0.

* Remove `yaml2camelcase.py`.

* Transport layer now works at the triple level.

* Changed deprecated `MAINTAINER` to `LABEL org.opencontainers.image.authors`.

* Reproduce old CUDS containment notion when updating individuals.

* Include `annotations` namespace in the emmo installation file.

* RDFS "ontologies" are translated to OWL. rdfs:Class are interpreted as owl:Classes, rdf:Property as owl:AnnotationProperty. This is necessary to use vocabularies such as the Dublin Core™ Metadata Initiative vocabularies.

* Moved ontology entity catalog from `osp.core.ontology` to `osp.ontology` module.

* Moved all user-facing utils to `osp.core.tools` module.

* Migrate city to OWL.

* Preload required ontologies in ontology sessions.

* Use `rdflib-sqlalchemy` instead of the built-in SQL interface.

* Delete obsolete schema validation file.

* Inverse relationships on the RelationshipSets.

* Rebrand to SimPhoNy.

* Return added individuals when using `add` with containers for consistency.

* Remote interface, folder structure changes and linting.

* Adapt SPARQL functionality, reorganize tests.

* [pre-commit.ci] pre-commit autoupdate (#772)
  • Loading branch information
kysrpex authored Apr 12, 2022
1 parent b4e8803 commit 5bc152d
Show file tree
Hide file tree
Showing 232 changed files with 15,456 additions and 23,540 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
4 changes: 2 additions & 2 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Performance check
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
# - uses: actions/setup-python@v1 # (not needed for self-hosted runner)
# with:
# python-version: '3.8'
Expand All @@ -38,4 +38,4 @@ jobs:
alert-threshold: '150%'
comment-on-alert: true
alert-comment-cc-users: '@yoavnash,@pablo-de-andres,@kysrpex'
fail-on-alert: true
fail-on-alert: true
33 changes: 23 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,39 @@ name: CI
on: pull_request

jobs:
code_analysis:
PEP8:
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Flake8
run: flake8 . --exclude=*/__init__.py,osp/core/ontology/docs/EMMO/* --ignore=W503 --docstring-convention=google
run: flake8 . --ignore=E203,W503 --docstring-convention=google

# Includes isort, black and other checks, see `.pre-commit.config.yaml`.
- name: pre-commit
run: pre-commit run --all-files

complexity:
runs-on: self-hosted
steps:
- uses: actions/checkout@v3

- name: Radon
run: |
radon cc -s -a .,
radon mi -s .
- name: bandit
security:
runs-on: self-hosted
steps:
- uses: actions/checkout@v3

- name: Bandit
run: bandit -r osp --skip B101
test:

testing:
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- name: unittesting
- uses: actions/checkout@v3
- name: tox
run: tox

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ osp/core/java/target
osp/core/packageinfo.py
*.jar
*.so
osp/core/java/lib/so/FaCT++
osp/core/java/lib/so/FaCT++
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: check-json
- id: check-yaml
- id: pretty-format-json
args:
- --autofix
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
args: [--profile, black, --filter-files, --line-length, "79"]

- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
args: [--line-length, "79"]
18 changes: 7 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
FROM ubuntu:18.04
MAINTAINER [email protected]
LABEL org.opencontainers.image.authors="[email protected], [email protected], [email protected]"

RUN apt-get update && \
apt-get install -y python3.7 python3-pip
RUN python3.7 -m pip install --upgrade pip
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.7 2
RUN update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 2
RUN python -m pip install --upgrade pip

RUN ln -s /usr/bin/python3.7 /usr/bin/python & \
ln -s /usr/bin/pip3 /usr/bin/pip

ADD . /simphony/osp-core
WORKDIR /simphony/osp-core

RUN pip install tox
RUN tox -e py37
RUN python setup.py install
ADD . /simphony/simphony-osp
RUN pip install /simphony/simphony-osp
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Redistribution and use in source and binary forms, with or without modification,

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ include packageinfo.py
include osp/core/ontology/docs/*.yml
include osp/core/ontology/docs/*.xml
include osp/core/ontology/docs/*.ttl
include osp/core/ontology/docs/EMMO/emmo-inferred.owl
include osp/core/ontology/docs/EMMO/emmo-inferred.owl
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

## Note

For applications where performance is important, we recommend v3.4.2
For applications where performance is important, we recommend v3.4.2
The performance optimizations will be done as a next step to v3.5.X

# OSP core
Expand Down Expand Up @@ -36,7 +36,7 @@ We provide the tool `ontology2dot` to visualize your ontologies. You can visuali
ontology2dot <installed-namespace-1> ... <installed-namespace-n> <path/to/ontology-1.yml> ... <path/to/ontology-m.yml>

# Alternative
python -m osp.core.tools.ontology2dot <installed-namespace-1> ... <installed-namespace-n> <path/to/ontology-1.yml> ... <path/to/ontology-m.yml>
python -m simphony_osp.tools.ontology2dot <installed-namespace-1> ... <installed-namespace-n> <path/to/ontology-1.yml> ... <path/to/ontology-m.yml>
```

You can use parameter `-g` to group the namespaces. Use `-o` to change the filename of the resulting png file.
Expand Down Expand Up @@ -65,7 +65,7 @@ Further examples can be found in the /examples folder. There the usage of wrappe

## Troubleshooting

If installation fails, try to install the dependencies one by one before installing osp-core.
If installation fails, try to install the dependencies one by one before installing simphony-osp.
The dependencies are listed at the top of this readme file.

On Windows, unittests can fail when you use a virtual environment.
Expand All @@ -76,7 +76,7 @@ From our experience, this will not happen if you use the virtual environements o
### Directory structure

- osp/core -- The source code
- tools -- various tools to work with osp-core.
- tools -- various tools to work with simphony-osp.
- ontology -- the parser and generation of the entities and classes.
- yml -- The supplied ontology files
- session -- Different abstract classes for wrappers.
Expand All @@ -85,4 +85,5 @@ From our experience, this will not happen if you use the virtual environements o

## Acknowledgements

The OSP-core Python package originates from the European Project [SimPhoNy](https://www.simphony-project.eu/) (Project Nr. 604005). We would like to acknowledge and thank our project partners, especially [Enthought, Inc](https://www.enthought.com/), [Centre Internacional de Mètodes Numèrics a l'Enginyeria (CIMNE)](https://cimne.com/) and the [University of Jyväskylä](https://www.jyu.fi/en), for their important contributions to some of the core concepts of OSP-core, which were originally demonstrated under the project https://github.com/simphony/simphony-common.
The SimPhoNy Python package originates from the European Project [SimPhoNy]
(https://www.simphony-project.eu/) (Project Nr. 604005). We would like to acknowledge and thank our project partners, especially [Enthought, Inc](https://www.enthought.com/), [Centre Internacional de Mètodes Numèrics a l'Enginyeria (CIMNE)](https://cimne.com/) and the [University of Jyväskylä](https://www.jyu.fi/en), for their important contributions to some of the core concepts of OSP-core, which were originally demonstrated under the project https://github.com/simphony/simphony-common.
4 changes: 4 additions & 0 deletions examples/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""Examples module.
Contains examples showing the basic usage of the SimPhoNy OSP.
"""
70 changes: 0 additions & 70 deletions examples/api_example.py

This file was deleted.

Loading

0 comments on commit 5bc152d

Please sign in to comment.