Migrate Apache Airflow 2.x DAGs to Airflow 3.x — validate, transform, and diff
Project description
airflow-v2-to-v3
Migrate Apache Airflow 2.x DAGs to Airflow 3.x automatically — validate, transform, and diff your DAGs with a single CLI command. Built for Astronomer (Astro) Airflow users and anyone upgrading from Airflow 2 to Airflow 3.
Why this tool? Ruff's AIR rules flag Airflow 3 compatibility issues but don't auto-fix them.
airflow-v2-to-v3does the actual code transformation — handling 200+ migration rules across imports, parameters, context variables, and more.
Features
- 200+ migration rules covering import moves, parameter renames, class renames, context variable changes, and more
- Validate — scan DAGs for Airflow 3 compatibility issues without modifying files
- Migrate — transform Airflow 2 code to Airflow 3 in-place or to a separate output directory
- Diff — side-by-side diff output (like a GitHub PR) showing exactly what changed
- Reserved keyword detection — flags directories that shadow core Airflow modules (
utils,models, etc.)
Installation
pip install airflow-v2-to-v3
Usage
Validate
Check your DAGs for Airflow 3 compatibility issues:
airflow-v2-to-v3 validate /path/to/dags/
# Output as JSON
airflow-v2-to-v3 validate /path/to/dags/ --format json
# Output as table
airflow-v2-to-v3 validate /path/to/dags/ --format table
Migrate
Transform your DAGs from Airflow 2 to Airflow 3:
# In-place migration
airflow-v2-to-v3 migrate /path/to/dags/
# Migrate to a separate directory
airflow-v2-to-v3 migrate /path/to/dags/ -o /path/to/output/
# Dry run (show what would change without modifying files)
airflow-v2-to-v3 migrate /path/to/dags/ --dry-run
# Save diff report to file
airflow-v2-to-v3 migrate /path/to/dags/ --diff-report /path/to/report.txt
Diff
Preview changes without modifying files:
# Show side-by-side diff in terminal
airflow-v2-to-v3 diff /path/to/dags/
# Save diff report to file
airflow-v2-to-v3 diff /path/to/dags/ -o /path/to/report.txt
What Gets Migrated
| Category | Example |
|---|---|
| Import moves | from airflow.operators.dummy import DummyOperator → from airflow.providers.standard.operators.empty import EmptyOperator |
| SDK moves | from airflow.decorators import dag, task → from airflow.sdk import dag, task |
| Parameter renames | schedule_interval="@daily" → schedule="@daily" |
| Removed parameters | provide_context=True → removed (always provided in Airflow 3) |
| Context variables | context['execution_date'] → context['logical_date'] |
| Class renames | DummyOperator → EmptyOperator |
| Dataset → Asset | from airflow.datasets import Dataset → from airflow.sdk import Asset |
| Trigger rules | TriggerRule.DUMMY → TriggerRule.ALWAYS |
| Removed functions | days_ago(1) → datetime(...) |
Development
# Clone and install in dev mode
git clone https://github.com/rajeshkbathula/airflow-v2-to-v3.git
cd airflow-v2-to-v3
make dev
# Run tests
make test
# Build
make build
# Publish to PyPI
PYPI_TOKEN=your-token make publish
License
Apache 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file airflow_v2_to_v3-0.1.0.tar.gz.
File metadata
- Download URL: airflow_v2_to_v3-0.1.0.tar.gz
- Upload date:
- Size: 20.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
edc980d4ca605022762853930893fcb9132a4fe46c39d4d9ce03190b122b0e1b
|
|
| MD5 |
e56b00c69a6806008040fdb4222608f5
|
|
| BLAKE2b-256 |
15dda0d67c2147cf96e84e35dc8ae25345bc04f55656d438fa517081b7ee63c6
|
File details
Details for the file airflow_v2_to_v3-0.1.0-py3-none-any.whl.
File metadata
- Download URL: airflow_v2_to_v3-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b65759da6f253ee023ddb15291f919689931699f34602b9932239a986db522a8
|
|
| MD5 |
3083c692067af7e84e778b6916d01761
|
|
| BLAKE2b-256 |
d7c4cf205b78c569c8a5fb4c6246c2f68ad190c73d8d3da40590b6a61802660e
|