Concepts
The provider joins two systems, each with its own vocabulary. This page gives a short primer on each, then shows how the provider’s classes map onto them. Skip the primer for the side you already know.
Airflow primer (for YellowDog users)
Apache Airflow is a workflow orchestrator. You describe a workflow in Python, and Airflow’s scheduler runs each step at the right time, in the right order, with retries and a record of what happened. Airflow itself does not usually do heavy computation; it tells other systems (such as YellowDog) what to do and waits for them.
- DAG
A Directed Acyclic Graph: one workflow, defined in a Python file in Airflow’s DAGs folder. A DAG has an ID, an optional schedule, and a set of tasks with dependencies between them (
a >> bmeans “runbaftera”). Each execution of a DAG is a DAG run, identified by arun_id.- Task
One step in a DAG. A task is an instance of an operator class, given a
task_idthat is unique within the DAG. Each run of a task is a task instance, which succeeds, fails, or is retried according to itsretriessetting.- Operator vs sensor
An operator performs an action and finishes (for example, “submit this work requirement”). A sensor is a special operator that waits for a condition to become true (for example, “this work requirement has completed”), checking periodically.
- Poke interval, timeout and mode
A sensor checks its condition (pokes) every
poke_intervalseconds. If the condition is not met withintimeoutseconds the sensor fails. In the defaultmode="poke"the sensor occupies a worker slot for the whole wait; withmode="reschedule"it releases the slot between pokes, which is better for long waits. The provider’s operators that wait takepoke_intervalandtimeouttoo.- Deferral and the triggerer
A deferrable task can hand a wait over to Airflow’s triggerer, a separate Airflow component that runs many small asynchronous waits, and give up its worker slot until the wait is over. The provider’s waiting operators and sensors take
deferrable=True; it needs a running triggerer. See Deferral.- XCom
Cross-communication: small values passed between tasks. When an operator returns a value, Airflow stores it as the task’s XCom under the key
return_value. A downstream task can read it withti.xcom_pull(task_ids="..."), typically inside a Jinja template.- Connection
A named, stored set of credentials and endpoint details, managed by Airflow (UI, CLI, environment variables or a secrets backend) so that secrets never appear in DAG code. Each connection has a type; this provider adds the
yellowdogtype.- Params
Run-time parameters declared on the DAG (
params={"namespace": "..."}) with defaults that can be overridden when a run is triggered. Templates read them as{{ params.namespace }}.- Templating
Some operator arguments are templated fields: Airflow renders them with Jinja just before the task runs, so
"{{ params.namespace }}"or"{{ ti.xcom_pull(task_ids='submit') }}"become real values. A templated field may also be given a Python callable, which Airflow calls to produce the value. See Templating and callables.- Setup and teardown
By default a task runs only if all its upstream tasks succeeded. A clean-up task, such as shutting down a worker pool, must run even when the work failed. Mark the task that creates the resource with
.as_setup()and the one that removes it with.as_teardown(setups=...): Airflow then runs the teardown once the tasks in between have finished, however they ended (unless the setup itself failed), and the teardown’s own result does not decide the DAG run’s outcome. (The older way,trigger_rule=TriggerRule.ALL_DONE, still works.)- Retries and clearing
A failed task is retried up to
retriestimes. Clearing a task instance in the UI or CLI runs it again, even if it succeeded. The provider’s submitting operators treat the two differently: a retry carries on with the earlier attempt’s work, a clear runs it again. See Safe retries and the run stamp.
For depth, see the Airflow documentation on DAGs, operators, sensors, XComs, connections, params and templates.
YellowDog primer (for Airflow users)
YellowDog is a platform for running large numbers of tasks on compute that it provisions for you (across cloud providers and regions) or that you supply. You describe work (what to run) separately from workers (where it can run), and YellowDog matches the two.
- Application, key and secret
An Application is a non-human identity in a YellowDog account, used for API access. It has a key ID and a key secret, and its permissions come from the groups it belongs to. The provider authenticates as an Application; you store its key and secret in an Airflow connection.
- Namespace
A label that groups related YellowDog resources (work requirements, worker pools, compute requirements). Names are unique within a namespace, so a resource can be identified either by its YellowDog ID or by its namespace and name.
- Work requirement, task group, task
The unit of work submitted to YellowDog is a work requirement. It contains one or more task groups, and each task group contains tasks. A task is a single job: a task type plus arguments, environment variables and so on. Task groups let tasks with the same requirements be scheduled together. In the SDK these are the
WorkRequirement,TaskGroupandTaskclasses.- Run specification and task types
Each task group has a
RunSpecificationsaying what its tasks need: at minimum the task types the tasks use (taskTypes), and optionally constraints such as worker tags, instance types, regions, retries and timeouts. A task type is a name (for exampledocker) that a worker advertises it can run; the worker’s configuration maps the task type to the actual command. Each task’staskTypemust be one of its task group’staskTypes.- Worker tags
A free-form label on a worker pool’s workers. Listing a tag in a run specification’s
workerTagsrestricts the task group to workers carrying that tag, which is how you direct work to a particular pool.- Worker pool
A set of workers that claim task groups and execute their tasks. A provisioned worker pool is one YellowDog creates for you on cloud instances; a configured worker pool is made of machines you run yourself, which register with YellowDog. A pool’s status is
IDLEwhile its workers are up but none has claimed work, andRUNNINGonce one or more workers are claimed; so a pool that is ready for work is inIDLEorRUNNING.- Compute requirement and template
Behind every provisioned worker pool is a compute requirement: the set of instances YellowDog provisions. It is created from a compute requirement template, which defines the instance types, providers, regions and so on. When provisioning, you say which template to use, the name and namespace for the new requirement and how many instances you want, in a
ComputeRequirementTemplateUsage. The worker pool’s own settings (worker tag, node counts, idle shutdown timers) go in aProvisionedWorkerPoolProperties.- Image family
A named family of machine images (for example, one image per cloud provider and region) from which instances are booted. A compute requirement refers to one through
imagesIdin the template usage, or in the template itself. The images determine which task types the workers can run.
For depth, see the YellowDog documentation and the YellowDog Python SDK.
How they fit together
An Airflow DAG drives YellowDog through the provider’s classes. Every class talks to YellowDog through a connection; operators perform one YellowDog action and return the affected resource’s ID as their XCom; sensors wait for a resource to reach a state.
Provider class |
What it does, in the terms above |
|---|---|
Reads a |
|
Submits a work requirement with its task groups and tasks, waits until it completes, and fails if it fails or is cancelled. Cancels it if it gives up. Returns its ID. |
|
Submits a work requirement. Returns its ID. |
|
Adds task groups (each with a run specification) to an existing work requirement. Returns the new task groups’ IDs. |
|
Adds tasks to an existing task group. Returns the new tasks’ IDs. |
|
Submits a work requirement together with its task groups and tasks, in one Airflow task. Returns the work requirement’s ID. |
|
Cancels a work requirement, optionally aborting running tasks. |
|
Provisions a worker pool and its compute requirement from a compute requirement template, optionally waiting until the pool is ready. Returns the worker pool’s ID. Typically a setup task. |
|
Cancels the unfinished work requirements of its setup/teardown scope (or of the whole DAG run), then shuts down a provisioned worker pool, optionally terminating its compute requirement immediately. Typically a teardown task. |
|
Sensor: waits for a work requirement to reach given states (for
example |
|
Sensor: waits for a worker pool to reach given states (for example
|
|
Sensor: waits for a compute requirement to reach given states (for
example |
Resources are identified either by ID (usually pulled from an upstream
task’s XCom) or by namespace and name (often built from params or
the run_id). Arguments that hold SDK objects are supplied either as
objects or as callables that build them at run time; see
Templating and callables.
A typical DAG has three tasks (see Provision, run, shut down):
ProvisionWorkerPool(a setup task,wait_until_ready=True) creates a pool whose workers carry a worker tag, and waits until it isIDLEorRUNNING.RunWorkRequirementsubmits work whose run specification targets that worker tag, and waits until it completes.ShutdownProvisionedWorkerPool(the teardown) cancels any work of its setup/teardown scope still running and shuts the pool down, whatever happened upstream.
The finer-grained operators and the sensors split these steps into more tasks; see Step by step.