Skip to content

edgexfoundry-holding/app-functions-sdk-python

Repository files navigation

Application Functions SDK for Python

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.

Prerequisites

This Python SDK is supported on Python 3.10.

File Structure

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.
  • 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.

Features Supported

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:

Run Tests

To run the unit-tests against SDK, you will have to follow steps as described below:

  1. Create a virtual environment in the root of the repository in your local environment:

    • python3 -m venv venv
  2. Switch to the virtual environment:

    • source ./venv/bin/activate
  3. Install the dependencies for the App Functions Python SDK in the virtual environment:

    • pip install -r requirements.txt
  4. Install the App Functions Python SDK in the virtual environment:

    • make install-sdk
  5. Run the tests against the SDK by using the following command:

    • make test-sdk

Try the sample application service

To further understand the usage of this Python SDK, you can try the sample application service provided in the app-service-template folder. This sample application service is configured with default Message Bus trigger to subscribe for any event messages published to EdgeX message bus, and process these event messages with the default pipeline containing two functions: filter_by_device_name and mqtt_send, so the app service will only process event messages coming from Random-Integer-Device, and then republish such event messages to an external MQTT broker test.mosquitto.org via test_topic topic.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages