Skip to main content

Migrate Apache Airflow 2.x DAGs to Airflow 3.x — validate, transform, and diff

Project description

airflow-v2-to-v3

PyPI version PyPI downloads Python versions CI License Donate

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-v3 does 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 DummyOperatorfrom airflow.providers.standard.operators.empty import EmptyOperator
SDK moves from airflow.decorators import dag, taskfrom 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 DummyOperatorEmptyOperator
Dataset → Asset from airflow.datasets import Datasetfrom airflow.sdk import Asset
Trigger rules TriggerRule.DUMMYTriggerRule.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

airflow_v2_to_v3-0.1.0.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

airflow_v2_to_v3-0.1.0-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

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

Hashes for airflow_v2_to_v3-0.1.0.tar.gz
Algorithm Hash digest
SHA256 edc980d4ca605022762853930893fcb9132a4fe46c39d4d9ce03190b122b0e1b
MD5 e56b00c69a6806008040fdb4222608f5
BLAKE2b-256 15dda0d67c2147cf96e84e35dc8ae25345bc04f55656d438fa517081b7ee63c6

See more details on using hashes here.

File details

Details for the file airflow_v2_to_v3-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for airflow_v2_to_v3-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b65759da6f253ee023ddb15291f919689931699f34602b9932239a986db522a8
MD5 3083c692067af7e84e778b6916d01761
BLAKE2b-256 d7c4cf205b78c569c8a5fb4c6246c2f68ad190c73d8d3da40590b6a61802660e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page