# airflow The Airflow migration tool (the compatibility layer dropped, D475). Generated by `make records` from the decisions whose `topic` (or `also`) is this one; edit the decisions, not this page. ## Current ### The tool - **The Airflow migration tool rewrites the source, checked against the original's structure** (D470, planned (M5.2b)): `schedr airflow migrate --out ` rewrites Airflow DAG files into native schedr DAGs once, with LibCST (comments, layout and the user's functions kept), never editing files in place. Each converted DAG is checked: the original imported through a recording stub of `airflow` and the converted one through `schedr dags check`, compared by the paths a run can take (which tasks run, after which, for each way their upstream tasks can end) and by their schedules, retries and timeouts, not by entity kinds, so an emulation (decision 473) compares equal; a difference is reported, not shipped. LibCST is an optional extra (`schedr[migrate]`). Not chosen: building DAGs by running the original alone (loops unrolled, the user's structure lost); a rewrite without the check. - **The migration tool has an Airflow 2 mode and an Airflow 3 mode** (D471, planned (M5.2b)): The tool has two modes, `--airflow 2` and `--airflow 3`, one of them always given (no default, never guessed): Airflow 2's forms (`airflow.operators.*`, `airflow.decorators`, `schedule_interval`) and defaults, or Airflow 3's (`airflow.sdk`, the `standard` provider) and its defaults. Defaults a file doesn't state differ between the two (e.g. `catchup`, the schedule when none is given), so the version can't be read from the file; an import that contradicts the mode stops that file with an error naming it. The report says which mode each file was converted in. Not chosen: Airflow 3 only (most of those leaving Airflow are on 2.x); guessing the version from the imports. - **No Airflow look-alike layer: the migration tool replaces it** (D475, planned (M5.2a)): `schedr.airflow` (Airflow's names over the native API at parse time) is dropped: a converted DAG has no runtime tie to Airflow's API. The layer's translation rules (schedules, trigger rules, short-circuit, resources for `all_done` and teardown) become the tool's. The principle stays: the native API never changes for Airflow; what it can't express exactly is reported. ### What converts - **What the migration tool converts, and what it leaves marked for a person** (D472, planned (M5.2c)): Converted: `DAG`/`@dag`, `@task`, the Bash, Python and Empty operators, dependencies, schedules, `default_args`, retries, timeouts, params (Airflow `Param` included), task groups, mapping, branching, short-circuit, trigger rules with an exact native equivalent; then Jinja in commands, XCom pulls (into outputs), sensors (into wait steps), `TriggerDagRunOperator` and `email_on_failure` where exact. What has none (callbacks, failure-branch rules, `depends_on_past`, SLA, custom operators) stays in place under a `# schedr-migrate: TODO` comment and is listed in the report; the file still converts. A per-DAG report (Markdown and JSON) says what was converted, approximated (and why) and left. - **The migration tool emulates Airflow behaviour with native constructs where exact** (D473, planned (M5.2c)): What the tool keeps is the DAG's paths: the same tasks run, after the same ones, in the same cases, even when the native entity differs. Where Airflow has a form the native API lacks, the tool writes the combination of native constructs that takes the same paths, never a change to the native API: e.g. a leaf task with the `all_done` rule (it runs once the others are done, whatever happened) becomes a resource with an empty setup whose cleanup is that task; `@task.run_if(condition)` a short-circuit in front of the task. Only exact emulations; anything inexact is reported for a person. - **Airflow connections and Variables are converted; provider operators are reported** (D474, planned (M5.2e)): `airflow connections export` and `airflow variables export` (JSON) become schedr connection definitions and secrets. Provider operators (SQL, S3, Kubernetes, ...) are not converted in the first version: the report counts them, so the most used ones are converted next. Not chosen: a fixed set of provider operators now (each needs a native form first); DAG files only. ### From other topics - Connections provide sync and async clients and checks (D53, `connections`; built M4.10) - A triggered run accepts an optional `planned_for` (D362, `chained-runs`; built M4.12a) ## Replaced - D136 (superseded by D472): Airflow Param comes with Airflow compatibility ## Where in code - `crates/schedr-master/src/dispatch/chained.rs::create_chained` (D362) - `crates/schedr-model/src/connection.rs::ConnectionDef` (D53) - `python/schedr/chained.py::TriggerDagOperator` (D362) - `python/schedr/connections.py::TwoWayConnection` (D53) ## Open None. Details and edge cases, with the reasons; read them before changing this: - JOURNAL.md: D470, D471, D472, D473, D474, D475 - archive/PROJECT.md: Run parameters and the DAG context