The EdgeXFoundry Application Functions Software Development Kit (SDK) for Python. This is a Python para SDK for the app-functions-sdk-go, which is designed to help you create EdgeX application services that can process/transform/export data from EdgeX.
This Python SDK is supported on Python 3.10 or later.
This Python SDK is designed to follow the file structure that can be installed by pip package installer as a Python package app_functions_sdk_py.
The file structure of this Python SDK is as follows:
- app-service-template: this folder contains a template for creating a new EdgeX application service using this Python SDK.
- src/app_functions_sdk_py: this folder contains the source code of the Python SDK with top-level package app_functions_sdk_py, which is further divided into the following subpackages:
- app_functions_sdk_py: this subpackage contains modules for implementation of the Python SDK.
- boostrap: this subpackage contains modules for implementation of the bootstrap library for service bootstrap.
- clients: this subpackage contains modules for implementation of various client libraries that are similar to https://github.com/edgexfoundry/go-mod-core-contracts/tree/main/clients.
- configuration: this subpackage contains modules for implementation of configuration client library that are similar to https://github.com/edgexfoundry/go-mod-configuration.
- contracts: this subpackage contains modules for implementation of contract models that are similar to https://github.com/edgexfoundry/go-mod-core-contracts.
- functions: this subpackage contains modules for implementation of functions that can be used to process/transform/export data from EdgeX.
- interfaces: this subpackage contains modules for various abstract class definition of a role or contract that can be fulfilled by any class or struct that inherits the abstract class. These abstract classes are defined to promote flexibility and decoupling in this SDK.
- internal: this subpackage contains modules for internal implementation of the SDK. These modules are not intended to be used by the end user.
- messaging: this subpackage contains modules for implementation of messaging client library that are similar to https://github.com/edgexfoundry/go-mod-messaging.
- registry: this subpackage contains modules for implementation of registry client library that are similar to https://github.com/edgexfoundry/go-mod-registry.
- utils: this subpackage contains utility functionality.
- tests: this folder contains the unit tests for the Python SDK. Any new unit-tests should be added here with corresponding file structure as to src/app_functions_sdk_py.
- setup.py: this file is used to package the Python SDK into a Python package. This file is used to dynamically specify the package version.
- pyproject.toml: this file is used to specify the build system requirements for the Python SDK.
- Makefile: the Makefile used to build and test the Python SDK.
- requirements.txt: this file specifies the dependencies required to build and test the Python SDK.
This Python SDK aims to facilitate the development for a python developer to create their own EdgeX Application Service with following features:
- Basic logging mechanism
- Load and apply the EdgeX environment variables
- Consume configuration from YAML configuration file
- Consume configuration from EdgeX Keeper
- Process incoming data from EdgeX Message Bus via either MQTT or NATS-Core
- Process incoming data from a HTTP POST request
- Basic EdgeX common REST API, such as ping, version, and config
The SDK also provides the following built-in functions to process/transform/export data from EdgeX:
- Filtering functions to filter data based on profile name, source name, device name, or resource name
- MQTT Export function to export data to an external MQTT broker
- Batch functions to batch data based on the number of events or the time window
- Compression functions to compress data
- Data protection functions to encrypt data
- Conversion functions to convert data from one format to another
- JSONLogic function to process data based on JSONLogic rules
- Set response function to set the response data into passed in event that received from previous function
- Wrap into event function to create an EventRequest using the Event/Reading metadata that have been set
To run the unit-tests against SDK, you can use the following command:
make test-sdk
You can also run the tests against the app-service-template by using the following command:
make test-template
To have lint to analyse the SDK, you can use the following command:
make lint
To run tests, and lint analysis altogether, you can use the following command:
make test
To build the Docker image for the app-service-template, you can use the following command:
make docker
By a successful build, a docker image $(USER)/app-service-template:latest will be created in your local environment.