GitHub user rachelrabbitink added a comment to the discussion: Runtime dynamic
DAGs: letting each DagRun build its own graph
A bit more details on the above questions:
For 1. Task representation and retries:
- Currently we suppor `compute_layout` registers tasks via
`add_task_into_dynamic_dag(operator_class=..., task_id=..., **kwargs)`. The
layout stores operator class import paths, constructor kwargs, downstream IDs,
and core metadata (setup/teardown, deps, template fields, UI colors) rather
than operator objects.
- Kwargs must use supported types (primitives, containers, datetimes,
timedeltas, timetables, Param, attrs objects). Unrecognized types fail during
`__compute_layout`.
- Callables & callbacks. Functions, methods, and classes are saved as import
paths and loaded on workers. Importable targets like python_callable or
on_failure_callback work, but lambdas and closures are not supported.
Schedulers and the UI use serialized stand-ins without importing callables;
actual operators instantiate only on workers.
- Retries & clears. The layout is reused across retries and clears without
recomputing. It pins the image and DAG-code builds from initial computation.
Runs can be manually upgraded to newer builds, while backfills reset the layout
to capture updated code and conf.
- TaskFlow. Not natively supported. PythonOperator works with importable
functions, but @task decorators and XComArg wiring rely on parse-time DAG
context. Supporting TaskFlow upstream remains open, possibly by serializing
function references, argument bindings, and XComArg edges as data.
- Upstream mapping (open). The layout can store the bundle version at compute
time for worker resolution (aligning with Airflow 3 versioned bundles).
Handling non-versioned bundles and mapping build migrations to clear options
remain open.
For 2. Storage and the Execution API boundary
- Currently layouts are not in the metadata database. Each run's layout is one
object in object storage, keyed by DAG and logical date. Scheduler and
webserver processes cache the deserialized form. Sizes range from about 1 KB -
1 GB, and tens of thousands are above 16 MB, so a db row cannot handle some
cases.
- We don't deduplicate today: identical layouts from different runs are stored
separately. We're adding a per-run SHA-256 digest that the scheduler checks on
every load, which would also make content-addressed deduplication
straightforward later. Retention is a lifecycle rule on the prefix.
- Publishing through the Task Execution API (open). On Airflow 2 the compute
task writes the layout itself. We're moving that write behind a small service
that authenticates the workload's identity. It accepts a publish only from the
DAG's own identity, only while that run's __compute_layout attempt is running,
and only once per run.
- For Airflow 3, we'd want the same rule enforced with the per-task execution
token. Publish would be an endpoint that accepts the token of the running
__compute_layout attempt and writes only that run's layout, once. That keeps
the token task-scoped: it authorizes "publish my own run's layout," not general
writes.
- Secrets (partly handled). Jinja templates in templated fields are stored
unrendered and rendered on the worker at execution time. So {{ conn... }} or {{
var.value... }} references, and connection IDs passed as arguments, never put
secret values in the layout. A literal value that compute_layout fetched and
passed as a kwarg would be stored. We don't block that today. Static DAGs have
the same property for parse-time values in serialized DAGs, but a runtime
layout makes it easier to do by accident. For upstream we can propose a
guardrail, such as masking or rejecting values the secrets masker already knows
about.
GitHub link:
https://github.com/apache/airflow/discussions/77421#discussioncomment-19860704
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]