Skip to main content

Generate implementations and schemas based on an AAS meta-model.

Project description

Continuous integration Test coverage PyPI - version PyPI - Python Version

Aas-core-codegen:

  • generates code for different programming environments and schemas

  • to handle asset administration shells

  • based on the meta-model in simplified Python.

Motivation

The meta-model is still at the stage where it changes frequently. However, we need SDKs in different languages (C#, C++, C, Java, Golang, Erlang etc.) as well as different schemas (JSON Schema, XSD, RDF etc.). Keeping up with the changes is hard, time-consuming and error-prone as each SDK and schema needs to be reviewed independently.

To make the whole development cycle of the meta-model, SDKs and schemas more maintainable, we wrote a code and schema generator. We write a meta-model in a subset of Python language, parse it and, based on this meta-model, generate the code for different languages and schemas.

Therefore we can easily scale to many languages and schemas.

Here is a diagram to illustrate the whole process:

https://raw.githubusercontent.com/aas-core-works/aas-core-codegen/main/diagram.svg

Installation

Single-File Release

Please download and unzip the latest release from the GitHub release page.

From PyPI

The tool is also available on PyPI.

Create a virtual environment:

python -m venv venv-aas-core-codegen

Activate it (in Windows):

venv-venv-aas-core-codegen\Scripts\activate

or in Linux and OS X:

source venv-aas-core-codegen/bin/activate

Install the tool in the virtual environment:

pip3 install aas-core-codegen

Usage

Write your meta-model somewhere as well as the code snippets for implementation specific classes and functions. For example, take our test meta-model for inspiration how to write the meta-model and the snippets.

Make sure you are within the virtual environment where you installed the generator. Alternatively, if you are using the binary release, make sure the release is on your path.

Call the generator with the appropriate target:

aas-core-codegen \
    --model_path path/to/meta_model.py \
    --snippets_dir path/to/snippets \
    --output_dir path/to/output \
    --target csharp

--help

usage: aas-core-codegen [-h] --model_path MODEL_PATH --snippets_dir
                        SNIPPETS_DIR --output_dir OUTPUT_DIR --target
                        {csharp,cpp,golang,java,jsonschema,python,typescript,rdf_shacl,xsd,jsonld_context,protobuf,python_protobuf,opcua}
                        [--cache_model] [--version]

Generate implementations and schemas based on an AAS meta-model.

options:
  -h, --help            show this help message and exit
  --model_path MODEL_PATH
                        path to the meta-model
  --snippets_dir SNIPPETS_DIR
                        path to the directory containing implementation-
                        specific code snippets
  --output_dir OUTPUT_DIR
                        path to the generated code
  --target {csharp,cpp,golang,java,jsonschema,python,typescript,rdf_shacl,xsd,jsonld_context,protobuf,python_protobuf,opcua}
                        target language or schema
  --cache_model         If set, cache the parsed meta-model in the temporary
                        directory of your OS. This makes the repeated runs
                        faster as the meta-model does not need to be reparsed.
  --version             show the current version and exit

Versioning

We are still not clear about how to version the generator. For the moment, we use a lax incremental versioning with 0.0 prefix (0.0.1, 0.0.2``) etc.

The changelog is available in CHANGELOG.rst.

Contributing

Feature requests or bug reports are always very, very welcome!

Please see quickly if the issue does not already exist in the issue section and, if not, create a new issue.

Contributions in code are also welcome! Please see CONTRIBUTING.rst for developing guidelines.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aas_core_codegen-0.0.19.tar.gz (667.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aas_core_codegen-0.0.19-py3-none-any.whl (802.5 kB view details)

Uploaded Python 3

File details

Details for the file aas_core_codegen-0.0.19.tar.gz.

File metadata

  • Download URL: aas_core_codegen-0.0.19.tar.gz
  • Upload date:
  • Size: 667.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for aas_core_codegen-0.0.19.tar.gz
Algorithm Hash digest
SHA256 79e3c6901afeb65980c588ad3286cbf5f5f2082d3f787058642e7e4b7427e18e
MD5 9761f19df39731f9738a901f4d628664
BLAKE2b-256 575b0f2914663008c0a78863780384583d2431c635c99a417a7d8bb7214dc880

See more details on using hashes here.

File details

Details for the file aas_core_codegen-0.0.19-py3-none-any.whl.

File metadata

File hashes

Hashes for aas_core_codegen-0.0.19-py3-none-any.whl
Algorithm Hash digest
SHA256 c421e3d38182ce31ac13edcbc94dfce11737d0ae5d8d6399b55a0360243b6058
MD5 f00a6218166b34e56f66505447d927b8
BLAKE2b-256 6ae4a633ea3a29d57aff3ad89890e6fb279178e42a4ee601181e1b67d347a0b1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page