boushphong commented on code in PR #30117:
URL: https://github.com/apache/airflow/pull/30117#discussion_r1144350686
##########
airflow/cli/commands/dag_command.py:
##########
@@ -296,36 +295,22 @@ def dag_next_execution(args):
print("[INFO] Please be reminded this DAG is PAUSED now.",
file=sys.stderr)
with create_session() as session:
- max_date_subq = (
- session.query(func.max(DagRun.execution_date).label("max_date"))
- .filter(DagRun.dag_id == dag.dag_id)
- .subquery()
- )
- max_date_run: DagRun | None = (
- session.query(DagRun)
- .filter(DagRun.dag_id == dag.dag_id, DagRun.execution_date ==
max_date_subq.c.max_date)
- .one_or_none()
- )
-
- if max_date_run is None:
- print("[WARN] Only applicable when there is execution record found
for the DAG.", file=sys.stderr)
+ last_parsed_dag: DagModel =
session.query(DagModel).filter(DagModel.dag_id == dag.dag_id).one()
+
+ next_interval = dag.get_next_data_interval(last_parsed_dag)
+ for i in range(args.num_executions):
+ if i != 0:
+ next_info = dag.next_dagrun_info(next_interval, restricted=False)
+ next_interval = None if next_info is None else
next_info.data_interval
Review Comment:
I think the `range(1, num)` way would require handling and printing `None`
in 2 different places. 1 before the loop and 1 more within the for loop itself.
I just think the handling all those cases within the loop would be more
elegant. But if you insist ... 😅
--
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]