apache-airflow-providers-pixi¶
apache-airflow-providers-pixi package¶
Run Python callables inside Pixi-managed environments, so a task can use packages from conda-forge and PyPI that are not installed on the Airflow worker.
Provider package¶
This package is for the pixi provider. All classes for this provider package are included in the
airflow.providers.pixi Python package:
| Class | Decorator | Description |
|---|---|---|
PixiOperator |
@task.pixi |
runs a Python callable in a Pixi environment on the worker |
PixiBashOperator |
@task.pixi_bash |
runs a Bash command in a Pixi environment, like BashOperator |
PixiTaskOperator |
- | runs a task from the manifest's [tasks] with pixi run <task> |
PixiKubernetesPodOperator |
@task.pixi_kubernetes |
runs a Python callable in a Pixi environment in a Kubernetes pod |
PixiBranchOperator |
@task.pixi_branch |
chooses the tasks to follow with a Python callable run in a Pixi environment, like BranchPythonVirtualenvOperator |
PixiShortCircuitOperator |
@task.pixi_short_circuit |
skips the tasks downstream when a Python callable, run in a Pixi environment, returns a falsy value, like ShortCircuitOperator |
PixiSensor |
@task.pixi_sensor |
waits for a Python callable, run in a Pixi environment, to return a truthy value |
The pixi connection type holds credentials for private conda channels and
PyPI indexes, and PixiCallableError is the
error a task fails with when the function raises inside the environment.
Other providers can build their own operators and decorators on these; see Building on the Pixi Operator.
Installation¶
Install it on top of an existing Airflow installation:
pip install apache-airflow-providers-pixi
pip install "apache-airflow-providers-pixi[cncf.kubernetes]"
The cncf.kubernetes extra adds the Kubernetes pod operator. For the minimum Airflow version
supported, see Requirements below.
The workers also need Pixi, installed for example in the worker image. The provider never installs it; see Pixi binary and the deployment guide.
Requirements¶
The minimum Apache Airflow version supported by this provider distribution is 3.1.2. Airflow 3.0
is not supported. The provider floors are the versions pinned by Airflow 3.1.2's constraints file, so
the constraints file of any supported Airflow release can be used.
| PIP package | Version required |
|---|---|
apache-airflow |
>=3.1.2 |
apache-airflow-providers-standard |
>=1.9.1 |
packaging |
>=22 |
tomlkit |
>=0.12 |
With the cncf.kubernetes extra:
| PIP package | Version required |
|---|---|
apache-airflow-providers-cncf-kubernetes |
>=10.9.0 |
On the workers:
| Tool | Version required |
|---|---|
pixi |
>=0.81.0 |
Python 3.10, 3.11, 3.12, 3.13 and 3.14 are supported; Airflow 3.1 itself runs on Python 3.13 at most, so Python 3.14 needs Airflow 3.2 or newer. CI runs the unit tests against the latest patch of each supported Airflow minor with its constraints file, and against the lowest allowed versions; see Testing against other Airflow versions. The Python inside the Pixi environment is independent of the worker's: it is whatever the manifest asks for, from Python 3.10 on, the oldest Python Airflow 3.1 supports.
Quick start¶
from airflow.sdk import dag, task
@dag
def my_dag():
@task
def epochs() -> int:
return 3
@task.pixi(dependencies={"python": "3.12.*", "numpy": ">=2"})
def train(epochs: int) -> float:
import numpy as np # imports go inside the function: it runs in the Pixi environment
return float(np.random.rand(epochs).mean())
train(epochs())
my_dag()
Continue with the Pixi Operator guide for the ways to point a task at an environment, and how arguments, return values, logs and timeouts work.