Package: basyx-python-sdk
Eclipse BaSyx Python SDK(formerly known as PyI40AAS – Python Industry 4.0 Asset Administration Shell)The Eclipse BaSyx Python project focuses on providing a Python implementation of the Asset Administration Shell (AAS)
for Industry 4.0 Systems.
These are the currently implemented specifications:SpecificationVersionPart 1: Metamodelv3.0 (01001-3-0)Part 2: APInot implemented yetPart 3a: Data Specification IEC 61360v3.0 (01003-a-3-0)Part 5: Package File Format (AASX)v3.0 (01005-3-0)FeaturesModelling of AASs as Python objectsexcept for:HasDataSpecificationReading and writing of AASX package files(De-)serialization of AAS objects into/from JSON and XMLStoring of AAS objects in CouchDB, Backend infrastructure for easy expansionCompliance checking of AAS XML and JSON filesProject StructureThe BaSyx Python SDK project provides thebasax.aasPython package with 6 submodules:basyx.aas.model: The AAS metamodel implemented in pythonbasyx.aas.adapter: Adapters for various file formatsbasyx.aas.backend: Backend infrastructure for storing and retrieving AAS objectsbasyx.aas.compliance_tool: Compliance checker for AAS filesbasyx.aas.util: Provides utilitiesbasyx.aas.examples: Example data and tutorialsLicenseThe BaSyx Python SDK project is licensed under the terms of the MIT License.SPDX-License-Identifier: MITFor more information, especially considering the licenses of included third-party works, please consult theNOTICEfile.DependenciesThe BaSyx Python SDK 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/documentation/example dependencies (seerequirements.txt):jsonschemaand its dependencies (MIT License, Apache License, PSF License)psutil(BSD 3-clause License)Sphinxand its dependencies (multiple licenses)sphinx-rtd-themeand its dependenciessphinx-argparse(MIT License)Dependencies for building the documentation:Sphinxand its dependencies (BSD 2-clause License, MIT License, Apache License)sphinx-rtd-themeand its dependencies (MIT License, PSF License)sphinx-argparse(MIT License)Getting StartedInstallationEclipse BaSyx Python SDK can be installed from PyPI, the Python Package Index, just as nearly every other Python package:pipinstallbasyx-python-sdkFor working with the current development version, you can also install the package directly from GitHub, using Pip's Git feature:pipinstallgit+https://github.com/eclipse-basyx/basyx-python-sdk.git@mainYou may want to use a Python'svenvor a similar tool to install BaSyx Python SDK and its dependencies only in a project-specific local environment.ExampleThe following code example shows how to create aSubmodelwith aPropertyserialize it into an XML file using the
Eclipse BaSyx Python SDK:Create aSubmodel:frombasyx.aasimportmodel# Import all BaSyx Python SDK classes from the model packageidentifier='https://acplt.org/Simple_Submodel'submodel=model.Submodel(identifier)Create aPropertyand add it to theSubmodel:# create an external reference to a semantic description of the propertysemantic_reference=model.ExternalReference((model.Key(type_=model.KeyTypes.GLOBAL_REFERENCE,value='http://acplt.org/Properties/SimpleProperty'),))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:frombasyx.aas.adapterimportwrite_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 thebasyx.aas.examples-package. Here is a quick overview:tutorial_create_simple_aas: Create an Asset Administration Shell, including an Asset object and a Submodeltutorial_storage: Manage a larger number of Asset Administration Shells in an ObjectStore and resolve referencestutorial_serialization_deserialization: Use the JSON and XML serialization/deserialization for single objects or full standard-compliant filestutorial_aasx: Export Asset Administration Shells with related objects and auxiliary files to AASX package filestutorial_backend_couchdb: Use theBackendsinterface (update()/commit()methods) to manage and retrieve AAS objects in a CouchDB document databaseDocumentationA detailed, complete API documentation is available on Read the Docs:https://basyx-python-sdk.readthedocs.ioCompliance ToolThe Eclipse BaSyx Python SDK project contains a compliance tool for testing xml and json files is provided in thebasyx.aas.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 basyx.aas.compliance_tool.clior (when installed correctly and PATH is set
correctly) withaas-compliance-checkon the command line.For further usage information consider thebasyx.aas.compliance_tool-package or invoke withpython -m basyx.aas.compliance_tool.cli --helprespectivelyaas-compliance-check --help.ContributingFor contributing with issues and code, please see ourContribution Guideline.Eclipse Contributor AgreementTo contribute code to this project you need to sign theEclipse Contributor Agreement (ECA).
This is done by creating an Eclipse account for your git e-mail address and then submitting the following form:https://accounts.eclipse.org/user/eca