-
Notifications
You must be signed in to change notification settings - Fork 14.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AIRFLOW-2932] GoogleCloudStorageHook - allow compression of file #3893
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work in general. Can you add a test for this?
@@ -37,6 +37,8 @@ class FileToGoogleCloudStorageOperator(BaseOperator): | |||
:type google_cloud_storage_conn_id: str | |||
:param mime_type: The mime-type string | |||
:type mime_type: str | |||
:type gzip: Allows for file to upload as gzip | |||
:param gzip: boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect docstring, you have mixed type
and param
. Replace it to:
:param gzip: Allows for file to upload as gzip
:type gzip: boolean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would also be good to add more detail to this parameter and also at Line 28 that says that optionally you can also compress the file before uploading. An example, would be good.
Codecov Report
@@ Coverage Diff @@
## master #3893 +/- ##
======================================
Coverage 75.5% 75.5%
======================================
Files 199 199
Lines 15949 15949
======================================
Hits 12043 12043
Misses 3906 3906 Continue to review full report at Codecov.
|
@neil90, Are you planning to update the PR with adding tests? |
Hi @xnuinside , sorry about that I have been swamped at work I will finish this task by the weekend my apologies. |
@kaxil and @xnuinside I have updated the operator and added test case, I used the test_file_to_wasb.py as a template. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@neil90 Two last comments, apart from that it looks good! 👍
airflow/contrib/hooks/gcs_hook.py
Outdated
@@ -172,7 +175,8 @@ def download(self, bucket, object, filename=None): | |||
return downloaded_file_bytes | |||
|
|||
# pylint:disable=redefined-builtin | |||
def upload(self, bucket, object, filename, mime_type='application/octet-stream'): | |||
def upload(self, bucket, object, filename, | |||
gzip=False, mime_type='application/octet-stream'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last comment, can you move the gzip
argument to the very end? Otherwise backward compatibility will be broken.
@@ -49,6 +52,7 @@ def __init__(self, | |||
bucket, | |||
google_cloud_storage_conn_id='google_cloud_default', | |||
mime_type='application/octet-stream', | |||
gzip=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last comment, can you move the gzip
argument to the very end? Otherwise backward compatibility will be broken.
I have made the changes. Let's wait for the CI to pass and it should be good to be merged :) |
Ohh thanks @kaxil sorry about that I was gonna try to get to today after work. |
…ache#3893) - Add gzip functionality to GoogleCloudStorageHook.upload - Resolve docstring mistype, added additional information to tell user that there is option to compress - Add test case for file_to_gcs
…ache#3893) - Add gzip functionality to GoogleCloudStorageHook.upload - Resolve docstring mistype, added additional information to tell user that there is option to compress - Add test case for file_to_gcs
…ache#3893) - Add gzip functionality to GoogleCloudStorageHook.upload - Resolve docstring mistype, added additional information to tell user that there is option to compress - Add test case for file_to_gcs
…ache#3893) - Add gzip functionality to GoogleCloudStorageHook.upload - Resolve docstring mistype, added additional information to tell user that there is option to compress - Add test case for file_to_gcs
- Add gzip functionality to GoogleCloudStorageHook.upload - Resolve docstring mistype, added additional information to tell user that there is option to compress - Add test case for file_to_gcs
…ache#3893) - Add gzip functionality to GoogleCloudStorageHook.upload - Resolve docstring mistype, added additional information to tell user that there is option to compress - Add test case for file_to_gcs
HI, is there a 2GB limit on the compressed .gz file that can be sent ? |
Make sure you have checked all steps below.
Jira
Description
Tests
Commits
Documentation
Code Quality
git diff upstream/master -u -- "*.py" | flake8 --diff