-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Fix logical_date
handling for using exeuction_date_fn
in ExternalTaskSensor
#52237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes the logical date handling for the ExternalTaskSensor by updating the usage of execution_date_fn.
- Passes logical_date as an explicit parameter to _handle_execution_date_fn rather than extracting it from the context
- Updates the function signature and removes the redundant extraction of logical_date from the context
Comments suppressed due to low confidence (1)
providers/standard/src/airflow/providers/standard/sensors/external_task.py:532
- Update the docstring for _handle_execution_date_fn to include and describe the new 'logical_date' parameter, ensuring the documentation accurately reflects the updated function signature.
def _handle_execution_date_fn(self, logical_date, context) -> Any:
33549ca
to
c68ed07
Compare
@@ -529,7 +529,7 @@ def get_external_task_group_task_ids(self, session, dttm_filter): | |||
dttm_filter, self.external_task_group_id, self.external_dag_id, session | |||
) | |||
|
|||
def _handle_execution_date_fn(self, context) -> Any: | |||
def _handle_execution_date_fn(self, logical_date, context) -> Any: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this method is purely for backwar compatibility and shouldn't have this breaking change here
cc: @kaxil what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bugraoz93 Thanks for review.
IMO, the backward compatibility is already handled in caller function, it is better to keep consistent and align with the caller.
airflow/providers/standard/src/airflow/providers/standard/sensors/external_task.py
Lines 261 to 273 in 3576530
def _get_dttm_filter(self, context): | |
logical_date = context.get("logical_date") | |
if AIRFLOW_V_3_0_PLUS: | |
if logical_date is None: | |
dag_run = context.get("dag_run") | |
if TYPE_CHECKING: | |
assert dag_run | |
logical_date = dag_run.run_after | |
if self.execution_delta: | |
dttm = logical_date - self.execution_delta | |
elif self.execution_date_fn: | |
dttm = self._handle_execution_date_fn(logical_date=logical_date, context=context) |
c68ed07
to
34da955
Compare
34da955
to
3576530
Compare
TBR |
closes #52236