Always provide a relevant TI context in Dag callback#61274
Always provide a relevant TI context in Dag callback#61274eladkal merged 80 commits intoapache:mainfrom
Conversation
|
I want to get some feedback on the behavior, whether it's the desired one or if anything can be made better. I will update the docs to explain the behavior of passed TIs to dag callbacks. |
Nataneljpwd
left a comment
There was a problem hiding this comment.
Looks good, I have left a few comments on the changes, overall, great find!
|
Slightly confused about the milestone |
I'll set it for 3.1.9 but this is subject to confirmation from the release manager of 3.1.9 |
|
Since technically, this is a chance in behavior, let's put it in 3.2, can you add a newsfragment too please @Asquator : https://github.com/apache/airflow/tree/main/airflow-core/newsfragments |
Co-authored-by: Elad Kalif <45845474+eladkal@users.noreply.github.com>
|
static checks are failing |
|
The test is failing because my newsfragment has multiple lines, and it can't... Do I change the type to Generally I'm not sure why we have to limit this to just one line... I don't think it's a |
|
Newsfragment validation should pass now. |
|
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
* Skeleton solution * Handle more cases * Refactored None handling * Fixed task name * Materialized tasks for double iteration * Use default argument in min * Use default argument in max * Use default argument in max * Changed end_date to start_date * Fix logic for on_success_callback * Handle the case where ti has no start_date * Logic for DAG testing * Cosmetics * Simplified logic * Pass last succeeded TI on success * Added template method * Cosmetics * More cosmetics * Lint * Added default keys for mypy check to succeed * Updated the docs * Fixed timezone aware datetime comparison * Clarified Dag run timeouts in the docs * Fix condition to look for failures across all relevant TIs * Mypy & ruff * Timezone awareness for deadlocked tasks case * Select from all tis for success callback * Improved deadlock callback logic * Mypy & ruff * Made the test more explicit * Format * Updated backward docs version to 3.1.9 according to milestone * Revert "Updated backward docs version to 3.1.9 according to milestone" This reverts commit 4defea7. * Type hint Thank you Co-authored-by: Kaxil Naik <kaxilnaik@gmail.com> * Reapply "Updated backward docs version to 3.1.9 according to milestone" This reverts commit a31476a. * Removed redundant iter() call * Removed redundant logic in deadlock case * Updated backward docs version to 3.2.0 according to milestone Co-authored-by: Elad Kalif <45845474+eladkal@users.noreply.github.com> * Added a newsfragment entry * Removed trailing whitespaces * Shortened nesfragment to just one line --------- Co-authored-by: TheoS <asquator@proton.me> Co-authored-by: Kaxil Naik <kaxilnaik@gmail.com> Co-authored-by: Elad Kalif <45845474+eladkal@users.noreply.github.com>
* Skeleton solution * Handle more cases * Refactored None handling * Fixed task name * Materialized tasks for double iteration * Use default argument in min * Use default argument in max * Use default argument in max * Changed end_date to start_date * Fix logic for on_success_callback * Handle the case where ti has no start_date * Logic for DAG testing * Cosmetics * Simplified logic * Pass last succeeded TI on success * Added template method * Cosmetics * More cosmetics * Lint * Added default keys for mypy check to succeed * Updated the docs * Fixed timezone aware datetime comparison * Clarified Dag run timeouts in the docs * Fix condition to look for failures across all relevant TIs * Mypy & ruff * Timezone awareness for deadlocked tasks case * Select from all tis for success callback * Improved deadlock callback logic * Mypy & ruff * Made the test more explicit * Format * Updated backward docs version to 3.1.9 according to milestone * Revert "Updated backward docs version to 3.1.9 according to milestone" This reverts commit 4defea7. * Type hint Thank you Co-authored-by: Kaxil Naik <kaxilnaik@gmail.com> * Reapply "Updated backward docs version to 3.1.9 according to milestone" This reverts commit a31476a. * Removed redundant iter() call * Removed redundant logic in deadlock case * Updated backward docs version to 3.2.0 according to milestone Co-authored-by: Elad Kalif <45845474+eladkal@users.noreply.github.com> * Added a newsfragment entry * Removed trailing whitespaces * Shortened nesfragment to just one line --------- Co-authored-by: TheoS <asquator@proton.me> Co-authored-by: Kaxil Naik <kaxilnaik@gmail.com> Co-authored-by: Elad Kalif <45845474+eladkal@users.noreply.github.com>
* Skeleton solution * Handle more cases * Refactored None handling * Fixed task name * Materialized tasks for double iteration * Use default argument in min * Use default argument in max * Use default argument in max * Changed end_date to start_date * Fix logic for on_success_callback * Handle the case where ti has no start_date * Logic for DAG testing * Cosmetics * Simplified logic * Pass last succeeded TI on success * Added template method * Cosmetics * More cosmetics * Lint * Added default keys for mypy check to succeed * Updated the docs * Fixed timezone aware datetime comparison * Clarified Dag run timeouts in the docs * Fix condition to look for failures across all relevant TIs * Mypy & ruff * Timezone awareness for deadlocked tasks case * Select from all tis for success callback * Improved deadlock callback logic * Mypy & ruff * Made the test more explicit * Format * Updated backward docs version to 3.1.9 according to milestone * Revert "Updated backward docs version to 3.1.9 according to milestone" This reverts commit 4defea7. * Type hint Thank you Co-authored-by: Kaxil Naik <kaxilnaik@gmail.com> * Reapply "Updated backward docs version to 3.1.9 according to milestone" This reverts commit a31476a. * Removed redundant iter() call * Removed redundant logic in deadlock case * Updated backward docs version to 3.2.0 according to milestone Co-authored-by: Elad Kalif <45845474+eladkal@users.noreply.github.com> * Added a newsfragment entry * Removed trailing whitespaces * Shortened nesfragment to just one line --------- Co-authored-by: TheoS <asquator@proton.me> Co-authored-by: Kaxil Naik <kaxilnaik@gmail.com> Co-authored-by: Elad Kalif <45845474+eladkal@users.noreply.github.com>
This PR strives to make sense out of TI contexts passed to Dag callbacks. Rather than always passing the last task lexicogrpahically, the new logic passes the last "relevant" task to Dag's resulting state.
Behavior outline:
There's a possibility it's better to pass no
"ti"key at all to Dag-level contexts, or provide aNonevalue. This might break the existing code even more, so currently the PR only improves the relevancy of the task passed. Yet we should consider the option of not passing any task instance in the future.Was generative AI tooling used to co-author this PR?
deepwiki.com was used to find the relevant logic in the repo, and an embedded chat was used to make a skeleton for tests.
{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.