Skip to content

Commit e89bf6e

Browse files
committed
Merge branch 'main' into 2.1.x
2 parents 98ed946 + 10a4af1 commit e89bf6e

40 files changed

+2101
-826
lines changed

.github/pull_request_template.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Description
2+
3+
Please include a summary of the changes and the related issue. List any dependencies that are required for this change.
4+
5+
Fixes #(number of issue in GitHub)
6+
7+
## Type of change
8+
9+
Please delete options that are not relevant.
10+
11+
- [ ] Bug fix (non-breaking change which fixes an issue)
12+
- [ ] New feature (non-breaking change which adds functionality)
13+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
14+
15+
## Checklist:
16+
17+
- [ ] My code follows the style guidelines of this project
18+
- [ ] I have performed a self-review of my own code
19+
- [ ] I have commented my code, particularly in hard-to-understand areas
20+
- [ ] I have made corresponding changes to the documentation
21+
- [ ] My changes generate no new warnings
22+
- [ ] I have added tests that prove my fix is effective or that my feature works
23+
24+
## Additional notes:
25+
26+
Add any other notes or comments here.

AUTHORS.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
The following people have contributed to this repository:
44

5-
* [Georg Schmidt-Dumont]([email protected])
6-
* [Nico Makowe](mailto:[email protected])
7-
* [Aghyad Farrouh](mailto:[email protected])
5+
* [Hanna Shalamitskaya](mailto:[email protected])
86
* [Andreas Textor](mailto:[email protected])
7+
* [Georg Schmidt-Dumont](mailto:[email protected])
98
* [Michele Santoro](mailto:[email protected])
9+
* Nico Makowe
10+
* Aghyad Farrouh
1011

1112
Please add yourself to this list, if you contribute to the content.

CONVENTIONS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# ESMF SDK PY Aspect Model Loader Code Conventions
22

3-
The following document contains a compilation of conventions and guidelines to format, structure and write code for the ESMF SDK PY Aspect Model Loader.
3+
The following document contains a compilation of conventions and guidelines to format,
4+
structure and write code for the ESMF SDK PY Aspect Model Loader.
45

56
## General Conventions
67
Our code conventions are based on the [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html) but
Lines changed: 165 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,198 @@
11
The Aspect Model Loader as part of the Python SDK provided by the [*Eclipse Semantic Modeling Framework*](
22
https://projects.eclipse.org/projects/dt.esmf).
33

4+
<!-- TOC -->
5+
* [An Aspect of the Meta Model](#an-aspect-of-the-meta-model)
6+
* [Set Up SAMM Aspect Meta Model](#set-up-samm-aspect-meta-model)
7+
* [Install poetry](#install-poetry)
8+
* [Install project dependencies](#install-project-dependencies)
9+
* [Download SAMM files](#download-samm-files)
10+
* [Download SAMM release](#download-samm-release)
11+
* [Download SAMM branch](#download-samm-branch)
12+
* [Aspect Meta Model Loader usage](#aspect-meta-model-loader-usage)
13+
* [Samm Units](#samm-units)
14+
* [SAMM CLI wrapper class](#samm-cli-wrapper-class)
15+
* [Scripts](#scripts)
16+
* [Automation Tasks](#automation-tasks)
17+
* [tox](#tox)
18+
* [GitHub actions](#github-actions)
19+
* [Check New Pull Request](#check-new-pull-request)
20+
* [Build release](#build-release)
21+
<!-- TOC -->
22+
423
# An Aspect of the Meta Model
524

625
The `esmf-aspect-model-loader` package provides the Python implementation for the SAMM Aspect Meta Model, or SAMM.
726
Each Meta Model element and each Characteristic class is represented by an interface with a corresponding
827
implementation.
928

10-
## Usage
29+
## Set Up SAMM Aspect Meta Model
1130

12-
An Aspect of the Meta Model can be created as follows using the provided `AspectInstantiator`.
31+
Before getting started to use the `esmf-aspect-model-loader` library you need to apply some set up actions:
1332

14-
```
15-
aspect_loader = AspectLoader()
16-
aspect = aspect_loader.load_aspect_model("absolute/path/to/turtle.ttl");
33+
Required
34+
- [Install poetry](#install-poetry)
35+
- [Install project dependencies](#install-project-dependencies)
36+
- [Download SAMM files](#download-samm-files)
37+
Optional
38+
- [Download SAMM CLI](#download-samm-cli) (needed to use SAMM CLI functions)
39+
- [Download SAMM test models](#download-test-models) (for running integration tests)
40+
41+
### Install poetry
42+
43+
`Poetry` used as a dependency management for the `esmf-aspect-model-loader`. Follow the next [instruction](https://python-poetry.org/docs/#installation)
44+
to install it.
45+
46+
To check the poetry version run:
47+
```console
48+
poetry --version
1749
```
1850

19-
or
51+
### Install project dependencies
2052

53+
Poetry provides convenient functionality for working with dependencies in the project.
54+
To automatically download and install all the necessary libraries, just run one command:
55+
```console
56+
poetry install
2157
```
22-
aspect_loader = AspectLoader()
23-
aspect = aspect_loader.load_aspect_model_from_multiple_files(["list/of/absolute/paths/to/turtles.ttl"], "aspect_urn");
58+
It is required to run `poetry install` once in the esmf-aspect-model-loader module.
59+
60+
### Download SAMM files
61+
62+
There are two possibilities to download the SAMM files and extract the Turtle sources for the Meta Model:
63+
SAMM release or SAMM branch
64+
65+
#### Download SAMM release
66+
67+
This script downloads a release JAR-file from GitHub, extracts them for further usage in the Aspect Model Loader:
68+
69+
To run script, execute the next command.
70+
```console
71+
poetry run download-samm-release
2472
```
73+
The version of the SAMM release is specified in the python script.
74+
75+
Link to all Releases: [SAMM Releases](https://github.com/eclipse-esmf/esmf-semantic-aspect-meta-model/releases)
2576

26-
## Automatic Deployment
77+
#### Download SAMM branch
2778

28-
A [GitHub action called 'Release'](https://github.com/eclipse-esmf/esmf-sdk-py-aspect-model-loader/actions/workflows/tagged_release.yml)
29-
has been set up for the `esmf-aspect-model-loader`. This action checks the code quality by running tests, the [static type checker MyPy](https://github.com/python/mypy) and
30-
the [code formatter 'Black'](https://github.com/psf/black).
79+
The script uses the GitHub API and downloads the files from the `main` GitHub branch.
3180

32-
## Set Up SAMM Aspect Meta Model for development
81+
If the script is run in a pipeline, it uses a GitHub token to authorize. If the script is run locally,
82+
the API is called without a token. This may cause problems because unauthorized API calls are limited.
3383

34-
In order to download the SAMM sources, it is required to run `poetry install` once in the `esmf-aspect-model-loader`
35-
module. There are two possibilities to download the SAMM files and extract the Turtle sources for the Meta Model.
84+
Run the next command to download and start working with the Aspect Model Loader.
85+
```console
86+
poetry run download-samm-branch
87+
```
88+
Link to all branches: [SAMM Releases](https://github.com/eclipse-esmf/esmf-semantic-aspect-meta-model/branches)
3689

37-
### Possibility 1 (downloading a release)
90+
## Aspect Meta Model Loader usage
3891

39-
The `download_samm_release` script may be executed with
92+
An Aspect of the Meta Model can be loaded as follows:
93+
```python
94+
from esmf_aspect_meta_model_python import AspectLoader
4095

96+
loader = AspectLoader()
97+
model_elements = loader.load_aspect_model("absolute/path/to/turtle.ttl")
98+
aspect = model_elements[0]
99+
100+
# or you can provide an Aspect URN
101+
102+
loader = AspectLoader()
103+
aspect_urn = "urn:samm:org.eclipse.esmf.samm:aspect.model:0.0.1#AspectName"
104+
model_elements = loader.load_aspect_model("absolute/path/to/turtle.ttl", aspect_urn)
105+
aspect = model_elements[0]
41106
```
42-
poetry run download-samm-release
43-
```
44107

45-
It downloads a release JAR-file from GitHub and extracts the SAMM Files.
46-
The version is specified in the python script.
108+
## Samm Units
109+
110+
SAMMUnitsGraph is a class contains functions for accessing units of measurement.
111+
```python
112+
from esmf_aspect_meta_model_python.samm_meta_model import SammUnitsGraph
47113

48-
Link to all Releases: https://github.com/eclipse-esmf/esmf-semantic-aspect-meta-model/releases
114+
units_graph = SammUnitsGraph()
115+
unit_data = units_graph.get_info("unit:volt")
116+
# {'preferredName': rdflib.term.Literal('volt', lang='en'), 'commonCode': rdflib.term.Literal('VLT'), ... }
49117

50-
### Possibility 2 (downloading from the repository)
118+
units_graph.print_description(unit_data)
119+
# preferredName: volt
120+
# commonCode: VLT
121+
# ...
122+
# symbol: V
123+
```
124+
125+
## SAMM CLI wrapper class
126+
127+
The SAMM CLI is a command line tool provided number of functions for working with Aspect Models.
51128

52-
It may happen that there is no .jar file that is up to date with the changes of the SAMM.
53-
This script is an alternative to the `download_samm_release.py` and extracts the files from the repository
54-
directly instead of using the newest release.
129+
More detailed information about SAMM CLI functionality can be found in the
130+
[SAMM CLI documentation](https://eclipse-esmf.github.io/esmf-developer-guide/tooling-guide/samm-cli.html).
55131

56-
The script uses the GitHub API and downloads the files from the `main` branch. If the script is run in a
57-
pipeline, it uses a GitHub token to authorize. If the script is run locally, the API is called without a token.
58-
This may cause problems because unauthorized API calls are limited.
132+
Python Aspect Model Loader provide a wrapper class to be able to call SAMM CLI functions from the Python code.
133+
For instance, validation of a model can be done with the following code snippet:
59134

60-
This script can be executed with
135+
```python
136+
from esmf_aspect_meta_model_python.samm_cli_functions import SammCli
61137

138+
samm_cli = SammCli()
139+
model_path = "Paht_to_the_model/Model.ttl"
140+
samm_cli.validate(model_path)
141+
# Input model is valid
62142
```
63-
poetry run download-samm-branch
143+
144+
List of SAMMCLI functions:
145+
- validate
146+
- to_openapi
147+
- to_schema
148+
- to_json
149+
- to_html
150+
- to_png
151+
- to_svg
152+
153+
# Scripts
154+
155+
The Aspect Model Loader provide scripts for downloading some additional code and data.
156+
Provided scripts:
157+
- download-samm-release
158+
- download-samm-branch
159+
- download-samm-cli
160+
- download-test-models
161+
162+
All scripts run like a poetry command. The poetry is available from the folder where [pyproject.toml](pyproject.toml)
163+
is located.
164+
165+
# Automation Tasks
166+
## tox
167+
168+
`tox` is used for the tests automation purpose. There are two environments with different purposes and tests can
169+
be running with the tox:
170+
- pep8: static code checks (PEP8 style) with MyPy and Black
171+
- py310: unit and integration tests
172+
173+
```console
174+
# run all checks use the next command
175+
poetry run tox
176+
177+
# run only pep8 checks
178+
poetry run tox -e pep8
179+
180+
# run tests
181+
poetry run tox -e py310
64182
```
65-
to download and start working with the Aspect Model Loader.
183+
184+
## GitHub actions
185+
186+
There are two actions on the GitHub repo:
187+
- [Check New Pull Request](../../.github/workflows/push_request_check.yml)
188+
- [Build release](../../.github/workflows/tagged_release.yml)
189+
190+
### Check New Pull Request
191+
This action run after creation or updating a pull request and run all automation tests with tox command.
192+
193+
### Build release
194+
Prepare and publish a new release for the `esmf-aspect-model-loader` to the PyPi:
195+
[esmf-aspect-model-loader](https://pypi.org/project/esmf-aspect-model-loader/.)
196+
197+
A list of the available releases on the GitHub:
198+
[Releases](https://github.com/eclipse-esmf/esmf-sdk-py-aspect-model-loader/releases).

core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,4 @@
8686
DefaultUnit,
8787
)
8888
from .loader.aspect_loader import AspectLoader
89+
from .loader.samm_graph import SAMMGraph

0 commit comments

Comments
 (0)