Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 57 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
run:
working-directory: ./etc/scripts
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ env.X_PYTHON_MIN_VERSION }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ env.X_PYTHON_MIN_VERSION }}
- name: Install Python dependencies
Expand All @@ -29,12 +29,14 @@ jobs:
${{ env.X_PYTHON_MIN_VERSION }} \
${{ env.X_PYTHON_MAX_VERSION }}

- name: Check Python Versions coincide with the SDKs pyproject.toml
- name: Check Python Versions coincide with all pyproject.toml Files
run: |
python check_python_versions_coincide.py \
../../sdk/pyproject.toml \
${{ env.X_PYTHON_MIN_VERSION }} \
${{ env.X_PYTHON_MAX_VERSION }}
for file in ../../sdk/pyproject.toml ../../compliance_tool/pyproject.toml; do
python check_python_versions_coincide.py \
$file \
${{ env.X_PYTHON_MIN_VERSION }} \
${{ env.X_PYTHON_MAX_VERSION }}
done

# Todo: Check other pyproject.toml here as well, as we add them

Expand Down Expand Up @@ -72,7 +74,7 @@ jobs:
exit 1
fi
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Collect schema files from aas-specs
Expand Down Expand Up @@ -104,7 +106,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ env.X_PYTHON_MIN_VERSION }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ env.X_PYTHON_MIN_VERSION }}
- name: Install Python dependencies
Expand All @@ -127,7 +129,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ env.X_PYTHON_MIN_VERSION }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ env.X_PYTHON_MIN_VERSION }}
- name: Install Python dependencies
Expand All @@ -153,7 +155,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ env.X_PYTHON_MIN_VERSION }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ env.X_PYTHON_MIN_VERSION }}
- name: Install Python dependencies
Expand All @@ -174,7 +176,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ env.X_PYTHON_MIN_VERSION }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ env.X_PYTHON_MIN_VERSION }}
- name: Install dependencies
Expand All @@ -185,28 +187,45 @@ jobs:
run: |
python -m build

repository-check-copyright:
# This job checks that the copyright year in the header of all files is up to date
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensure full history is available
- name: Install required dependencies
run: |
sudo apt-get update
sudo apt-get install -y bash git
- name: Run copyright check
run: |
chmod +x ./etc/scripts/set_copyright_year.sh
./etc/scripts/set_copyright_year.sh --check


compliance-tool-test:
# This job runs the unittests on the python versions specified down at the matrix
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.10", "3.12"]
python-version: ["3.9", "3.12"]
defaults:
run:
working-directory: ./compliance_tool

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
# install the local sdk in editable mode so it does not get overwritten
run: |
python -m pip install --upgrade pip
pip install coverage
pip install -r requirements.txt
pip install -e ../sdk[dev]
pip install .[dev]
- name: Test with coverage + unittest
run: |
coverage run --source=aas_compliance_tool -m unittest
Expand All @@ -223,16 +242,17 @@ jobs:
run:
working-directory: ./compliance_tool
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ env.X_PYTHON_VERSION }}
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ env.X_PYTHON_MIN_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.X_PYTHON_VERSION }}
python-version: ${{ env.X_PYTHON_MIN_VERSION }}
- name: Install Python dependencies
# install the local sdk in editable mode so it does not get overwritten
run: |
python -m pip install --upgrade pip
pip install pycodestyle mypy
pip install -r requirements.txt
pip install -e ../sdk[dev]
pip install .[dev]
- name: Check typing with MyPy
run: |
mypy ./aas_compliance_tool test
Expand All @@ -248,16 +268,17 @@ jobs:
run:
working-directory: ./compliance_tool
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ env.X_PYTHON_VERSION }}
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ env.X_PYTHON_MIN_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.X_PYTHON_VERSION }}
python-version: ${{ env.X_PYTHON_MIN_VERSION }}
- name: Install Python dependencies
# install the local sdk in editable mode so it does not get overwritten
run: |
python -m pip install --upgrade pip
pip install pycodestyle mypy codeblocks
pip install -r requirements.txt
pip install -e ../sdk[dev]
pip install .[dev]
- name: Check typing with MyPy
run: |
mypy <(codeblocks python README.md)
Expand All @@ -276,18 +297,18 @@ jobs:
run:
working-directory: ./compliance_tool
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ env.X_PYTHON_VERSION }}
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ env.X_PYTHON_MIN_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.X_PYTHON_VERSION }}
python-version: ${{ env.X_PYTHON_MIN_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
pip install build
- name: Create source and wheel dist
run: |
python setup.py sdist bdist_wheel
python -m build

server-package:
# This job checks if we can build our server package
Expand All @@ -299,7 +320,7 @@ jobs:
- uses: actions/checkout@v4
- name: Build the Docker image
run: |
docker build -t basyx-python-server .
docker build -t basyx-python-server -f Dockerfile ..
- name: Run container
run: |
docker run -d --name basyx-python-server basyx-python-server
Expand Down
35 changes: 31 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ on:
types: [published]

jobs:
publish:
# This job publishes the package to PyPI
sdk-publish:
# This job publishes the SDK package to PyPI
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./sdk
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
Expand All @@ -31,3 +31,30 @@ jobs:
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_ORG_TOKEN }}

compliance-tool-publish:
# This job publishes the compliance_tool package to PyPI
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./compliance_tool
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Create source and wheel dist
# (2024-12-11, s-heppner)
# The PyPI Action expects the dist files in a toplevel `/dist` directory,
# so we have to specify this as output directory here.
run: |
python -m build --outdir ../dist
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_ORG_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ sdk/test/adapter/schemas

# Ignore dynamically generated version file
sdk/basyx/version.py
compliance_tool/aas_compliance_tool/version.py

# ignore the content of the server storage
server/storage/
File renamed without changes.
76 changes: 70 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ the further steps via the comments.
In order to effectively communicate, there are some conventions to respect when writing
commit messages and pull requests.

Similarily to when creating an issue, the commit title, as well as the PR title should
Similarly to when creating an issue, the commit title, as well as the PR title should
be as short as possible, ideally 72 characters or fewer using imperative language.
If a specific module is affected, please mention it at the beginning of the title.

Expand All @@ -119,16 +119,41 @@ The following guidelines are for the commit or PR message text:
via `https://link/to.pdf#Page=123`
- Optionally, where applicable reference respective issues: `Fixes #123`

## Codestyle and Testing
## Code Quality

The Eclipse BaSyx Python project emphasizes high code quality.
To achieve this, we apply best practices where possible and have developed an extensive suite of tests that are
expected to pass for each Pull Request to the project.

### Codestyle
Our code follows the [PEP 8 -- Style Guide for Python Code](https://www.python.org/dev/peps/pep-0008/)
with the following exceptions:
- Line length is allowed to be up to 120 characters, though lines up to 100 characters are preferred.

Additionally, we use [PEP 484 -- Type Hints](https://www.python.org/dev/peps/pep-0484/) throughout the code to enable type checking the code.

Before submitting any changes, make sure to let `mypy` and `pycodestyle` check your code and run the unit tests with
Python's builtin `unittest`. To install the required tools, use:
Before submitting any changes to the SDK, make sure to let `mypy` and `pycodestyle` check your code and run the unit
tests with Python's builtin `unittest`.

### Testing
There are many automated checks implemented in the CI pipelines of this project, all of which are expected to pass
before new code can be added:

- We check that the Python packages can be built.
- We run the developed unittests and aim for a code coverage of at least 80%.
- We perform static code analysis for type-checking and codestyle, not just in the code itself, but also in codeblocks
that are inside docstrings and the `README.md`.
- We check that the automatically generated developer documentation compiles.
- We check that the Python Versions we support match between the different subprojects in the monorepository and are
not End of Life.
- We check that the year in the copyright headers in each file (stemming from the license) is correct.

> [!note]
> We strongly suggest to run the tests locally, before submitting a Pull Request, in order to accelerate the review
> process.

### Testing the SDK
For testing the SDK locally on your machine, you can install the required tools like so:
```bash
pip install .[dev]
```
Expand All @@ -142,12 +167,51 @@ Running all checks:
mypy basyx test
pycodestyle --max-line-length 120 basyx test
python -m unittest
coverage run --source basyx --branch -m unittest
coverage report -m
```

We aim to cover our code with test by at least 80%. To check test coverage, you can use `coverage`:
We aim to cover our code with tests by at least 80%.

This should help you sort out the most important bugs in your code.
Note that there are more checks that run in the CI once you open a Pull Request.
If you want to run the additional checks, please refer to the [CI definition](./.github/workflows/ci.yml).

### Testing the Server
Currently, the automated server tests are still under development.
To test that the server is working, we expect to at least be able to build the docker images and run a container
of it without error.

For that, you need to have Docker installed on your system.
In the directory with the `Dockerfile`:
```bash
pip install coverage
docker build -t basyx-python-server .
docker run --name basyx-python-server basyx-python-server
```
Wait until you see the line:
```
INFO success: quit_on_failure entered RUNNING state
```

### Testing the Compliance Tool
For the Compliance Tool, you can install the required tools like this (from the `./compliance_tool` directory):
```bash
pip install -e ../sdk[dev]
pip install .[dev]
```
The first line installs the SDK and its dependencies, the second the developer dependencies for the compliance tool
itself.

Then you can run the checks via:
```bash
mypy basyx test
pycodestyle --max-line-length 120 basyx test
python -m unittest
coverage run --source basyx --branch -m unittest
coverage report -m
```

We aim to cover our code with tests by at least 80%.
This should help you sort out the most important bugs in your code.
Note that there are more checks that run in the CI once you open a Pull Request.
If you want to run the additional checks, please refer to the [CI definition](./.github/workflows/ci.yml).
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ These are the currently implemented specifications:

| Specification | Version |
|---------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Part 1: Metamodel | [v3.0.1 (01001-3-1)](https://industrialdigitaltwin.org/wp-content/uploads/2024/06/IDTA-01001-3-0-1_SpecificationAssetAdministrationShell_Part1_Metamodel.pdf) |
| Part 1: Metamodel | [v3.0.1 (01001-3-0-1)](https://industrialdigitaltwin.org/wp-content/uploads/2024/06/IDTA-01001-3-0-1_SpecificationAssetAdministrationShell_Part1_Metamodel.pdf) |
| Schemata (JSONSchema, XSD) | [v3.0.8 (IDTA-01001-3-0-1_schemasV3.0.8)](https://github.com/admin-shell-io/aas-specs/releases/tag/IDTA-01001-3-0-1_schemasV3.0.8) |
| Part 2: API | [v3.0 (01002-3-0)](https://industrialdigitaltwin.org/en/wp-content/uploads/sites/2/2023/06/IDTA-01002-3-0_SpecificationAssetAdministrationShell_Part2_API_.pdf) |
| Part 3a: Data Specification IEC 61360 | [v3.0 (01003-a-3-0)](https://industrialdigitaltwin.org/wp-content/uploads/2023/04/IDTA-01003-a-3-0_SpecificationAssetAdministrationShell_Part3a_DataSpecification_IEC61360.pdf) |
Expand Down
2 changes: 1 addition & 1 deletion compliance_tool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Following functionalities are supported:
* create an aasx file with xml or json files compliant to the official schema containing example Asset Administration
Shell elements
* check if a given xml or json file is compliant to the official schema
* check if a given xml, json or aasx file is readable even if it is not compliant to the offical schema
* check if a given xml, json or aasx file is readable even if it is not compliant to the official schema
* check if the data in a given xml, json or aasx file is the same as the example data
* check if two given xml, json or aasx files contain the same Asset Administration Shell elements in any order

Expand Down
Loading
Loading