Skip to main content

Generate different 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://media.githubusercontent.com/media/aas-core-works/aas-core-codegen/main/diagram.svg

Warning about Stability

While we aim for long-term stability of the generators, mind that the current version of the meta-model, version 3 release candidate 2 (V3RC2) is in too much flux to make any solid claims about the short-term stability.

For example, not even the set of basic types is still defined, and there is an on-going discussion in the UAG Verwaltungsschale what this set might be. Same holds about the definitions of references and how we should deal with them.

Moreover, the serialization approaches are not finalized either. For example, the current JSON schema does not allow for one-pass serialization (a.k.a. streaming-based serialization). We are discussing in UAG Verwaltungsschale to use JSON tuples with the model type as prefix instead of JSON objects, but this discussion is still at an early stage.

As long as V3RC2 does not stabilize, consider the generated code and schemas to be insufficient for any serious use (either experimental or in production).

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}

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

optional arguments:
  -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}     target language or schema

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.1rc1.post1.tar.gz (127.3 kB view details)

Uploaded Source

File details

Details for the file aas-core-codegen-0.0.1rc1.post1.tar.gz.

File metadata

  • Download URL: aas-core-codegen-0.0.1rc1.post1.tar.gz
  • Upload date:
  • Size: 127.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for aas-core-codegen-0.0.1rc1.post1.tar.gz
Algorithm Hash digest
SHA256 6453ca5cf30f9ede8ec45669e803082914111abd71cf77514dc36dcc39648e15
MD5 7b4eea8020a29af8fe8efc356242132d
BLAKE2b-256 e06e738ffbefcd03f37cffb3a69d62c1303b1aff5e34a18ef1d99b4980214955

See more details on using hashes here.

Supported by

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