Skip to content

Commit 12244c5

Browse files
committed
TS SDK: add task groups to the native Dag surface
1 parent 5a6fcf3 commit 12244c5

5 files changed

Lines changed: 517 additions & 39 deletions

File tree

‎airflow-core/docs/authoring-and-scheduling/language-sdks/typescript.rst‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,27 @@ already exists changes nothing. Each returns the reference it was called on, so
311311
Pass a value as an argument when the downstream task needs it, and use ``before`` or ``after`` when
312312
it only needs to run in order.
313313

314+
Task groups
315+
~~~~~~~~~~~
316+
317+
``dag.taskGroup(groupId)`` opens a scope with the same ``task`` and ``taskGroup`` methods as the Dag,
318+
prefixing the id of everything declared in it, as Python's ``prefix_group_id`` does:
319+
320+
.. code-block:: typescript
321+
322+
const staging = dag.taskGroup("staging");
323+
staging.task("stage_rows", stageRows)(); // task id "staging.stage_rows"
324+
staging.taskGroup("checks").task("nulls", checkNulls)(); // "staging.checks.nulls"
325+
326+
staging.before(loaded); // staging >> loaded
327+
328+
A group is an edge endpoint in its own right, so ``before`` and ``after`` order a whole group against
329+
a task or against another group.
330+
331+
Tasks and groups share one id namespace, as they do in Python, so a Dag cannot hold both a task and a
332+
group called ``staging``. A ``.`` is what separates a group from what it holds, so it cannot appear in
333+
an id of either.
334+
314335
``new Dag`` and ``dag.task`` both take a trailing spec of Airflow options:
315336
``{ schedule: "@daily", tags: ["etl"] }`` for the Dag, ``{ retries: 2, retryDelay: 30 }`` for a task.
316337

‎ts-sdk/src/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ export type { ArgNameMap } from "./sdk/arg-names.js";
2828
export type { Registerable } from "./sdk/bundle.js";
2929
export type {
3030
DagSpec,
31+
Node,
3132
TaskFactory,
33+
TaskGroupRef,
3234
TaskInput,
3335
TaskInputs,
3436
TaskOptions,

0 commit comments

Comments
 (0)