TaskGroupRef

A group of tasks in a Dag, shown in the Airflow UI as one node that expands: Python's TaskGroup.

Everything declared in a group carries the group's ID as a prefix, so task stage in group staging is the task staging.stage. A group can stand at either end of an edge, so a whole group can be ordered against a task or another group:

var staging = dag.taskGroup("staging");
staging.task("stage", Stage.class);
extract.before(staging); // every task staging starts with waits for extract

As an upstream, a group stands for its leaves, the tasks nothing else in the group runs after; as a downstream, for its roots, the tasks that run after nothing else in the group. What the group holds is read once, rather than at each edge as Python reads it, so a group's edges can be drawn before its tasks are declared. The edges still resolve in the order they were drawn.

The Airflow UI draws the edges into a group through one join node and the edges out of it through a second join node. For staging, the join nodes have the IDs staging.upstream_join_id and staging.downstream_join_id, and no task or other group in the Dag can take either ID. For example, staging.task("upstream_join_id", Stage.class) fails because the new task's ID would be staging.upstream_join_id. dag.taskGroup("staging") also fails if the Dag already has a task with the ID staging.upstream_join_id.

Properties

Link copied to clipboard
val id: String

Group ID, including any enclosing group's prefix.

Functions

Link copied to clipboard
open override fun after(vararg previous: Deps.Flow): TaskGroupRef

Runs the tasks here after each of previous, carrying no value.

Link copied to clipboard
open override fun before(vararg next: Deps.Flow): TaskGroupRef

Runs the tasks here before each of next, carrying no value.

Link copied to clipboard
open override fun endpoints(): List<Endpoint>

The ends an edge drawn here attaches to. A task stands for itself, so the default is nodes; a task group stands for the group rather than for the tasks it holds today.

Link copied to clipboard
fun If(definition: Class<out ConditionTask>): ConditionRef

Declares a condition in this group, as DagDef.If does for the Dag.

fun If(id: String, definition: Class<out ConditionTask>): ConditionRef

Declares a condition in this group under the task ID <group ID>.<id>.

Link copied to clipboard
open override fun nodes(): List<TaskDef>

Every task in this group, including those in nested groups.

Link copied to clipboard
fun Switch(definition: Class<out SwitchTask>): SwitchRef

Declares a switch in this group, as DagDef.Switch does for the Dag.

fun Switch(id: String, definition: Class<out SwitchTask>): SwitchRef

Declares a switch in this group under the task ID <group ID>.<id>.

Link copied to clipboard
fun <T> task(id: String, definition: Class<out Task>): TaskRef<T>

Creates a task in this group, registers it with the Dag, and hands back its handle.

fun task(id: String, trigger: TriggerDagRun): TaskRef<Void>

Declares a task in this group that starts a run of another Dag, as DagDef.task does for the Dag.

Link copied to clipboard

Nests a task group inside this one.