Skip to content

Commit f831016

Browse files
authored
Merge pull request #424 from eclipse-basyx/develop
Prepare Release v2.0.0 # Release Notes Version 2.0.0 of the BaSyx-Python SDK comes with a major refactoring of the server and a renewed concept for data persistence. Previously, the server code was split between the `sdk` and `server` packages (due to historic development of the code). Now all the code relevant just for the server is located in `server`, where it belongs. Since this means, some code that was previously in `sdk` is not there anymore, this is a breaking change and warranted the new major release. > [!note] > This release does not have any changes in implemented AAS specification versions. It is the preparotory release in order to get ready for the new versions of the specifications, as well as new features for the SDK, such as Registry and Discovery server. > [!warning] > Due to these major refactorings, there were some backward incompatible changes. Please check the documentation, if you encounter any issues. # Changelog **Notable:** - Backward Incompatible: Refactor server functionality from `sdk` to `server` (See: #388) - Backward Incompatible: Refactor `backend` concept for data persistence (See: #370) - Backward Incompatible: Refactor server `start-up` options (See: #418) - Remove support for Python 3.9 (as it is EoL) (See #433) **Improvements:** - Clarify documentation of running the server with Docker (See: #398) - Document running the server without Docker (See: #403) - Improve XML serialization (See: #406) - Improve server reading of JSON and XML files (See: #408) - Add more utility methods for `Referable` and `Key` handling (See: #410) **Bugfixes:** - Fix type issues found with a new version of `mypy` (See: #399) - Fix parsing of `ConceptDescription`s in the server (See: #420) - Update `pyecma376-2` and `lxml` dependencies (See: #419)
2 parents 2455821 + dcc8d2c commit f831016

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1584
-1709
lines changed

.github/workflows/ci.yml

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

55
env:
6-
X_PYTHON_MIN_VERSION: "3.9"
6+
X_PYTHON_MIN_VERSION: "3.10"
77
X_PYTHON_MAX_VERSION: "3.12"
88

99
jobs:
@@ -45,7 +45,7 @@ jobs:
4545
runs-on: ubuntu-latest
4646
strategy:
4747
matrix:
48-
python-version: ["3.9", "3.12"]
48+
python-version: ["3.10", "3.12"]
4949
env:
5050
COUCHDB_ADMIN_PASSWORD: "yo0Quai3"
5151
# (2024-10-11, s-heppner)
@@ -154,15 +154,14 @@ jobs:
154154
working-directory: ./sdk
155155
steps:
156156
- uses: actions/checkout@v4
157-
- name: Set up Python ${{ env.X_PYTHON_MIN_VERSION }}
157+
- name: Set up Python ${{ env.X_PYTHON_MAX_VERSION }}
158158
uses: actions/setup-python@v5
159159
with:
160-
python-version: ${{ env.X_PYTHON_MIN_VERSION }}
160+
python-version: ${{ env.X_PYTHON_MAX_VERSION }}
161161
- name: Install Python dependencies
162162
run: |
163163
python -m pip install --upgrade pip
164-
pip install .
165-
pip install -r docs/add-requirements.txt
164+
pip install .[docs]
166165
- name: Check documentation for errors
167166
run: |
168167
SPHINXOPTS="-a -E -n -W --keep-going" make -C docs html
@@ -209,7 +208,7 @@ jobs:
209208
runs-on: ubuntu-latest
210209
strategy:
211210
matrix:
212-
python-version: ["3.9", "3.12"]
211+
python-version: ["3.10", "3.12"]
213212
defaults:
214213
run:
215214
working-directory: ./compliance_tool
@@ -255,13 +254,13 @@ jobs:
255254
pip install .[dev]
256255
- name: Check typing with MyPy
257256
run: |
258-
mypy ./aas_compliance_tool test
257+
mypy aas_compliance_tool test
259258
- name: Check code style with PyCodestyle
260259
run: |
261-
pycodestyle --count --max-line-length 120 ./aas_compliance_tool test
260+
pycodestyle --count --max-line-length 120 aas_compliance_tool test
262261
263-
compliance-tool-readme-codeblocks:
264-
# This job runs the same static code analysis (mypy and pycodestyle) on the codeblocks in our docstrings.
262+
compliance-tool-package:
263+
# This job checks if we can build our compliance_tool package
265264
runs-on: ubuntu-latest
266265

267266
defaults:
@@ -273,42 +272,43 @@ jobs:
273272
uses: actions/setup-python@v5
274273
with:
275274
python-version: ${{ env.X_PYTHON_MIN_VERSION }}
276-
- name: Install Python dependencies
277-
# install the local sdk in editable mode so it does not get overwritten
275+
- name: Install dependencies
278276
run: |
279277
python -m pip install --upgrade pip
280-
pip install -e ../sdk[dev]
281-
pip install .[dev]
282-
- name: Check typing with MyPy
283-
run: |
284-
mypy <(codeblocks python README.md)
285-
- name: Check code style with PyCodestyle
286-
run: |
287-
codeblocks --wrap python README.md | pycodestyle --count --max-line-length 120 -
288-
- name: Run readme codeblocks with Python
278+
pip install build
279+
- name: Create source and wheel dist
289280
run: |
290-
codeblocks python README.md | python
281+
python -m build
291282
292-
compliance-tool-package:
293-
# This job checks if we can build our compliance_tool package
283+
#server-test:
284+
# TODO: This job runs the unittests on the python versions specified down at the matrix
285+
# and aas-test-engines on the server
286+
287+
288+
server-static-analysis:
289+
# This job runs static code analysis, namely pycodestyle and mypy
294290
runs-on: ubuntu-latest
295291

296292
defaults:
297293
run:
298-
working-directory: ./compliance_tool
294+
working-directory: ./server/app
299295
steps:
300296
- uses: actions/checkout@v4
301297
- name: Set up Python ${{ env.X_PYTHON_MIN_VERSION }}
302298
uses: actions/setup-python@v5
303299
with:
304300
python-version: ${{ env.X_PYTHON_MIN_VERSION }}
305-
- name: Install dependencies
301+
- name: Install Python dependencies
306302
run: |
307303
python -m pip install --upgrade pip
308-
pip install build
309-
- name: Create source and wheel dist
304+
pip install ../../sdk
305+
pip install .[dev]
306+
- name: Check typing with MyPy
310307
run: |
311-
python -m build
308+
mypy .
309+
- name: Check code style with PyCodestyle
310+
run: |
311+
pycodestyle --count --max-line-length 120 .
312312
313313
server-package:
314314
# This job checks if we can build our server package

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@ htmlcov/
2121
docs/build/
2222
.hypothesis/
2323

24-
# customized config files
24+
# Customized config files
2525
sdk/test/test_config.ini
2626
# Schema files needed for testing
2727
sdk/test/adapter/schemas
2828

2929
# Ignore dynamically generated version file
3030
sdk/basyx/version.py
3131
compliance_tool/aas_compliance_tool/version.py
32+
server/app/version.py
3233

33-
# ignore the content of the server storage
34+
# Ignore the content of the server storage
35+
server/input/
3436
server/storage/

compliance_tool/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ classifiers = [
3434
"Operating System :: OS Independent",
3535
"Development Status :: 5 - Production/Stable"
3636
]
37-
requires-python = ">=3.9"
37+
requires-python = ">=3.10"
3838
dependencies = [
3939
"pyecma376-2>=0.2.4",
4040
"jsonschema>=4.21.1",

sdk/.readthedocs.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ version: 2
66
build:
77
os: ubuntu-20.04
88
tools:
9-
python: "3.9"
9+
python: "3.10"
1010

1111
sphinx:
1212
configuration: docs/source/conf.py
@@ -15,4 +15,5 @@ python:
1515
install:
1616
- method: pip
1717
path: .
18-
- requirements: docs/add-requirements.txt
18+
extra_requirements:
19+
- docs

sdk/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ The BaSyx Python SDK requires the following Python packages to be installed for
4242
* `lxml` (BSD 3-clause License, using `libxml2` under MIT License)
4343
* `python-dateutil` (BSD 3-clause License)
4444
* `pyecma376-2` (Apache License v2.0)
45-
* `urllib3` (MIT License)
46-
* `Werkzeug` (BSD 3-clause License)
45+
4746

4847
Development/testing/documentation/example dependencies:
4948
* `mypy` (MIT License)
@@ -128,7 +127,7 @@ For further examples and tutorials, check out the `basyx.aas.examples`-package.
128127
* [`tutorial_storage`](./basyx/aas/examples/tutorial_storage.py): Manage a larger number of Asset Administration Shells in an ObjectStore and resolve references
129128
* [`tutorial_serialization_deserialization`](./basyx/aas/examples/tutorial_serialization_deserialization.py): Use the JSON and XML serialization/deserialization for single objects or full standard-compliant files
130129
* [`tutorial_aasx`](./basyx/aas/examples/tutorial_aasx.py): Export Asset Administration Shells with related objects and auxiliary files to AASX package files
131-
* [`tutorial_backend_couchdb`](./basyx/aas/examples/tutorial_backend_couchdb.py): Use the *Backends* interface (`update()/commit()` methods) to manage and retrieve AAS objects in a CouchDB document database
130+
* [`tutorial_backend_couchdb`](./basyx/aas/examples/tutorial_backend_couchdb.py): Use the *CouchDBObjectStore* to manage and retrieve AAS objects in a CouchDB document database
132131

133132

134133
### Documentation

sdk/basyx/aas/adapter/__init__.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,45 @@
77
Python SDK objects to/from XML.
88
* :ref:`aasx <adapter.aasx>`: This package offers functions for reading and writing AASX-files.
99
"""
10+
11+
from basyx.aas.adapter.aasx import AASXReader, DictSupplementaryFileContainer
12+
from basyx.aas.adapter.json import read_aas_json_file_into
13+
from basyx.aas.adapter.xml import read_aas_xml_file_into
14+
from basyx.aas.model.provider import DictObjectStore
15+
from pathlib import Path
16+
from typing import Union
17+
18+
19+
def load_directory(directory: Union[Path, str]) -> tuple[DictObjectStore, DictSupplementaryFileContainer]:
20+
"""
21+
Create a new :class:`~basyx.aas.model.provider.DictObjectStore` and use it to load Asset Administration Shell and
22+
Submodel files in ``AASX``, ``JSON`` and ``XML`` format from a given directory into memory. Additionally, load all
23+
embedded supplementary files into a new :class:`~basyx.aas.adapter.aasx.DictSupplementaryFileContainer`.
24+
25+
:param directory: :class:`~pathlib.Path` or ``str`` pointing to the directory containing all Asset Administration
26+
Shell and Submodel files to load
27+
:return: Tuple consisting of a :class:`~basyx.aas.model.provider.DictObjectStore` and a
28+
:class:`~basyx.aas.adapter.aasx.DictSupplementaryFileContainer` containing all loaded data
29+
"""
30+
31+
dict_object_store: DictObjectStore = DictObjectStore()
32+
file_container: DictSupplementaryFileContainer = DictSupplementaryFileContainer()
33+
34+
directory = Path(directory)
35+
36+
for file in directory.iterdir():
37+
if not file.is_file():
38+
continue
39+
40+
suffix = file.suffix.lower()
41+
if suffix == ".json":
42+
with open(file) as f:
43+
read_aas_json_file_into(dict_object_store, f)
44+
elif suffix == ".xml":
45+
with open(file) as f:
46+
read_aas_xml_file_into(dict_object_store, f)
47+
elif suffix == ".aasx":
48+
with AASXReader(file) as reader:
49+
reader.read_into(object_store=dict_object_store, file_store=file_container)
50+
51+
return dict_object_store, file_container

sdk/basyx/aas/adapter/_generic.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
PathOrBinaryIO = Union[Path, BinaryIO]
2020
PathOrIO = Union[Path, IO] # IO is TextIO or BinaryIO
2121

22+
# JSON top-level keys and their corresponding model classes
23+
JSON_AAS_TOP_LEVEL_KEYS_TO_TYPES = (
24+
('assetAdministrationShells', model.AssetAdministrationShell),
25+
('submodels', model.Submodel),
26+
('conceptDescriptions', model.ConceptDescription),
27+
)
28+
2229
# XML Namespace definition
2330
XML_NS_MAP = {"aas": "https://admin-shell.io/aas/3/0"}
2431
XML_NS_AAS = "{" + XML_NS_MAP["aas"] + "}"

0 commit comments

Comments
 (0)