orbitra.dags.airflow.client
OrbitraDagsClient: list, trigger and follow DAG runs through the Airflow REST API (/api/v2).
The client asks its TokenCredential for a token on every request, so a long wait outlives the token it started
with. get_dags_client builds one from the Orbitra settings and the Orbitra login of an environment.
Every API failure is a :class:DagsError with a one-line message: a missing DAG, run or task names the id, a refused
token says how to log in again, and anything else carries the HTTP status and the server’s detail.
Functions
get_dags_client
OrbitraDagsClient for the Airflow of an Orbitra environment, authenticated as the Orbitra login.
Args:
environment: The Orbitra environment; resolved from the settings sources whenNone.
- A client; no token is requested until its first call.
DagsError: The environment’s settings do not say where its Airflow API is.
Classes
DagsError
A call to the Airflow API failed; the message says why in one line.
OrbitraDagsClient
A client of the Airflow REST API of an Orbitra environment.
Methods:
close
get_dag_run
dag_id: The DAG id.dag_run_id: The run id.
- The run as it is now.
get_task_logs
dag_id: The DAG id.dag_run_id: The run id.task_id: The task id.try_number: The try to read;Nonereads the task instance’s current try.map_index: The map index of a mapped task instance;-1for a task that is not mapped.
- The log lines, oldest first.
list_dag_runs
dag_id: The DAG id.limit: How many runs to return, from 1 to 100.offset: How many runs to skip, for pagination.states: Only return runs in one of these states (queued,running,success,failed, in any case).start_time: Only return runs that started at or after this time. A naive datetime is read as UTC.end_time: Only return runs that started at or before this time. A naive datetime is read as UTC.
- One page of runs.
ValueError:limit,offsetor a state is invalid; nothing is requested.
list_dags
name_like: Only list DAGs whose id contains this text, case-insensitively.
- Every matching DAG, read across all pages.
list_task_instances
dag_id: The DAG id.dag_run_id: The run id.
- Every task instance of the run, read across all pages.
trigger_dag_run
dag_id: The DAG to run.conf: The run configuration (dag_run.conf).
- The id of the new run.
wait_for_dag_run
success or failed.
Args:
dag_id: The DAG id.dag_run_id: The run id.poll_interval: Seconds between two reads of the run.timeout: Seconds to wait before giving up;Nonewaits until the run ends.raise_on_failure: Raise when the run endsfailed;Falsereturns the failed run instead.
- The finished run.
DagsError: The run failed (withraise_on_failure) or the timeout passed.