Skip to content

Commit 42a4e19

Browse files
authored
Merge branch 'main' into add_compliance-tool
2 parents 103f14d + 4c07fe1 commit 42a4e19

36 files changed

+335
-220
lines changed

.github/workflows/ci.yml

Lines changed: 84 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,47 @@ name: ci
33
on: [push, pull_request]
44

55
env:
6-
X_PYTHON_VERSION: "3.12"
6+
X_PYTHON_MIN_VERSION: "3.9"
7+
X_PYTHON_MAX_VERSION: "3.12"
78

89
jobs:
10+
check-python-versions:
11+
# This job checks that the Python Versions we support match and are not End of Life
12+
runs-on: ubuntu-latest
13+
defaults:
14+
run:
15+
working-directory: ./etc/scripts
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Set up Python ${{ env.X_PYTHON_MIN_VERSION }}
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: ${{ env.X_PYTHON_MIN_VERSION }}
22+
- name: Install Python dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install -r ./check_python_versions_requirements.txt
26+
- name: Check Supported Python Versions
27+
run: |
28+
python check_python_versions_supported.py \
29+
${{ env.X_PYTHON_MIN_VERSION }} \
30+
${{ env.X_PYTHON_MAX_VERSION }}
31+
32+
- name: Check Python Versions coincide with the SDKs pyproject.toml
33+
run: |
34+
python check_python_versions_coincide.py \
35+
../../sdk/pyproject.toml \
36+
${{ env.X_PYTHON_MIN_VERSION }} \
37+
${{ env.X_PYTHON_MAX_VERSION }}
38+
39+
# Todo: Check other pyproject.toml here as well, as we add them
40+
941
sdk-test:
1042
# This job runs the unittests on the python versions specified down at the matrix
1143
runs-on: ubuntu-latest
1244
strategy:
1345
matrix:
14-
python-version: ["3.8", "3.10", "3.12"]
46+
python-version: ["3.9", "3.12"]
1547
env:
1648
COUCHDB_ADMIN_PASSWORD: "yo0Quai3"
1749
# (2024-10-11, s-heppner)
@@ -32,9 +64,15 @@ jobs:
3264
run:
3365
working-directory: ./sdk
3466
steps:
35-
- uses: actions/checkout@v2
67+
- uses: actions/checkout@v4
68+
- name: Verify Matrix Version matches Global Version
69+
run: |
70+
if [ "${{ matrix.python-version }}" != "${{ env.X_PYTHON_MIN_VERSION }}" ] && [ "${{ matrix.python-version }}" != "${{ env.X_PYTHON_MAX_VERSION }}" ]; then
71+
echo "Error: Matrix version ${{ matrix.python-version }} does not match global version."
72+
exit 1
73+
fi
3674
- name: Set up Python ${{ matrix.python-version }}
37-
uses: actions/setup-python@v2
75+
uses: actions/setup-python@v4
3876
with:
3977
python-version: ${{ matrix.python-version }}
4078
- name: Collect schema files from aas-specs
@@ -64,11 +102,11 @@ jobs:
64102
run:
65103
working-directory: ./sdk
66104
steps:
67-
- uses: actions/checkout@v2
68-
- name: Set up Python ${{ env.X_PYTHON_VERSION }}
105+
- uses: actions/checkout@v4
106+
- name: Set up Python ${{ env.X_PYTHON_MIN_VERSION }}
69107
uses: actions/setup-python@v2
70108
with:
71-
python-version: ${{ env.X_PYTHON_VERSION }}
109+
python-version: ${{ env.X_PYTHON_MIN_VERSION }}
72110
- name: Install Python dependencies
73111
run: |
74112
python -m pip install --upgrade pip
@@ -87,11 +125,11 @@ jobs:
87125
run:
88126
working-directory: ./sdk
89127
steps:
90-
- uses: actions/checkout@v2
91-
- name: Set up Python ${{ env.X_PYTHON_VERSION }}
128+
- uses: actions/checkout@v4
129+
- name: Set up Python ${{ env.X_PYTHON_MIN_VERSION }}
92130
uses: actions/setup-python@v2
93131
with:
94-
python-version: ${{ env.X_PYTHON_VERSION }}
132+
python-version: ${{ env.X_PYTHON_MIN_VERSION }}
95133
- name: Install Python dependencies
96134
run: |
97135
python -m pip install --upgrade pip
@@ -113,11 +151,11 @@ jobs:
113151
run:
114152
working-directory: ./sdk
115153
steps:
116-
- uses: actions/checkout@v2
117-
- name: Set up Python ${{ env.X_PYTHON_VERSION }}
154+
- uses: actions/checkout@v4
155+
- name: Set up Python ${{ env.X_PYTHON_MIN_VERSION }}
118156
uses: actions/setup-python@v2
119157
with:
120-
python-version: ${{ env.X_PYTHON_VERSION }}
158+
python-version: ${{ env.X_PYTHON_MIN_VERSION }}
121159
- name: Install Python dependencies
122160
run: |
123161
python -m pip install --upgrade pip
@@ -134,11 +172,11 @@ jobs:
134172
run:
135173
working-directory: ./sdk
136174
steps:
137-
- uses: actions/checkout@v2
138-
- name: Set up Python ${{ env.X_PYTHON_VERSION }}
175+
- uses: actions/checkout@v4
176+
- name: Set up Python ${{ env.X_PYTHON_MIN_VERSION }}
139177
uses: actions/setup-python@v2
140178
with:
141-
python-version: ${{ env.X_PYTHON_VERSION }}
179+
python-version: ${{ env.X_PYTHON_MIN_VERSION }}
142180
- name: Install dependencies
143181
run: |
144182
python -m pip install --upgrade pip
@@ -147,6 +185,7 @@ jobs:
147185
run: |
148186
python -m build
149187
188+
150189
compliance-tool-test:
151190
# This job runs the unittests on the python versions specified down at the matrix
152191
runs-on: ubuntu-latest
@@ -249,3 +288,32 @@ jobs:
249288
- name: Create source and wheel dist
250289
run: |
251290
python setup.py sdist bdist_wheel
291+
292+
server-package:
293+
# This job checks if we can build our server package
294+
runs-on: ubuntu-latest
295+
defaults:
296+
run:
297+
working-directory: ./server
298+
steps:
299+
- uses: actions/checkout@v4
300+
- name: Build the Docker image
301+
run: |
302+
docker build -t basyx-python-server .
303+
- name: Run container
304+
run: |
305+
docker run -d --name basyx-python-server basyx-python-server
306+
- name: Wait for container and server initialization
307+
run: |
308+
timeout 30s bash -c '
309+
until docker logs basyx-python-server 2>&1 | grep -q "INFO success: quit_on_failure entered RUNNING state"; do
310+
sleep 2
311+
done
312+
'
313+
- name: Check if container is running
314+
run: |
315+
docker inspect --format='{{.State.Running}}' basyx-python-server | grep true
316+
- name: Stop and remove the container
317+
run: |
318+
docker stop basyx-python-server && docker rm basyx-python-server
319+

CONTRIBUTING.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ The following guidelines are for the commit or PR message text:
121121

122122
## Codestyle and Testing
123123

124-
Our code follows the [PEP 8 -- Style Guide for Python Code](https://www.python.org/dev/peps/pep-0008/).
124+
Our code follows the [PEP 8 -- Style Guide for Python Code](https://www.python.org/dev/peps/pep-0008/)
125+
with the following exceptions:
126+
- Line length is allowed to be up to 120 characters, though lines up to 100 characters are preferred.
127+
125128
Additionally, we use [PEP 484 -- Type Hints](https://www.python.org/dev/peps/pep-0484/) throughout the code to enable type checking the code.
126129

127130
Before submitting any changes, make sure to let `mypy` and `pycodestyle` check your code and run the unit tests with
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"""
2+
This helper script checks if the Python versions defined in a `pyproject.toml` coincide with the given `min_version`
3+
and `max_version` and returns an error if they don't.
4+
"""
5+
import re
6+
import argparse
7+
import sys
8+
from packaging.version import Version, InvalidVersion
9+
10+
def main(pyproject_toml_path: str, min_version: str, max_version: str) -> None:
11+
# Load and check `requires-python` version from `pyproject.toml`
12+
try:
13+
with open(pyproject_toml_path, "r") as f:
14+
pyproject_content = f.read()
15+
16+
match = re.search(r'requires-python\s*=\s*">=([\d.]+)"', pyproject_content)
17+
if not match:
18+
print(f"Error: `requires-python` field not found or invalid format in `{pyproject_toml_path}`")
19+
sys.exit(1)
20+
21+
pyproject_version = match.group(1)
22+
if Version(pyproject_version) < Version(min_version):
23+
print(f"Error: Python version in `{pyproject_toml_path}` `requires-python` ({pyproject_version}) "
24+
f"is smaller than `min_version` ({min_version}).")
25+
sys.exit(1)
26+
27+
except FileNotFoundError:
28+
print(f"Error: File not found: `{pyproject_toml_path}`.")
29+
sys.exit(1)
30+
31+
print(f"Success: Version in pyproject.toml `requires-python` (>={pyproject_version}) "
32+
f"matches expected versions ([{min_version} to {max_version}]).")
33+
34+
35+
if __name__ == "__main__":
36+
parser = argparse.ArgumentParser(description="Check Python version support and alignment with pyproject.toml.")
37+
parser.add_argument("pyproject_toml_path", help="Path to the `pyproject.toml` file to check.")
38+
parser.add_argument("min_version", help="The minimum Python version.")
39+
parser.add_argument("max_version", help="The maximum Python version.")
40+
args = parser.parse_args()
41+
42+
try:
43+
main(args.pyproject_toml_path, args.min_version, args.max_version)
44+
except InvalidVersion:
45+
print("Error: Invalid version format provided.")
46+
sys.exit(1)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
requests>=2.23
2+
packaging>=24.2
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"""
2+
This helper script checks that the provided `min_version` and `max_version` are supported and released, respectively,
3+
using the API from the great https://github.com/endoflife-date/endoflife.date project.
4+
"""
5+
import argparse
6+
import sys
7+
import requests
8+
from packaging.version import InvalidVersion
9+
from datetime import datetime
10+
11+
def main(min_version: str, max_version: str) -> None:
12+
# Fetch supported Python versions and check min/max versions
13+
try:
14+
response = requests.get("https://endoflife.date/api/python.json")
15+
response.raise_for_status()
16+
eol_data = response.json()
17+
eol_versions = {entry["cycle"]: {"eol": entry["eol"], "releaseDate": entry["releaseDate"]} for entry in eol_data}
18+
19+
# Get current date to compare with EoL and release dates
20+
current_date = datetime.now().date()
21+
22+
# Check min_version EoL status
23+
min_eol_date = eol_versions.get(min_version, {}).get("eol")
24+
if min_eol_date and datetime.strptime(min_eol_date, "%Y-%m-%d").date() <= current_date:
25+
print(f"Error: min_version {min_version} has reached End-of-Life.")
26+
sys.exit(1)
27+
28+
# Check max_version EoL and release status
29+
max_info = eol_versions.get(max_version)
30+
if max_info:
31+
max_eol_date = max_info["eol"]
32+
max_release_date = max_info["releaseDate"]
33+
34+
# Check if max_version has a release date in the future
35+
if max_release_date and datetime.strptime(max_release_date, "%Y-%m-%d").date() > current_date:
36+
print(f"Error: max_version {max_version} has not been officially released yet.")
37+
sys.exit(1)
38+
39+
# Check if max_version has reached EoL
40+
if max_eol_date and datetime.strptime(max_eol_date, "%Y-%m-%d").date() <= current_date:
41+
print(f"Error: max_version {max_version} has reached End-of-Life.")
42+
sys.exit(1)
43+
44+
except requests.RequestException:
45+
print("Error: Failed to fetch Python version support data.")
46+
sys.exit(1)
47+
48+
print(f"Version check passed: min_version [{min_version}] is supported "
49+
f"and max_version [{max_version}] is released.")
50+
51+
if __name__ == "__main__":
52+
parser = argparse.ArgumentParser(description="Check Python version support and alignment with pyproject.toml.")
53+
parser.add_argument("min_version", help="The minimum Python version.")
54+
parser.add_argument("max_version", help="The maximum Python version.")
55+
args = parser.parse_args()
56+
57+
try:
58+
main(args.min_version, args.max_version)
59+
except InvalidVersion:
60+
print("Error: Invalid version format provided.")
61+
sys.exit(1)

sdk/basyx/aas/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
The package consists of the python implementation of the AssetAdministrationShell, as defined in the
33
'Details of the Asset Administration Shell' specification of Plattform Industrie 4.0.
44
5-
The subpackage 'model' is an implementation of the meta-model of the AAS,
5+
The subpackage 'model' is an implementation of the metamodel of the AAS,
66
in 'adapter', you can find JSON and XML adapters to translate between BaSyx Python SDK objects and JSON/XML schemas;
7-
and in 'util', some helpful functionality to actually use the AAS meta-model you created with 'model' is located.
7+
and in 'util', some helpful functionality to actually use the AAS metamodel you created with 'model' is located.
88
"""
99

1010
__version__ = "1.0.0"

0 commit comments

Comments
 (0)