Lee-W commented on code in PR #37693: URL: https://github.com/apache/airflow/pull/37693#discussion_r1559301512
########## airflow/providers/google/cloud/sensors/dataflow.py: ########## @@ -276,26 +371,72 @@ def poke(self, context: Context) -> bool: location=self.location, ) - return self.callback(result) + return result if self.callback is None else self.callback(result) + + def execute(self, context: Context) -> Any: + """Airflow runs this method on the worker and defers using the trigger.""" + if not self.deferrable: + super().execute(context) + else: + self.defer( + timeout=self.execution_timeout, + trigger=DataflowJobMessagesTrigger( + job_id=self.job_id, + project_id=self.project_id, + location=self.location, + gcp_conn_id=self.gcp_conn_id, + poll_sleep=self.poll_interval, + impersonation_chain=self.impersonation_chain, + fail_on_terminal_state=self.fail_on_terminal_state, + ), + method_name="execute_complete", + ) + + def execute_complete(self, context: Context, event: dict[str, str | list]) -> Any: + """ + Execute this method when the task resumes its execution on the worker after deferral. + + If the trigger returns an event with success status - passes the event result to the callback function. + Returns the event result if no callback function is provided. + + If the trigger returns an event with error status - raises an exception. + """ + if event["status"] == "success": + self.log.info(event["message"]) + return event["result"] if self.callback is None else self.callback(event["result"]) + if self.soft_fail: Review Comment: ah yes, as this is handled in base sensor since 2.7.1 (introduced in https://github.com/apache/airflow/pull/33424/files#diff-7486f32e385d7ad0376cccda08d80e54939aa901a24616d11fb1f5cba6af7f83R285). Once the min_airflow_version of google provider has been upgraded to 2.7.1. We no longer need this section -- 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