The Python SDK provides modules for developing an IIoT Edge App using Python 3.8 or higher. All examples assume this has been installed.
You should also update 'pip':
> pip install -U pipThe IIoT Edge App Python SDK provides the following modules combined within one Python package called agoraiot:
- agora_logging
- agora_busclient
- agora_config
- agora_utils
To install the package use:
> pip install agoraiotAlternatively, create a requirements.txt file and place all dependencies there.
Create a helloWorld.py file:
from agoraiot import logger
logger.info("Hello World!")Execute using Python:
> python helloWorld.pyCreate the following files:
helloworld.py [from above]
DockerfileDockerfile:
FROM python:3.12-alpine3.21
ADD ./src app
RUN pip install agoraiot
ADD requirements.txt /
RUN pip3 install -r requirements.txt
WORKDIR /app
CMD python3 app/helloWorld.py
Run the following command to build the image:
> docker build .The SDK is available for CSharp application. Details to setup application using CSharp SDK is Quick Guide for CSharp
- Applications can be configured at startup in the following ways:
- Defaults
- Default configuration files (
AEA.json)
- Supports prioritized configuration overlays.
- Configure applications dynamically at runtime using:
- External configuration files (
AEA.json) published in Redis via Twin Property
- External configuration files (
- Additional details found in the Configuration Tutorial.
- Advanced messaging via NATS for efficient communication between edge and cloud systems.
- Among supported topics:
slbapps.<app-name>.DataIn/slbapps.<app-name>.DataOut: Data messagesslbapps.<app-name>.RequestIn/slbapps.<app-name>.RequestOut: Application services requestsslbapps.<app-name>.EventIn/slbapps.<app-name>.EventOut: Alerts and events
- Additional details found in the BusClient Tutorial.
- Synchronize desired (cloud) and reported (edge) properties to maintain an accurate representation of physical devices.
- Properties are grouped into Twin Property Groups for easy management.
- Configuration
AEA.jsoncan also be submitted using Twin Property underconfiggroup - Additional details found in the Twin Property Tutorial.
- Applications are deployed in containers to ensure isolation and security.
- Containers are distributed via a private container registry and scanned for security compliance.
- IRIS environment comes with Redis and NATS
For local development, you can run both NATS and Redis locally either installed on the host or as docker containers.
Install Redis or run as a docker container, e.g.:
$ docker run --name alpine-redis -d redis:latest
Install NATS or run as a docker container, e.g:
$ docker run --name nats-server -p 4222:4222 nats:latest
Sample AEA.json with local Redis and NATS
{
"Name": "MyApp",
"AEA2": {
"RedisClient": {
"Server": "localhost",
"Port": "6379"
},
"BusClient": {
"Server": "nats://localhost:4222"
}
}
}Alternatively, you may point your application config file to a deployed IRIS environment if the external IP of the gateway is known.
Sample AEA.json with IRIS-deployed gateway
{
"Name": "MyApp",
"AEA2": {
"RedisClient": {
"Server": "163.188.xxx.xxx",
"Port": "6379"
},
"BusClient": {
"Server": "nats://163.188.xxx.xxx:4222"
}
}
}