xiaohongshu
xiaohongshu
airflow-3x-migration
Comprehensive guide and patterns for migrating Apache Airflow 2.x workflows to Airflow 3.x, covering import changes, deprecated features, and new paradigms like Asset scheduling and TaskFlow API.
Full skill instructions
# Airflow 2.x
from airflow.operators.python import PythonOperator
# Airflow 3.x
from airflow.providers.standard.operators.python import PythonOperator
from airflow.providers.standard.operators.bash import BashOperator
from airflow.providers.standard.operators.empty import EmptyOperator
# Airflow 3.x
from airflow.providers.standard.sensors.filesystem import FileSensor
from airflow.providers.standard.sensors.time import TimeSensor
| Removed | Replacement |
|---|---|
SubDagOperator | TaskGroup |
packaged_dag_processor | Use standard DAG loading |
airflow.contrib.* | Provider packages |
schedule_interval param | schedule param |
# Airflow 3.x preferred
from airflow import DAG
from datetime import datetime
with DAG(
dag_id="my_dag",
schedule="@daily", # Not schedule_interval
start_date=datetime(2024, 1, 1),
catchup=False,
tags=["betting", "sports"],
) as dag:
...
from airflow.decorators import dag, task
@dag(schedule="@daily", start_date=datetime(2024, 1, 1), catchup=False)
def betting_workflow():
@task
def download_games(sport: str) -> list:
# Returns are automatically passed via XCom
return fetch_games(sport)
@task
def update_elo(games: list) -> dict:
return calculate_elo(games)
# Chain tasks
games = download_games("nba")
ratings = update_elo(games)
betting_dag = betting_workflow()
from airflow.sdk import Asset
# Define assets
games_data = Asset("games_data")
elo_ratings = Asset("elo_ratings")
# Producer DAG
@dag(schedule="@daily")
def download_dag():
@task(outlets=[games_data])
def download():
...
# Consumer DAG - triggers when asset updates
@dag(schedule=[games_data])
def process_dag():
@task
def process():
...
@task
def setup_db_connection():
return create_connection()
@task
def cleanup_connection(conn):
conn.close()
@task
def process_data(conn):
...
# Define setup/teardown relationship
with dag:
conn = setup_db_connection()
process_data(conn) >> cleanup_connection(conn)
# Or use context manager style
conn.as_setup() >> process_data(conn) >> conn.as_teardown()
from airflow import DAG
with DAG(
dag_id="betting_workflow",
version="2.0.0", # New in 3.x
schedule="@daily",
) as dag:
...
# Airflow 3.x - use REST API
curl -X POST "http://localhost:8080/api/v1/dags/my_dag/dagRuns" \
-H "Content-Type: application/json" \
-d '{"logical_date": "2024-01-15T00:00:00Z"}'
# Or use new backfill command
airflow dags backfill my_dag --start-date 2024-01-01 --end-date 2024-01-15
import requests
# Get DAG runs
response = requests.get(
"http://localhost:8080/api/v1/dags/betting_workflow/dagRuns",
auth=("admin", "admin")
)
# Trigger DAG
response = requests.post(
"http://localhost:8080/api/v1/dags/betting_workflow/dagRuns",
json={"conf": {"sport": "nba"}},
auth=("admin", "admin")
)
from airflow.utils.edgemodifier import Label
download >> Label("success") >> process
download >> Label("failure") >> alert
schedule_interval with schedulepython dags/my_dag.pydags/multi_sport_betting_workflow.py - Already uses 3.x importsxiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience