sunank200 commented on code in PR #42404:
URL: https://github.com/apache/airflow/pull/42404#discussion_r1848529847
##########
airflow/cli/commands/task_command.py:
##########
@@ -112,49 +147,48 @@ def _get_dag_run(
the logical date; otherwise use it as a run ID and set the logical date
to the current time.
"""
- if not exec_date_or_run_id and not create_if_necessary:
- raise ValueError("Must provide `exec_date_or_run_id` if not
`create_if_necessary`.")
- execution_date: pendulum.DateTime | None = None
- if exec_date_or_run_id:
- dag_run = DAG.fetch_dagrun(dag_id=dag.dag_id,
run_id=exec_date_or_run_id, session=session)
- if dag_run:
- return dag_run, False
- with suppress(ParserError, TypeError):
- execution_date = timezone.parse(exec_date_or_run_id)
- if execution_date:
- dag_run = DAG.fetch_dagrun(dag_id=dag.dag_id,
execution_date=execution_date, session=session)
- if dag_run:
+ if not logical_date_or_run_id and not create_if_necessary:
+ raise ValueError("Must provide `logical_date_or_run_id` if not
`create_if_necessary`.")
+
+ logical_date = None
+ if logical_date_or_run_id:
+ dag_run, logical_date =
_fetch_dag_run_from_run_id_or_logical_date_string(
+ dag_id=dag.dag_id,
+ value=logical_date_or_run_id,
+ session=session,
+ )
+ if dag_run is not None:
return dag_run, False
elif not create_if_necessary:
raise DagRunNotFound(
- f"DagRun for {dag.dag_id} with run_id or execution_date "
- f"of {exec_date_or_run_id!r} not found"
+ f"DagRun for {dag.dag_id} with run_id or logical_date "
+ f"of {logical_date_or_run_id!r} not found"
)
- if execution_date is not None:
- dag_run_execution_date = execution_date
+ if logical_date is not None:
+ dag_run_logical_date = logical_date
else:
- dag_run_execution_date = pendulum.instance(timezone.utcnow())
+ dag_run_logical_date = pendulum.instance(timezone.utcnow())
if create_if_necessary == "memory":
dag_run = DagRun(
dag_id=dag.dag_id,
- run_id=exec_date_or_run_id,
- execution_date=dag_run_execution_date,
-
data_interval=dag.timetable.infer_manual_data_interval(run_after=dag_run_execution_date),
+ run_id=logical_date_or_run_id,
+ logical_date=dag_run_logical_date,
+
data_interval=dag.timetable.infer_manual_data_interval(run_after=dag_run_logical_date),
triggered_by=DagRunTriggeredByType.CLI,
)
return dag_run, True
elif create_if_necessary == "db":
dag_run = dag.create_dagrun(
state=DagRunState.QUEUED,
- execution_date=dag_run_execution_date,
+ logical_date=dag_run_logical_date,
run_id=_generate_temporary_run_id(),
-
data_interval=dag.timetable.infer_manual_data_interval(run_after=dag_run_execution_date),
+
data_interval=dag.timetable.infer_manual_data_interval(run_after=dag_run_logical_date),
session=session,
triggered_by=DagRunTriggeredByType.CLI,
)
- return dag_run, True
+ return dag_run, True # type: ignore[return-value]
Review Comment:
removed it
--
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]