leoflow_runtime.runner

Run a user task callable and capture its return value.

DEFAULT_RETURN_VALUE_PATH = '/tmp/leoflow_return_value.json'
def return_value_path() -> str:

Return the path the task's return value is written to.

Overridable via LEOFLOW_RETURN_VALUE_PATH (primarily for tests).

def run(entrypoint: str) -> None:

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 [dexaflow] prefix via _lifecycle() so they are distinguishable from user print().

class TemplateRenderError(builtins.RuntimeError):

TemplateRenderError fails a task attempt whose templates cannot render.

A template that fails to render must never run as its raw {{ ... }} text (#1845, ADR 0084): the attempt fails before execute() or bash -c, as on Airflow. field names the template field that failed, or is None when it cannot be identified; the message carries the Jinja error.

TemplateRenderError(field: str | None, owner: str, error: BaseException)
field
def run_bash(command: str) -> None:

Render a bash command with the run context, then exec bash -c in place so bash's stdout/stderr/exit code flow to the agent unchanged (ADR 0040). The agent only routes a command here when it contains {{ — plain bash stays a direct bash -c (no Python needed in bash-only images). A command that cannot render fails the attempt without running anything (ADR 0084).

UPSTREAM_XCOM_ENV = 'LEOFLOW_UPSTREAM_XCOM'
RESCHEDULE_PATH_ENV = 'LEOFLOW_RESCHEDULE_PATH'
RESCHEDULE_EXIT_CODE = 75
UPSTREAM_TASK_IDS_ENV = 'LEOFLOW_UPSTREAM_TASK_IDS'
UPSTREAM_XCOM_OMITTED_ENV = 'LEOFLOW_UPSTREAM_XCOM_OMITTED'
class XComNotDeliveredError(builtins.LookupError):

XComNotDeliveredError is raised by ti.xcom_pull for a value Dexaflow does not deliver to the task: a custom key, a task that is not a declared upstream, another DAG, or an upstream value too large for the environment. Airflow would return the value; returning None instead let the task run on with the wrong data (#2452).

CONTEXT_DOCS_URL = 'https://dexaflow.dexadata.ai/author-dags/operators-sensors/#the-full-run-context'
class NotProvidedError(builtins.AttributeError):

NotProvidedError is raised for a context attribute Dexaflow does not provide.

The runtime builds the Airflow context itself (ADR 0040), so its task instance, task, DAG and DAG run objects carry the attributes the runtime has data for and no others. A provider that reaches for another one gets this error, which names the attribute, instead of a bare AttributeError deep inside the provider (#1843). It is an AttributeError, so hasattr and getattr(obj, name, default) keep working. The message links the docs section that lists what the context carries (#2474).

NotProvidedError(owner: str, name: str)
name

attribute name

def run_operator(operator_class: str, args: dict) -> None:

Instantiate and execute a captured Airflow operator/sensor (ADR 0040 Phase A): import_string(class)(task_id, **args) → render_template_fields → execute. The provider is installed in the task image (declared via connectors:/ dependencies:); connections resolve from AIRFLOW_CONN_* exactly as a hook's do.