-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
Replace external_trigger
check with DagRunType
#45961
base: main
Are you sure you want to change the base?
Replace external_trigger
check with DagRunType
#45961
Conversation
45cf835
to
9eef4f1
Compare
external_trigger
check with DagRunTypeexternal_trigger
check with DagRunType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also needs a newsfragment noting about the removal of it please
|
||
print(f"Dag information:{dag_id} Run id: {run_id} external trigger: {external_trigger}") | ||
print(f"Dag information:{dag_id} Run id: {run_id}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that it matters, but lets include the run_type here in its place.
|
||
def upgrade(): | ||
"""Apply remove external_trigger field.""" | ||
# ### commands auto generated by Alembic - please adjust! ### |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# ### commands auto generated by Alembic - please adjust! ### |
|
||
def downgrade(): | ||
"""Unapply remove external_trigger field.""" | ||
# ### commands auto generated by Alembic - please adjust! ### |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# ### commands auto generated by Alembic - please adjust! ### |
|
||
# ### end Alembic commands ### |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# ### end Alembic commands ### |
airflow/models/dagrun.py
Outdated
@@ -1227,11 +1217,11 @@ def _emit_true_scheduling_delay_stats_for_finished_state(self, finished_tis: lis | |||
rid of the outliers on the stats side through dashboards tooling. | |||
|
|||
Note that the stat will only be emitted for scheduler-triggered DAG runs | |||
(i.e. when ``external_trigger`` is *False* and ``clear_number`` is equal to 0). | |||
(i.e. when ``run_type`` is *MANUAL* and ``clear_number`` is equal to 0). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(i.e. when ``run_type`` is *MANUAL* and ``clear_number`` is equal to 0). | |
(i.e. when ``run_type`` is not *MANUAL* and ``clear_number`` is equal to 0). |
Though this brings up another question: How should this function deal with run_type==BACKFILL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding an externally_triggered_type in airflow.utils.types? Instead of checking run_type == DagRunType.MANUAL
, we could use run_type in externally_triggered_type
. WDYT?
externally_triggered_type: frozenset[DagRunType] = frozenset([DagRunType.BACKFILL_JOB, DagRunType.MANUAL, DagRunType.ASSET_TRIGGERED])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to look at what the intent here was, and how that maps on to the new dag run types. My guess is that when "external_trigger" was added, there was either scheduled, or external.
So Manual is clearly not scheduled, but what abouty Backfill runs? How should we treat those. And for that I delegate to @uranusjr and @dstandish boing flip 😄
providers/src/airflow/providers/standard/operators/latest_only.py
Outdated
Show resolved
Hide resolved
@@ -53,7 +54,7 @@ def choose_branch(self, context: Context) -> str | Iterable[str]: | |||
# If the DAG Run is externally triggered, then return without | |||
# skipping downstream tasks | |||
dag_run: DagRun = context["dag_run"] # type: ignore[assignment] | |||
if dag_run.external_trigger: | |||
if dag_run.run_type == DagRunType.MANUAL: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto here about BACKFILL. Need to decide how to handle this
a65904d
to
2fee34c
Compare
closes: #45932
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rst
or{issue_number}.significant.rst
, in newsfragments.