kaxil commented on issue #48897:
URL: https://github.com/apache/airflow/issues/48897#issuecomment-2785785139
@uranusjr @ashb Thoughts on the following patch to make this working? An
assumption here is DataInterval won't be None!
```diff
diff --git
a/providers/standard/src/airflow/providers/standard/operators/latest_only.py
b/providers/standard/src/airflow/providers/standard/operators/latest_only.py
index 930d594756..69d84d153a 100644
---
a/providers/standard/src/airflow/providers/standard/operators/latest_only.py
+++
b/providers/standard/src/airflow/providers/standard/operators/latest_only.py
@@ -25,10 +25,12 @@ from typing import TYPE_CHECKING
import pendulum
from airflow.providers.standard.operators.branch import BaseBranchOperator
+from airflow.timetables.base import TimeRestriction, DataInterval
from airflow.utils.types import DagRunType
if TYPE_CHECKING:
- from airflow.models import DAG, DagRun
+ from airflow.sdk import DAG
+ from airflow.sdk.types import DagRunProtocol as DagRun
try:
from airflow.sdk.definitions.context import Context
@@ -59,7 +61,13 @@ class LatestOnlyOperator(BaseBranchOperator):
return
list(context["task"].get_direct_relative_ids(upstream=False))
dag: DAG = context["dag"] # type: ignore[assignment]
- next_info =
dag.next_dagrun_info(dag.get_run_data_interval(dag_run), restricted=False)
+ time_restriction = TimeRestriction(earliest=None, latest=None,
catchup=True)
+ next_info = dag.timetable.next_dagrun_info(
+ last_automated_data_interval=DataInterval(
+ start=dag_run.data_interval_start,
end=dag_run.data_interval_end
+ ),
+ restriction=time_restriction,
+ )
now = pendulum.now("UTC")
if next_info is 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]