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 2019/04/08 11:29:04 UTC

[GitHub] [airflow] potiuk commented on a change in pull request #5054: [AIRFLOW-4255] Replace Discovery based api with client based for GCS

potiuk commented on a change in pull request #5054: [AIRFLOW-4255] Replace Discovery based api with client based for GCS
URL: https://github.com/apache/airflow/pull/5054#discussion_r272993210
 
 

 ##########
 File path: airflow/contrib/hooks/gcs_hook.py
 ##########
 @@ -287,57 +236,41 @@ def is_updated_after(self, bucket, object, ts):
         :param ts: The timestamp to check against.
         :type ts: datetime.datetime
         """
-        service = self.get_conn()
-        try:
-            response = (service
-                        .objects()
-                        .get(bucket=bucket, object=object)
-                        .execute())
-
-            if 'updated' in response:
-                import dateutil.parser
-                import dateutil.tz
+        client = self.get_conn()
+        bucket = storage.Bucket(client=client, name=bucket)
+        blob = bucket.get_blob(blob_name=object)
+        blob.reload()
 
-                if not ts.tzinfo:
-                    ts = ts.replace(tzinfo=dateutil.tz.tzutc())
+        blob_update_time = blob.updated
 
-                updated = dateutil.parser.parse(response['updated'])
-                self.log.info("Verify object date: %s > %s", updated, ts)
+        if blob_update_time is not None:
+            import dateutil.tz
 
-                if updated > ts:
-                    return True
+            if not ts.tzinfo:
+                ts = ts.replace(tzinfo=dateutil.tz.tzutc())
 
-        except HttpError as ex:
-            if ex.resp['status'] != '404':
-                raise
+            self.log.info("Verify object date: %s > %s", blob_update_time, ts)
 
-        return False
+            if blob_update_time > ts:
+                return True
+            else:
+                return False
 
 Review comment:
   'return False' is missing for if blob_udate_time is None

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services