GAIA-X4PLC-AAD / ontology-management-base

Our implementation for an open automated ontology management process for GAIA-X interoperable ecosystems. Please use a community agreed domain specific class or if not yet available please create a new class and submit it for review.
Other
2 stars 0 forks source link

Ontology management

Purpose

This repository is used to maintain the custom Ontologies and associated SHACL Shapes that are used within a specific Scope. It's also used to ensure a unified process for handling the Ontologies & Shapes.

Ontologies are required, when there is a need to introduce a custom type for a Self Description which should be expressed as an OWL class. For each class a SHACL Shape must be defined, which defines the properties for the class and optional constraints.

Repository structure

The repository contains a folder for each domain in the project which stores Turtle files for the domain-specific Ontologies and associated SHACL Shapes.

Example files can be found in the folder example in the this repository.

Process

This section describes the general process to apply changes to the Ontologies & SHACL Shapes.

General process

  1. Checkout the repository
  2. Create a local feature branch that will store the changes
  3. Perform changes (see Modeling Guidelines, Creating a new Ontology & Shape or Modify an existing Ontology & Shape)
  4. Push the branch to remote
  5. Check the CI pipeline status.
  6. Open a Pull Request and describe the changes according to the provided template which should help the Reviewer to understand why the changes are important from you point of view
  7. Review process performed by Reviewers
  8. (optional) Apply changes recommended by the Reviewer
  9. Reviewer merges Pull Request to main branch and adds the changes (SHACL file and/or Ontology file) to the Federated Catalogue via its API (supported by Github Action)

Creating a new Ontology & Shape

In the case you want to create a new Class which is not suitable for the existing Ontologies, you should create a new Ontology that contains this class. An Ontology describes a set of classes in a specific subject area and how they are related. A domain may contain multiple Ontologies.

  1. Create a folder for the Domain, if it does not already exist.
  2. Create a Turtle file for the Ontology
  3. Describe the new type as an OWL Class in the Ontology
  4. Create a Turtle file for the SHACL Shape
  5. Describe a NodeShape in the SHACL file that refers to the class created in step 3 and describes its properties and their constraints
  6. Add a new entry to the CODEOWNERS file in the root directory of this repository and specify the owners for the new directory (see Review process section below).

Modify an existing Ontology & Shape

In the case you want to create a new Class which fits to any of the existing Ontologies in the Domain, you should add this class to the existing Ontology.

  1. Describe the new type as an OWL Class in the existing Ontology
  2. Describe a NodeShape in the SHACL file that refers to the class created in step 1 and describes its properties and their constraints

Review process responsibilities

Modeling Guidelines

This section describes guidelines that must be followed when applying changes to this repository.

General

Directories & files

Ontologies

SHACL Shapes

CI pipeline

The CI/CD pipeline is defined in the .github/workflows directory. The pipeline is triggered on every push to the repository as defined in the workflow. The result can be seen in the Actions tab in the github repository.

Steps

Generate VARIABLES.md (overview of used properties in the SHACL files)

The file VARIABLES.md will be generated automatically when a push to a non-main branch is executed. This file is existent in every subdirectory once there is a SHACL file containing properties. This should help to get a fast overview of the properties used in the SHACL files.

NOTE: the VARIABLES.md file should not be changed since it will be overwritten automatically.

Check syntax of Turtle files

The pipeline checks the syntax of the Turtle files (*.ttl) by loading a RDF graph. If the Turtle file is not correct the pipeline fails with a detailed error message.

Check if _instance.json file is conform to the SHACL Shape(s)

The pipeline checks if the _instance.json file is conform to the SHACL Shape(s) defined in the corresponding SHACL file. For this all *_shacl.ttl files in this repository are collected to be able to check against a schema not defined in the current SHACL Shape. If the instance is not conform the pipeline fails with a detailed error message.

Run the pipeline scripts locally

# prepare venv (optional)
$ python3 -m venv .venv
$ source .venv/bin/activate
(.venv) $ python3 -m pip install --upgrade pip
(.venv) $ python3 -m pip install -r src/requirements_ci.txt
# execute check from CI
python3 src/check_ttl_syntax.py <path_to_ttl_file>
python3 src/check_jsonld_against_shacl_schema.py <directory name>

Example:

python3 src/check_ttl_syntax.py scenario/scenario_ontology.ttl
python3 src/check_jsonld_against_shacl_schema.py scenario

You might use py or python instead of python3 depending on your system.

Further information

Related repository

Helpful Plugins

To handle and display rdf-files, especially .ttl files, you can use an IDE with plugins. Following plugins have been experienced as being very helpful:

Known issues

Issues with SD-Creation-Wizard