Ajay9704 commented on code in PR #61274:
URL: https://github.com/apache/airflow/pull/61274#discussion_r2838308369
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2311,7 +2311,10 @@ def _schedule_dag_run(
select(TI)
.where(TI.dag_id == dag_run.dag_id)
.where(TI.run_id == dag_run.run_id)
- .where(TI.state.in_(State.unfinished))
+ .where(TI.state.in_(State.unfinished) |
(TI.state.is_(None)))
+ ).all()
+ last_unfinished_ti = (
+ max(unfinished_task_instances, key=lambda ti:
ti.start_date, default=None)
Review Comment:
last_unfinished_ti = max(
unfinished_task_instances, key=lambda ti: ti.start_date,
default=None
##########
airflow-core/src/airflow/models/dagrun.py:
##########
@@ -1215,22 +1215,36 @@ def recalculate(self) -> _UnfinishedStates:
self.set_state(DagRunState.FAILED)
self.notify_dagrun_state_changed(msg="task_failure")
- if execute_callbacks and dag.has_on_failure_callback:
- self.handle_dag_callback(dag=cast("SDKDAG", dag),
success=False, reason="task_failure")
- elif dag.has_on_failure_callback:
- callback = DagCallbackRequest(
- filepath=self.dag_model.relative_fileloc,
- dag_id=self.dag_id,
- run_id=self.run_id,
- bundle_name=self.dag_model.bundle_name,
- bundle_version=self.bundle_version,
- context_from_server=DagRunContext(
- dag_run=self,
- last_ti=self.get_last_ti(dag=dag, session=session),
- ),
- is_failure_callback=True,
- msg="task_failure",
+ if dag.has_on_failure_callback:
+ ti_causing_failure = (
+ max(
+ (ti for ti in tis_for_dagrun_state
+ if ti.state == TaskInstanceState.FAILED and
ti.end_date is not None),
+ key=lambda ti: ti.end_date,
+ default=None
+ )
Review Comment:
ti_causing_failure = max(
(
ti
for ti in tis_for_dagrun_state
if ti.state == TaskInstanceState.FAILED and
ti.end_date is not None
),
key=lambda ti: ti.end_date,
default=None,
\> fix as per logs
"-" ti_causing_failure = (
"-" max(
"-" (ti for ti in tis_for_dagrun_state
"-" if ti.state == TaskInstanceState.FAILED and
ti.end_date is not None),
"-" key=lambda ti: ti.end_date,
"-" default=None
"-" )
"+" ti_causing_failure = max(
"+" (
"+" ti
"+" for ti in tis_for_dagrun_state
"+" if ti.state == TaskInstanceState.FAILED and
ti.end_date is not None
"+" ),
"+" key=lambda ti: ti.end_date,
"+" default=None,
)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]