
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Kestra is an infinitely scalable orchestration and scheduling platform, creating, running, scheduling, and monitoring millions of complex pipelines.
This Python client provides functionality to interact with the Kestra server for sending metrics, outputs, and logs, as well as executing/polling flows.
pip install kestra
The Kestra
class is responsible for sending metrics, outputs, and logs to the Kestra server.
The Flow
class is used to execute a Kestra flow and optionally wait for its completion. It can also be used to get the status of an execution and the logs of an execution.
flow = Flow(
wait_for_completion=True, # default is True
poll_interval=1, # seconds. default is 1
labels_from_inputs=False, # default is False
tenant=None # default is None
)
You can also set the hostname and authentication credentials using environment variables:
export KESTRA_HOSTNAME=http://localhost:8080
export KESTRA_USER=admin
export KESTRA_PASSWORD=admin
export KESTRA_API_TOKEN=my_api_token
It is worth noting that the KESTRA_API_TOKEN or KESTRA_USER and KESTRA_PASSWORD need to be used, you do not need all at once. The possible Authentication patterns are:
Trigger a flow and wait for its completion:
from kestra import Flow
flow = Flow()
flow.execute('mynamespace', 'myflow', {'param': 'value'})
Set labels from inputs:
from kestra import Flow
flow = Flow(labels_from_inputs=True)
flow.execute('mynamespace', 'myflow', {'param': 'value'})
Pass a text file to an input of type FILE named 'myfile':
from kestra import Flow
flow = Flow()
with open('example.txt', 'rb') as fh:
flow.execute('mynamespace', 'myflow', {'files': ('myfile', fh, 'text/plain')})
Fire and forget:
from kestra import Flow
flow = Flow(wait_for_completion=False)
flow.execute('mynamespace', 'myflow', {'param': 'value'})
Overwrite the username and password:
from kestra import Flow
flow = Flow()
flow.user = 'admin'
flow.password = 'admin'
flow.execute('mynamespace', 'myflow')
Set the hostname, username, and password using environment variables:
from kestra import Flow
import os
os.environ["KESTRA_HOSTNAME"] = "http://localhost:8080"
os.environ["KESTRA_USER"] = "admin"
os.environ["KESTRA_PASSWORD"] = "admin"
flow = Flow()
flow.execute('mynamespace', 'myflow', {'param': 'value'})
The client includes retry logic with exponential backoff for certain HTTP status codes, and raises a FailedExponentialBackoff
exception if the request fails after multiple retries.
The Kestra
class provides a logger that formats logs in JSON format, making it easier to integrate with log management systems.
from kestra import Kestra
Kestra.logger().info("Hello, world!")
The Kestra
class provides a method to send key-value-based outputs to
the Kestra server. If you want to output large objects, write them to a
file and specify them within the outputFiles
property of the Python
script task.
Kestra.outputs({"my_output": "my_value"})
The Kestra
class provides a method to send counter metrics to the Kestra server.
Kestra.counter("my_counter", 1)
The Kestra
class provides a method to send timer metrics to the Kestra server.
Kestra.timer("my_timer", 1)
The Kestra
ION extra provides a method to read files and convert them to a list of dictionaries.
pip install kestra[ion]
import pandas as pd
import requests
from kestra import Kestra
file_path = "employees.ion"
url = "https://huggingface.co/datasets/kestra/datasets/resolve/main/ion/employees.ion"
response = requests.get(url)
if response.status_code == 200:
with open(file_path, "wb") as file:
file.write(response.content)
else:
print(f"Failed to download the file. Status code: {response.status_code}")
data = Kestra.read(file_path)
df = pd.DataFrame(data)
print(df.info())
FAQs
Kestra is an infinitely scalable orchestration and scheduling platform, creating, running, scheduling, and monitoring millions of complex pipelines.
We found that kestra demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.