Skip to content

Airflow Migration#726

Draft
pingsutw wants to merge 19 commits intomainfrom
airflow-migration
Draft

Airflow Migration#726
pingsutw wants to merge 19 commits intomainfrom
airflow-migration

Conversation

@pingsutw
Copy link
Member

@pingsutw pingsutw commented Feb 27, 2026

Summary

  • Introduces the Airflow migration plugin (flyteplugins-airflow) that monkey-patches airflow.DAG and BaseOperator to transparently convert standard Airflow DAG definitions into runnable Flyte tasks
  • Extracts _AirflowTaskMixin to DRY shared behavior (dependency arrows, ExecutorSafeguard workaround) between AirflowShellTask and AirflowPythonFunctionTask
  • Breaks FlyteDAG.build() into smaller focused methods (_build_downstream_map(), _find_caller_module(), _create_dag_entry())
  • Cleans up unused imports, dead code, and replaces global statements with a module-level _state dict

Test plan

  • Verified import flyteplugins.airflow.task triggers patches correctly
from pathlib import Path

import flyteplugins.airflow.task  # noqa: F401 — triggers DAG + operator monkey-patches
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.operators.python import PythonOperator

import flyte


def hello_python():
    print("Hello from PythonOperator!")


# Standard Airflow DAG definition — no Flyte-specific changes needed inside the block.
# Pass flyte_env so the generated workflow task uses the right container image.
with DAG(
    dag_id="simple_airflow_workflow",
) as dag:
    t1 = BashOperator(
        task_id="say_hello",
        bash_command='echo "Hello Airflow!"',
    )
    t2 = BashOperator(
        task_id="say_goodbye",
        bash_command='echo "Goodbye Airflow!"',
    )
    t3 = PythonOperator(
        task_id="hello_python",
        python_callable=hello_python,
    )
    t1 >> t2  # t2 runs after t1


if __name__ == "__main__":
    flyte.init_from_config(root_dir=Path(__file__).parent.parent.parent)
    run = flyte.with_runcontext(mode="remote", log_level="10").run(dag)
    print(run.url)

pingsutw and others added 17 commits February 10, 2026 22:20
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
- Extract _AirflowTaskMixin to DRY shared behavior (dependency arrows,
  ExecutorSafeguard workaround, common init) between task classes
- Rename classes for clarity: AirflowRawContainerTask -> AirflowShellTask,
  AirflowFunctionTask -> AirflowPythonFunctionTask,
  AirflowTaskResolver -> AirflowPythonTaskResolver
- Break FlyteDAG.build() into smaller methods: _build_downstream_map(),
  _find_caller_module(), _create_dag_entry()
- Replace global statement with module-level _state dict
- Remove unused imports, dead code (_downstream_flyte_tasks, commented-out
  params), and replace print() with logger.debug()
- Consolidate two iteration loops in build() into one
- Update README with current API and quick-start example

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
@pingsutw pingsutw marked this pull request as draft February 27, 2026 08:36
@pingsutw pingsutw changed the title Rewrite airflow plugin for clarity and maintainability Airflow Migration Feb 27, 2026
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant