Python runtime API¶
The leoflow_runtime package runs your task callable inside the container and
bridges its return value to XCom. It is installed in the DAG image (and the dev
venv); your dag.py uses the Apache Airflow Task SDK (from airflow.sdk import
DAG, task), and the agent invokes leoflow_runtime to execute the callable.
leoflow_runtime.runner
¶
Run a user task callable and capture its return value.
return_value_path()
¶
Return the path the task's return value is written to.
Overridable via LEOFLOW_RETURN_VALUE_PATH (primarily for tests).
Source code in
runtime/python/leoflow_runtime/runner.py
run(entrypoint)
¶
Import and call module:callable, writing a non-None return as JSON.
The agent reads the file and pushes it as the task's return_value XCom.
A None return writes nothing, so downstream tasks see no XCom.
Emits three lifecycle lines so the UI's log panel is informative even when
the user function is silent: loading <entrypoint>, resolved kwargs:
{...} (when any), and returned <repr> (success) or no extra line on
raise (the agent wraps the traceback). All three use [leoflow] prefix
via :func:_lifecycle so they are distinguishable from user print().
Source code in
runtime/python/leoflow_runtime/runner.py
leoflow_runtime.xcom
¶
Access XCom inputs injected into the task container by the agent.
xcom_pull(name, default=None)
¶
Return the upstream XCom mapped to name, or default if absent.
The agent injects each declared input as LEOFLOW_XCOM_<NAME>=<json>;
the name is matched case-insensitively.