Visitar URL original
Support dynamic Dag generation for native TypeScript Dags · Issue #74335 · apache/airflow · GitHub
Skip to content

Support dynamic Dag generation for native TypeScript Dags #74335

Description

@jason810496

Description

Once #74036 and #74037 land, a native TypeScript Dag bundle can generate its Dags from a YAML file in the Dag bundle. Editing only the YAML changes the live Dags, and their tasks run without repacking the bundle:

  • The Dag processor runs the packed bundle on every parse, so the YAML is read fresh.
  • A task of a native Dag runs the .min.mjs named by its dag_rel_path, at the run's bundle version, with no check against the dag_ids recorded at pack time.
import { readFileSync } from "node:fs";
import { parse } from "yaml";
import { Bundle, Dag } from "apache-airflow-ts-sdk";

const config = parse(readFileSync(new URL("./dags.yaml", import.meta.url), "utf-8"));

const bundle = new Bundle();
for (const spec of config.dags) {
  const dag = new Dag(spec.dag_id, { queue: "typescript" });
  // add tasks from spec
  bundle.register(dag);
}
await bundle.serve();

Follow-ups

  • Add an e2e case: pack the bundle, add a Dag to the YAML in the Dag bundle, wait for a re-parse, then trigger the new Dag and check that it succeeds.
  • Document dynamic Dag generation in the TypeScript SDK native Dag guide:
    • Read the YAML at runtime with fs and import.meta.url. Importing it lets the bundler inline it, which freezes it at pack time.
    • Keep the YAML in the same Dag bundle. airflow-ts-pack also runs the bundle, so the YAML must exist at pack time, or the code must handle it being missing.
    • Generation must be deterministic, and every generated Dag needs the queue that routes to the NodeCoordinator.
    • A YAML change shows up on the next periodic re-parse ([dag_processor] min_file_process_interval). Editing the YAML does not trigger an earlier re-parse.
    • With a versioned Dag bundle, runs keep the YAML of their bundle version. With an unversioned bundle, a running Dag run sees the new YAML, and tasks removed from it end as removed.

Depends on

Activity

  1. added
    kind:taskA task that needs to be completed as part of a larger issue
    on Oct 6, 2026
  2. self-assigned this
    on Oct 6, 2026
  3. dhanusharer commented on Oct 7, 2026

    @dhanusharer

    Hi @jason810496, I’d be interested in contributing to this issue.

    I’d like to work on the E2E coverage for dynamic DAG generation, specifically the flow of packing the TypeScript DAG bundle, updating the YAML to add a new DAG, waiting for the DAG processor to re-parse the bundle, and then triggering and verifying the newly generated DAG.

    I can also help with the corresponding documentation updates for the TypeScript SDK native DAG guide.

    Before I start, could you please let me know if this scope would be helpful and whether there are any existing E2E tests or patterns you’d recommend following?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:coordinatorCoordinator: The interface to spawn Lang-SDK subprocessesarea:ts-sdkkind:taskA task that needs to be completed as part of a larger issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions