Skip to content

Ensure that dag.partial_subset doesn't mutate task group properties#30129

Merged
ashb merged 4 commits into
apache:mainfrom
astronomer:partial-subset-taskgroup-deepcopy
Mar 15, 2023
Merged

Ensure that dag.partial_subset doesn't mutate task group properties#30129
ashb merged 4 commits into
apache:mainfrom
astronomer:partial-subset-taskgroup-deepcopy

Conversation

@ashb

@ashb ashb commented Mar 15, 2023

Copy link
Copy Markdown
Member

We had a few properties that we failed to deepcopy that we should have. To fix that in such a way that we don't miss things in the future I've converted it to use deepcopy everything by default and exclude children and parent_group.

This also made me notice that we were not correctly setting parent_group after partial_subset anymore -- it clearly hasn't mattered, but we were setting a now-unused _parent_group attribute.

Fixes #26059

We had a few properties that we failed to copy that we should have. To
fix that in such a way that we don't miss things in the future I've
converted it to use deepcopy everything by default and exclude
`children` and `parent_group`.

This also made me notice that we were not correctly setting
`parent_group` after partial_subset anymore -- it clearly hasn't mattered, but
we were setting a now-unused `_parent_group` attribute.
@ashb
ashb requested review from XD-DENG and kaxil as code owners March 15, 2023 16:35
@ashb ashb added this to the Airflow 2.5.3 milestone Mar 15, 2023
@ashb

ashb commented Mar 15, 2023

Copy link
Copy Markdown
Member Author

Marked it for 2.5.3 in case there is one before 2.6

@ashb

This comment was marked as resolved.

Comment thread airflow/models/dag.py Outdated
@ashb

ashb commented Mar 15, 2023

Copy link
Copy Markdown
Member Author

Okay yeah, I've totally misunderstood how deepcopy memo works on classes (It only works on instances, not on individual fields of the instance.) Rethinking

@ashb

ashb commented Mar 15, 2023

Copy link
Copy Markdown
Member Author

Slightly more complex now, but it errs on the side of not breaking things in future (while still be quick now)

@ashb
ashb requested review from bbovenzi and kaxil March 15, 2023 18:23
Comment thread airflow/models/dag.py Outdated

@bbovenzi bbovenzi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Local testing works for me now. Including very large dags.

Comment thread airflow/models/dag.py Outdated
Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
@ashb
ashb merged commit 76a884c into apache:main Mar 15, 2023
@ashb
ashb deleted the partial-subset-taskgroup-deepcopy branch March 15, 2023 20:05
@pierrejeambrun pierrejeambrun added the type:bug-fix Changelog: Bug Fixes label Mar 22, 2023
pierrejeambrun pushed a commit that referenced this pull request Mar 23, 2023
…#30129)

We had a few properties that we failed to copy that we should have. To
fix that in such a way that we don't miss things in the future I've
converted it to use deepcopy everything by default and exclude
`children` and `parent_group`.

This also made me notice that we were not correctly setting
`parent_group` after partial_subset anymore -- it clearly hasn't mattered, but
we were setting a now-unused `_parent_group` attribute.

(cherry picked from commit 76a884c)
pierrejeambrun pushed a commit that referenced this pull request Mar 24, 2023
…#30129)

We had a few properties that we failed to copy that we should have. To
fix that in such a way that we don't miss things in the future I've
converted it to use deepcopy everything by default and exclude
`children` and `parent_group`.

This also made me notice that we were not correctly setting
`parent_group` after partial_subset anymore -- it clearly hasn't mattered, but
we were setting a now-unused `_parent_group` attribute.

(cherry picked from commit 76a884c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Graph view] After clearing the task (and its downstream tasks) in a task group the task group becomes disconnected from the dag

5 participants