You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2023/01/10 12:14:34 UTC

[GitHub] [airflow] ashb commented on a diff in pull request #28763: Add deferrable ``GCSObjectExistenceSensorAsync``

ashb commented on code in PR #28763:
URL: https://github.com/apache/airflow/pull/28763#discussion_r1065712585


##########
airflow/providers/google/cloud/sensors/gcs.py:
##########
@@ -94,6 +95,55 @@ def poke(self, context: Context) -> bool:
         return hook.exists(self.bucket, self.object, self.retry)
 
 
+class GCSObjectExistenceAsyncSensor(GCSObjectExistenceSensor):
+    """
+    Checks for the existence of a file in Google Cloud Storage.
+
+    :param bucket: The Google Cloud Storage bucket where the object is.
+    :param object: The name of the object to check in the Google cloud storage bucket.
+    :param google_cloud_conn_id: The connection ID to use when connecting to Google Cloud Storage.
+    :param delegate_to: The account to impersonate using domain-wide delegation of authority,
+        if any. For this to work, the service account making the request must have
+        domain-wide delegation enabled.
+    :param impersonation_chain: Optional service account to impersonate using short-term
+        credentials, or chained list of accounts required to get the access_token
+        of the last account in the list, which will be impersonated in the request.
+        If set as a string, the account must grant the originating account
+        the Service Account Token Creator IAM role.
+        If set as a sequence, the identities from the list must grant
+        Service Account Token Creator IAM role to the directly preceding identity, with first
+        account from the list granting this role to the originating account (templated).
+    """
+
+    def execute(self, context: Context) -> None:
+        """Airflow runs this method on the worker and defers using the trigger."""
+        self.defer(
+            timeout=timedelta(seconds=self.timeout),
+            trigger=GCSBlobTrigger(
+                bucket=self.bucket,
+                object_name=self.object,
+                poke_interval=self.poke_interval,
+                google_cloud_conn_id=self.google_cloud_conn_id,
+                hook_params={
+                    "delegate_to": self.delegate_to,
+                    "impersonation_chain": self.impersonation_chain,
+                },
+            ),
+            method_name="execute_complete",
+        )
+
+    def execute_complete(self, context: dict[str, Any], event: dict[str, str]) -> str:

Review Comment:
   I think?
   ```suggestion
       def execute_complete(self, context: Context, event: dict[str, str]) -> str:
   ```



-- 
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-unsubscribe@airflow.apache.org

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