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 01:48:34 UTC

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

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

 ##########
 File path: airflow/contrib/hooks/gcs_hook.py
 ##########
 @@ -162,24 +162,20 @@ def download(self, bucket, object, filename=None):
         :param filename: If set, a local file path where the file should be written to.
         :type filename: str
         """
-        service = self.get_conn()
-        downloaded_file_bytes = service \
-            .objects() \
-            .get_media(bucket=bucket, object=object) \
-            .execute()
+        client = self.get_conn()
+        bucket = client.get_bucket(bucket)
+        blob = bucket.blob(blob_name=object)
 
-        # Write the file to local file path, if requested.
         if filename:
-            write_argument = 'wb' if isinstance(downloaded_file_bytes, bytes) else 'w'
-            with open(filename, write_argument) as file_fd:
-                file_fd.write(downloaded_file_bytes)
-
-        return downloaded_file_bytes
+            blob.download_to_filename(filename)
+            self.log.info('File downloaded to %s', filename)
+        # MAX XCOM Size is 48KB
+        # https://github.com/apache/airflow/pull/1618#discussion_r68249677
+        if blob.size < 49344:
 
 Review comment:
   Done

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