Package: pyi40aas
PyI40AAS – Python Industry 4.0 Asset Administration Shell⚠️ This project is now known as basyx-python-sdk, available here:https://github.com/eclipse-basyx/basyx-python-sdk⚠️⚠️⚠️This project is deprecated⚠️⚠️⚠️The PyI40AAS project aims to provide an implementation of the Asset Administration Shell (AAS) for Industry 4.0 Systems,
compliant with the meta model and interface specification provided inthe document “Details of the Asset Administration Shell” (v2.0.1).FeaturesModelling of AASs as Python objects (according to DotAAS sec. 4)except for: Security extension of the metamodel (according to DotAAS sec. 5),HasDataSpecificationReading and writing of AASX package files (according to DotAAS sec. 6)(De-)serialization of AAS objects into/from JSON and XML (according to DotAAS sec. 7)Storing of AAS objects in CouchDB, Backend infrastructure for easy expansionCompliance checking of AAS XML and JSON filesProject StructureThe PyI40AAS project provides theaasPython package with 6 submodules:aas.model: The AAS metamodel implemented in pythonaas.adapter: Adapters for various file formatsaas.backend: Backend infrastructure for storing and retrieving AAS objectsaas.compliance_tool: Compliance checker for AAS filesaas.util: Provides utilitiesaas.examples: Example data and tutorialsLicenseThe PyI40AAS project is dual-licensed under the terms of the Eclipse Public License - v 2.0 and the
Apache License Version 2.0. Choose either of the two licenses that better suits your needs.SPDX-License-Identifier: EPL-2.0 OR Apache-2.0For more information, especially considering the licenses of included third-party works, please consult theNOTICEfile.DependenciesPyI40AAS requires the following Python packages to be installed for production usage. These dependencies are listed insetup.pyto be fetched automatically when installing withpip:lxml(BSD 3-clause License, usinglibxml2under MIT License)python-dateutil(BSD 3-clause License)pyecma376-2(Apache License v2.0)urllib3(MIT License)Optional production usage dependencies:For using the Compliance Tool to validate JSON files against the JSON Schema:jsonschemaand its
dependencies (MIT License, Apache License, PSF License)Development/testing/example dependencies (seerequirements.txt):jsonschemaand its dependencies (MIT License, Apache License, PSF License)psutil(BSD 3-clause License)Getting StartedInstallationFor production usage and building applications with PyI40AAS, we recommended installation from PyPI:pipinstallpyi40aasExampleThe following code example shows how to create aSubmodelwith aPropertyserialize it into an XML file using PyI40AAS:Create aSubmodel:fromaasimportmodel# Import all PYI40AAS classes from the model packageidentifier=model.Identifier('https://acplt.org/Simple_Submodel',model.IdentifierType.IRI)submodel=model.Submodel(identification=identifier)Create aPropertyand add it to theSubmodel:# create a global reference to a semantic description of the propertysemantic_reference=model.Reference((model.Key(type_=model.KeyElements.GLOBAL_REFERENCE,local=False,value='http://acplt.org/Properties/SimpleProperty',id_type=model.KeyType.IRI),))property=model.Property(id_short='ExampleProperty',# Identifying string of the element within the submodel namespacevalue_type=model.datatypes.String,# Data type of the valuevalue='exampleValue',# Value of the propertysemantic_id=semantic_reference# set the semantic reference)submodel.submodel_element.add(property)Serialize theSubmodelto XML:fromaas.adapter.xmlimportwrite_aas_xml_filedata:model.DictObjectStore[model.Identifiable]=model.DictObjectStore()data.add(submodel)withopen('Simple_Submodel.xml','w',encoding='utf-8')asf:write_aas_xml_file(file=f,data=data)Examples and TutorialsFor further examples and tutorials, check out theaas.examples-package. Here is a quick overview:aas.examples.tutorial_create_simple_aas: Create an Asset Administration Shell, including an Asset object and a
Submodelaas.examples.tutorial_storage: Manage a larger number of Asset Administration Shells in an ObjectStore and resolve
referencesaas.examples.tutorial_serialization_deserialization: Use the JSON and XML serialization/deserialization for
single objects or full standard-compliant filesaas.examples.tutorial_aasx: Export Asset Administration Shells with related objects and auxiliary files to AASX
package filesaas.examples.tutorial_backend_couchdb: Use theBackendsinterface (update()/commit()methods) to manage and
retrieve AAS objects in a CouchDB document databaseCompliance ToolThe PyI40AAS project contains a compliance tool for testing xml and json files is provided in theaas.compliance_tool-package. Following functionalities are supported:create an xml or json file compliant to the official schema containing example Asset Administration Shell elementscreate an aasx file with xml or json files compliant to the official schema containing example Asset Administration
Shell elementscheck if a given xml or json file is compliant to the official schemacheck if a given xml, json or aasx file is readable even if it is not compliant to the offical schemacheck if the data in a given xml, json or aasx file is the same as the example datacheck if two given xml, json or aasx files contain the same Asset Administration Shell elements in any orderInvoking should work with eitherpython -m aas.compliance_tool.clior (when installed correctly and PATH is set
correctly) withaas_compliance_checkon the command line.For further usage information consider theaas.compliance_tool-package or invoke withpython -m aas.compliance_tool.cli --helprespectivelyaas_compliance_check --help.ContributingIf you plan contributing code to the PyI40AAS project, please get in touch with us via E-Mail first:m.thies@plt.rwth-aachen.deCodestyle and TestingOur code follows thePEP 8 -- Style Guide for Python Code.
Additionally, we usePEP 484 -- Type Hintsthroughout the code to enable type checking the code.Before submitting any changes, make sure to letmypyandpycodestylecheck your code and run the unit tests with
Python's builtinunittest. To install the required tools, use:pipinstallmypypycodestyleRunning all checks:mypyaastestpycodestyle--max-line-length120aastestpython-munittestWe aim to cover our code with test by at least 80%. To check test coverage, you can usecoverage:pipinstallcoverage
coveragerun--sourceaas--branch-munittest
coveragereport-mContribute Code/PatchesTBD