gopidesupavan commented on code in PR #52431:
URL: https://github.com/apache/airflow/pull/52431#discussion_r2178711514
##########
providers/standard/src/airflow/providers/standard/sensors/external_task.py:
##########
@@ -534,7 +534,9 @@ def _handle_execution_date_fn(self, context) -> Any:
from airflow.utils.operator_helpers import make_kwargs_callable
# Remove "logical_date" because it is already a mandatory positional
argument
- logical_date = context["logical_date"]
+ logical_date = (
Review Comment:
I think it would be better to move this logical_date get from context to a
function and work out and return logical_date. there is some duplicity, this
line and here
https://github.com/apache/airflow/pull/52431/files#diff-cd0a81a3fe4e14f46d41d402eabcb273554245c7e676e549b8b84030a99d4870R256,
can you do something like this please? and you can call the function with
context?
```
def _get_logical_date(self, context):
if AIRFLOW_V_3_0_PLUS:
logical_date = context.get("logical_date")
dag_run = context.get("dag_run")
if not (logical_date or (dag_run and dag_run.run_after)):
raise ValueError(
"Either `logical_date` or `run_after` should be provided
in the task context"
)
return logical_date or dag_run.run_after
else:
execution_date = context.get("execution_date")
if not execution_date:
raise ValueError(
"Either `execution_date` should be provided in the task
context"
)
return execution_date
```
--
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]