- Overview
- Python Executor Standalone Installation
- How to Migrate Trendz Python Executor 1.13.3 to Trendz Python Executor 1.14.0
- How to Connect Additional Libraries to the Python Executor
- Next steps
Overview
Trendz Python Executor is required to run:
- Python Calculation fields
- All prediction models (except Fourier Transformation)
- Code generation for Metric Explorer
Starting from version 1.14.0, the only way to run these features is via Trendz Python Executor using Docker (or Kubernetes).
Python Executor Standalone Installation
Step 1: Create Docker Compose File
Create the Docker Compose file with the following configuration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
version: '3.0'
services:
mypyexecutor:
restart: always
image: "thingsboard/trendz-python-executor:1.14.0"
ports:
- "8181:8181"
environment:
SCRIPT_ENGINE_RUNTIME_TIMEOUT: 30000
EXECUTOR_MANAGER: 1
EXECUTOR_SCRIPT_ENGINE: 6
THROTTLING_QUEUE_CAPACITY: 10
THROTTLING_THREAD_POOL_SIZE: 6
NETWORK_BUFFER_SIZE: 10485760
volumes:
- mytrendz-data/python-executor:/python-executor
Explanation of key fields:
8181- Python executor port for communication with Trendz servicerestart: always- automatically restarts the executor on failure or system rebootthingsboard/trendz-python-executor:1.14.0- Docker image for Trendz Python ExecutorSCRIPT_ENGINE_RUNTIME_TIMEOUT- timeout for Python script executionmytrendz-data/python-executor:/python-executor- mounts the volumemytrendz-data/python-executorto Trendz Python Executor additional data directory
Step 2: Create Volumes
Windows users should use Docker-managed volumes for Trendz data. Create a Docker volume before executing the Docker run command. Open “Docker Quickstart Terminal” and run:
1
docker volume create mytrendz-data-python-executor
Note: Replace the volume name mytrendz-data-python-executor with the name you plan to use in docker-compose.yaml.
Step 3: Start Python Executor
1
2
docker compose up -d
docker compose logs -f mypyexecutor
Step 4: Connect Trendz to Python Executor
Configure Trendz to communicate with the Python Executor.
Open Notepad as Administrator and edit:
1
C:\Program Files (x86)\trendz\conf\trendz.yml
Locate the script-engine block and configure:
1
2
3
4
5
6
7
script-engine:
provider: "${SCRIPT_ENGINE_PROVIDER:DOCKER_CONTAINER}"
runtime-timeout: "${SCRIPT_ENGINE_TIMEOUT:60000}"
callback-timeout: "${SCRIPT_ENGINE_TIMEOUT:60000}"
docker-provider-url: "${SCRIPT_ENGINE_DOCKER_PROVIDER_URL:PYTHON_EXECUTOR_HOST:PYTHON_EXECUTOR_PORT}"
websocket-buffer-size: "${SCRIPT_ENGINE_WEBSOCKET_BUFFER_SIZE:20971520}"
websocket-concurrency: "${SCRIPT_ENGINE_WEBSOCKET_CONCURRENCY:5}"
Replace PYTHON_EXECUTOR_HOST and PYTHON_EXECUTOR_PORT with your Python Executor service values and ensure Trendz can reach this network destination.
How to Migrate Trendz Python Executor 1.13.3 to Trendz Python Executor 1.14.0
If you already have a Python Executor with a version earlier than 1.14.0 connected to Trendz, you should migrate it before updating Trendz to 1.14.0.
Modify Docker Compose File
Locate the docker-compose.yaml file from which the Python Executor was launched.
Change the Python Executor image tag to version 1.14.0:
1
image: "thingsboard/trendz-python-executor:1.14.0"
Add the following lines at the end of the Python Executor configuration:
1
2
volumes:
- mytrendz-data/python-executor:/python-executor
Add the following lines at the end of the Docker Compose file:
1
2
3
volumes:
mytrendz-data-python-executor:
external: true
The final docker-compose.yaml should look like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
version: '3.0'
services:
mypyexecutor:
restart: always
image: "thingsboard/trendz-python-executor:1.14.0"
ports:
- "8181:8181"
environment:
SCRIPT_ENGINE_RUNTIME_TIMEOUT: 30000
EXECUTOR_MANAGER: 1
EXECUTOR_SCRIPT_ENGINE: 6
THROTTLING_QUEUE_CAPACITY: 10
THROTTLING_THREAD_POOL_SIZE: 6
NETWORK_BUFFER_SIZE: 10485760
volumes:
- mytrendz-data/python-executor:/python-executor
volumes:
mytrendz-data-python-executor:
external: true
Create Volumes for Python Executor
Windows users should use Docker-managed volumes for Trendz data. Create a Docker volume before executing the Docker run command. Open “Docker Quickstart Terminal” and run:
1
docker volume create mytrendz-data-python-executor
Note: Replace the volume name mytrendz-data-python-executor with the name you plan to use in docker-compose.yaml.
Restart Python Executor
Restart the Python Executor to apply the changes:
1
2
docker compose restart -d
docker compose logs -f mypyexecutor
How to Connect Additional Libraries to the Python Executor
If necessary, you can add additional Python libraries to the Python Executor and use them in your Trendz Calculation Fields or Trendz Custom Prediction Models.
For example, if you want to add the emoji library (specific version 2.2.0), follow these steps.
Step 1. Locate the Volume
The Python Executor data is mapped to a local folder via Docker volumes. By default:
1
cd %USERPROFILE%\mytrendz-data\python-executor
Step 2. Add a requirements.txt File
Create a file named requirements.txt in this folder with the library you need. For example:
1
echo emoji==2.2.0 > requirements.txt
Step 3. Restart the Docker Container
After updating requirements.txt, restart the Python Executor container:
1
2
docker compose ps
docker compose restart mypyexecutor
Step 4. Verify Installation
Check the logs to ensure the library installed successfully:
1
docker compose logs mypyexecutor
You should see something like:
1
2
Installing custom Python requirements...
Requirement already satisfied: emoji==2.2.0 in /usr/local/lib/python3.9/site-packages
Next steps
-
Getting started guide - These guide provide quick overview of main Trendz features.
-
Metric Explorer - Learn how to explore and create new metrics with Trendz Metric Explorer.
-
Anomaly Detection - Learn how to identify anomalies in the data.
-
Calculated Fields - Learn about Calculated fields and how to use them.
-
States - Learn how to define and analyse states for assets based on raw telemetry.
-
Prediction - Learn how to make forecasts and predict telemetry behavior.
-
Filters - Learn how filter dataset during analysis.
-
Available Visualizations - Learn about visualization widgets available in Trendz and how to configure them.
-
Share and embed Visualizations - Learn how to add Trendz visualizations on ThingsBoard dashboard or 3rd party web pages.
-
AI Assistant - Learn how to utilize Trendz AI capabilities.