Kestra is an infinitely scalable orchestration and scheduling platform that allows users to create, run, schedule, and monitor complex pipelines. The Python client library facilitates programmatic interaction with the Kestra API for managing flows, executions, and sending metrics, outputs, and logs from within Python script tasks. The library is currently at version 1.3.0 and maintains a regular release cadence with frequent updates.
pip install kestraVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to programmatically create and execute a Kestra flow using the Kestra Python SDK. It configures the client using environment variables for host, username, and password (or API token), then defines a simple flow in YAML and submits it to the Kestra instance. It then triggers an execution and waits for its completion. For in-flow interactions, the `kestra.Kestra` class is used within Python script tasks.
Ensure all API calls and client configurations specify a `tenant` ID. For Open Source, use `main`. Update any hardcoded API paths to include the tenant.
Configure the `KestraClient` with either `username` and `password`, or an `access_token` (for service accounts). Avoid making unauthenticated API calls.
Run the provided migration scripts for your storage provider to update object paths. Failure to do so will prevent Kestra from accessing files with the old path structure.
For efficient dependency management, consider building a custom Docker image that includes Python and all required pip packages, or install packages at server startup if using the `Process Task Runner`. Alternatively, use caching for virtual environments in `WorkingDirectory` tasks.
Be mindful of the specific import paths based on whether you are writing an external Python script to interact with Kestra (use `kestrapy`) or writing a Python script to be executed within a Kestra flow (use `kestra`).
Ensure the necessary packages are listed in the `beforeCommands` property of your Kestra Python task (e.g., `pip install kestra pandas`) or use the `dependencies` property (available from Kestra 0.23+) for caching.
Verify that the `KESTRA_HOSTNAME` environment variable is correctly set to the Kestra API's URL (e.g., `http://localhost:8080`) and that the Kestra server is running and reachable from where the Python client is executed.
Add `from kestra import Kestra` at the beginning of your Python script when interacting with Kestra's context (e.g., `Kestra.outputs({'key': 'value'})`).Review the YAML definition of the flow or the structure of the input payload being sent to the Kestra API to ensure it adheres to Kestra's schema and expected data types.
No dependency data recorded yet.