You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "sunank200 (via GitHub)" <gi...@apache.org> on 2023/06/07 06:38:26 UTC

[GitHub] [airflow] sunank200 commented on a diff in pull request #31018: Add deferrable mode for S3KeySensor

sunank200 commented on code in PR #31018:
URL: https://github.com/apache/airflow/pull/31018#discussion_r1220946091


##########
airflow/providers/amazon/aws/sensors/s3.py:
##########
@@ -131,6 +135,43 @@ def poke(self, context: Context):
         else:
             return all(self._check_key(key) for key in self.bucket_key)
 
+    def execute(self, context: Context) -> None:
+        """
+        Defers to Trigger class to poll for state of the job run until
+        it reaches a failure state or success state
+        """
+        if not self.deferrable:
+            super().execute(context)
+        else:
+            if not self.poke(context=context):
+                self.defer(
+                    timeout=timedelta(seconds=self.timeout),
+                    trigger=S3KeyTrigger(
+                        bucket_name=cast(str, self.bucket_name),
+                        bucket_key=self.bucket_key,
+                        wildcard_match=self.wildcard_match,
+                        check_fn=self.check_fn,

Review Comment:
   Thanks @syedahsn I have changed the logic for `check_fn` [here](https://github.com/apache/airflow/pull/31018/commits/d36487d24c5bbb9ab43e8b503ea1842853332be7) Please check



-- 
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