uranusjr commented on code in PR #38570:
URL: https://github.com/apache/airflow/pull/38570#discussion_r1544011206


##########
airflow/cli/commands/task_command.py:
##########
@@ -149,23 +150,27 @@ def _get_dag_run(
             execution_date=dag_run_execution_date,
             run_id=_generate_temporary_run_id(),
             
data_interval=dag.timetable.infer_manual_data_interval(run_after=dag_run_execution_date),
-            session=session,
+            **session_kwarg,
         )
         return dag_run, True
     raise ValueError(f"unknown create_if_necessary value: 
{create_if_necessary!r}")
 
 
-@provide_session
 def _get_ti(
     task: Operator,
     map_index: int,
     *,
     exec_date_or_run_id: str | None = None,
     pool: str | None = None,
     create_if_necessary: CreateIfNecessary = False,
-    session: Session = NEW_SESSION,
+    session: Session | None = None,
 ) -> tuple[TaskInstance | TaskInstancePydantic, bool]:
     """Get the task instance through DagRun.run_id, if that fails, get the TI 
the old way."""
+    # this is required by AIP-44; if there's a session here, let's use it
+    # if it's None, don't pass it (because @provide_session does not check
+    # whether the provided session is None or not
+    session_kwarg = {"session": session} if session else {}

Review Comment:
   Not in love with this repeated pattern.



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to