jscheffl commented on code in PR #49554:
URL: https://github.com/apache/airflow/pull/49554#discussion_r2054789156
##########
providers/standard/src/airflow/providers/standard/operators/latest_only.py:
##########
@@ -62,54 +63,65 @@ def choose_branch(self, context: Context) -> str |
Iterable[str]:
dag_run: DagRun = context["dag_run"] # type: ignore[assignment]
if dag_run.run_type == DagRunType.MANUAL:
self.log.info("Manually triggered DAG_Run: allowing execution to
proceed.")
- return
list(context["task"].get_direct_relative_ids(upstream=False))
+ return list(self.get_direct_relative_ids(upstream=False))
- next_info = self._get_next_run_info(context, dag_run)
- now = pendulum.now("UTC")
+ dates = self._get_compare_dates(dag_run)
- if next_info is None:
+ if dates is None:
self.log.info("Last scheduled execution: allowing execution to
proceed.")
- return
list(context["task"].get_direct_relative_ids(upstream=False))
+ return list(self.get_direct_relative_ids(upstream=False))
- left_window, right_window = next_info.data_interval
+ now = pendulum.now("UTC")
+ left_window, right_window = dates
self.log.info(
"Checking latest only with left_window: %s right_window: %s now:
%s",
left_window,
right_window,
now,
)
- if left_window == right_window:
- self.log.info(
- "Zero-length interval [%s, %s) from timetable (%s); treating
current run as latest.",
- left_window,
- right_window,
- self.dag.timetable.__class__,
- )
- return
list(context["task"].get_direct_relative_ids(upstream=False))
-
if not left_window < now <= right_window:
self.log.info("Not latest execution, skipping downstream.")
# we return an empty list, thus the parent BaseBranchOperator
# won't exclude any downstream tasks from skipping.
return []
- self.log.info("Latest, allowing execution to proceed.")
- return list(context["task"].get_direct_relative_ids(upstream=False))
- def _get_next_run_info(self, context: Context, dag_run: DagRun) ->
DagRunInfo | None:
- dag: DAG = context["dag"] # type: ignore[assignment]
+ self.log.info("Latest, allowing execution to proceed.")
+ return list(self.get_direct_relative_ids(upstream=False))
+ def _get_compare_dates(self, dag_run: DagRun) -> tuple[DateTime, DateTime]
| None:
+ dagrun_date: DateTime
if AIRFLOW_V_3_0_PLUS:
- from airflow.timetables.base import DataInterval, TimeRestriction
+ dagrun_date = dag_run.logical_date or dag_run.run_after
+ else:
+ dagrun_date = dag_run.logical_date
- time_restriction = TimeRestriction(earliest=None, latest=None,
catchup=True)
- current_interval = DataInterval(start=dag_run.data_interval_start,
end=dag_run.data_interval_end)
+ # breakpoint()
Review Comment:
I assume this is a testing leftover/glitch?
```suggestion
```
--
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]