Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start porting DAG definition code to the Task SDK #43076

Merged
merged 32 commits into from
Oct 30, 2024
Merged

Conversation

ashb
Copy link
Member

@ashb ashb commented Oct 16, 2024

By "definition code" we mean anything needed at definition/parse time, leaving
anything to do with scheduling time decisions in Airflow's core.

Also in this PR I have attempted to keep it to only porting defintiion code
for simple DAGs, leaving anything to do with mapped tasks or execution time in
core for now, but a few things "leaked" across.

And as the goal of this PR is to go from working state to working state some
of the code in Task SDK still imports from "core" (various types, enums or
helpers) that will need to be resolved before 3.0 release, but it is fine for
now.

I'm also aware that the class hierarchy with
airflow.models.baseoperator.BaseOperator (and to a lesser extend with DAG) in
particular is very messy right now, and we will need to think how we want to
add on the scheduling-time functions etc, as I'm not yet sold that having Core
Airflow depend upon the Task-SDK classes/import the code is the right
structure, but we can address that later

We will also need to addresses the rendered docs for the Task SDK in a future
PR -- the goal is that "anything" exposed on airflow.sdk directly is part of
the public API, but right now the renedered docs show DAG as
airflow.sdk.definitions.dag.DAG which is certainly not what we want users to
see.

closes #43011

@boring-cyborg boring-cyborg bot added area:Scheduler including HA (high availability) scheduler area:task-sdk labels Oct 16, 2024
@ashb
Copy link
Member Author

ashb commented Oct 16, 2024

This is very much at the "boring ground work stage" - once we've got this covered we can add some of the execution changes which is not of the n"execution interface" side where it gets fun

Copy link
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments. In general looks great!

A bit of a challenge to review such a big PR - and I assume it is just the starting :-D - if possible would be cool to split this a bit up for better review, e.g.

  • One PR just the skeleton and AbstractOperator or so
  • One PR for BaseOperator
  • One PR for DAG only
  • Maybe one for Nodes/TaskGroup etc clubbing the rest together.

Anyway after some time was able to digest. Would offer also a full review if needed. And please don't take my early comments too serious more or less thinking out loud.

airflow/models/dag.py Outdated Show resolved Hide resolved
airflow/task/priority_strategy.py Show resolved Hide resolved
task_sdk/src/airflow/sdk/__init__.py Show resolved Hide resolved
task_sdk/src/airflow/sdk/exceptions.py Outdated Show resolved Hide resolved
uv.lock Outdated Show resolved Hide resolved
task_sdk/src/airflow/sdk/__init__.py Outdated Show resolved Hide resolved
task_sdk/src/airflow/sdk/definitions/abstractoperator.py Outdated Show resolved Hide resolved
task_sdk/src/airflow/sdk/definitions/dag.py Outdated Show resolved Hide resolved
task_sdk/src/airflow/sdk/definitions/mixins.py Outdated Show resolved Hide resolved
uv.lock Outdated Show resolved Hide resolved
uv.lock Outdated Show resolved Hide resolved
@ashb
Copy link
Member Author

ashb commented Oct 17, 2024

@kaxil @jscheffl I've just pushed latest changes to this. Probably not worth looking at it again until I've finished it and have a decent idea that the tests are passing locally, but in the last commit I've just pushed I have removed the old code I've ported over, so it might be slightly clearer where I've just moved code.

@ashb

This comment was marked as outdated.

@ashb ashb force-pushed the task-sdk-first-code branch 3 times, most recently from c0a7b96 to fd1085d Compare October 22, 2024 14:42
@kaxil kaxil force-pushed the task-sdk-first-code branch 5 times, most recently from 29f9cda to d4e015a Compare October 23, 2024 12:32
@ashb ashb force-pushed the task-sdk-first-code branch 3 times, most recently from 03282b4 to 11e4304 Compare October 28, 2024 22:42
@ashb

This comment was marked as outdated.

kaxil added a commit to astronomer/airflow that referenced this pull request Oct 29, 2024
While debugging test failures on apache#43076, found that
this docstring was wrong, most likely a copy/paste error of `ti._handle_failure`
kaxil added a commit that referenced this pull request Oct 29, 2024
While debugging test failures on #43076, found that
this docstring was wrong, most likely a copy/paste error of `ti._handle_failure`
@ashb ashb added the legacy api Whether legacy API changes should be allowed in PR label Oct 29, 2024
airflow/models/dag.py Show resolved Hide resolved
@ashb
Copy link
Member Author

ashb commented Oct 30, 2024

There are lots more things to move over to the TaskSDK before AIP-72 will be complete which we will track in the project board, but since this is the big base, and slow to test due to unavoidable wide reaching changes we will merge this and follow up with future changes for the rest (things like Mapped operator, DagParam etc)

@kaxil kaxil merged commit d8c7d28 into main Oct 30, 2024
101 of 102 checks passed
@kaxil kaxil deleted the task-sdk-first-code branch October 30, 2024 18:21
@kaxil
Copy link
Member

kaxil commented Oct 30, 2024

Merging this, one of the failures around k8s test that took longer than an hour looks like a transient one:

Progress: airflow-python-3.9-v1.28.13   Error during running tests for Python 3.9, Kubernetes v1.28.13
Progress: airflow-python-3.10-v1.29.8   Image: "ghcr.io/apache/airflow/main/prod/python3.10-kubernetes" with ID "sha256:1547fde10197845f0938fd7d0fc5977273a4871e016c8102ce9c8eb33010d064" not [...]

If for some reason it fails on main too, we will debug it

kaxil added a commit to astronomer/airflow that referenced this pull request Oct 30, 2024
Fixing one of the TODOs: apache#43076

This was already addressed.
kaxil added a commit that referenced this pull request Oct 30, 2024
Fixing one of the TODOs: #43076

This was already addressed.
ellisms pushed a commit to ellisms/airflow that referenced this pull request Nov 13, 2024
While debugging test failures on apache#43076, found that
this docstring was wrong, most likely a copy/paste error of `ti._handle_failure`
ellisms pushed a commit to ellisms/airflow that referenced this pull request Nov 13, 2024
closes apache#43011

By "definition code" we mean anything needed at definition/parse time, leaving
anything to do with scheduling time decisions in Airflow's core.

Also in this PR I have _attempted_ to keep it to only porting defintiion code
for simple DAGs, leaving anything to do with mapped tasks or execution time in
core for now, but a few things "leaked" across.

And as the goal of this PR is to go from working state to working state some
of the code in Task SDK still imports from "core" (various types, enums or
helpers) that will need to be resolved before 3.0 release, but it is fine for
now.

I'm also aware that the class hierarchy with
airflow.models.baseoperator.BaseOperator (and to a lesser extend with DAG) in
particular is very messy right now, and we will need to think how we want to
add on the scheduling-time functions etc, as I'm not yet sold that having Core
Airflow depend upon the Task-SDK classes/import the code is the right
structure, but we can address that later

We will also need to addresses the rendered docs for the Task SDK in a future
PR -- the goal is that "anything" exposed on `airflow.sdk` directly is part of
the public API, but right now the renedered docs show DAG as
`airflow.sdk.definitions.dag.DAG` which is certainly not what we want users to
see.

Co-authored-by: Kaxil Naik <[email protected]>
ellisms pushed a commit to ellisms/airflow that referenced this pull request Nov 13, 2024
Fixing one of the TODOs: apache#43076

This was already addressed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:Scheduler including HA (high availability) scheduler area:task-sdk legacy api Whether legacy API changes should be allowed in PR
Development

Successfully merging this pull request may close these issues.

Extract dag definition object models to Task SDK - Phase 1
6 participants