Skip to content

Commit

Permalink
Bugfix: Fix rendering of object_name in ``GCSToLocalFilesystemOpe…
Browse files Browse the repository at this point in the history
…rator`` (#15487)

#14918 made coms consistency changes
where the template_fields was changed for ``GCSToLocalFilesystemOperator``.

While the change was correct since``object`` param was deprecated, the
instance attribute wasn't updated hence you see this error:

```
AttributeError: 'GCSToLocalFilesystemOperator' object has no attribute 'object_name'
```
  • Loading branch information
kaxil committed Apr 22, 2021
1 parent 4c8a32c commit 3b9a918
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions airflow/providers/google/cloud/transfers/gcs_to_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,26 +119,26 @@ def __init__(

super().__init__(**kwargs)
self.bucket = bucket
self.object = object_name
self.object_name = object_name
self.filename = filename # noqa
self.store_to_xcom_key = store_to_xcom_key # noqa
self.gcp_conn_id = gcp_conn_id
self.delegate_to = delegate_to
self.impersonation_chain = impersonation_chain

def execute(self, context):
self.log.info('Executing download: %s, %s, %s', self.bucket, self.object, self.filename)
self.log.info('Executing download: %s, %s, %s', self.bucket, self.object_name, self.filename)
hook = GCSHook(
gcp_conn_id=self.gcp_conn_id,
delegate_to=self.delegate_to,
impersonation_chain=self.impersonation_chain,
)

if self.store_to_xcom_key:
file_bytes = hook.download(bucket_name=self.bucket, object_name=self.object)
file_bytes = hook.download(bucket_name=self.bucket, object_name=self.object_name)
if sys.getsizeof(file_bytes) < MAX_XCOM_SIZE:
context['ti'].xcom_push(key=self.store_to_xcom_key, value=str(file_bytes))
else:
raise AirflowException('The size of the downloaded file is too large to push to XCom!')
else:
hook.download(bucket_name=self.bucket, object_name=self.object, filename=self.filename)
hook.download(bucket_name=self.bucket, object_name=self.object_name, filename=self.filename)

0 comments on commit 3b9a918

Please sign in to comment.