-
Notifications
You must be signed in to change notification settings - Fork 166
feat: Adding support of single shot download #1493
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
Changes from all commits
0871189
e6d704f
e45b18b
1c48b6c
2a04a4f
40dd696
2d12b6d
37e59d1
0ce88e7
fb07ad6
b7b6b6b
2ba5b56
a4ad641
f5d467d
7e8f213
be281fa
4df2f87
d314b59
a960858
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -987,6 +987,7 @@ def _do_download( | |
| timeout=_DEFAULT_TIMEOUT, | ||
| checksum="auto", | ||
| retry=DEFAULT_RETRY, | ||
| single_shot_download=False, | ||
| ): | ||
| """Perform a download without any error handling. | ||
|
|
||
|
|
@@ -1047,13 +1048,20 @@ def _do_download( | |
| See the retry.py source code and docstrings in this package | ||
| (google.cloud.storage.retry) for information on retry types and how | ||
| to configure them. | ||
|
|
||
| :type single_shot_download: bool | ||
| :param single_shot_download: | ||
| (Optional) If true, download the object in a single request. | ||
| Caution: Enabling this will increase the memory overload for your application. | ||
| Please enable this as per your use case. | ||
shubham-up-47 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """ | ||
|
|
||
| extra_attributes = { | ||
| "url.full": download_url, | ||
| "download.chunk_size": f"{self.chunk_size}", | ||
| "download.raw_download": raw_download, | ||
| "upload.checksum": f"{checksum}", | ||
| "download.single_shot_download": single_shot_download, | ||
| } | ||
| args = {"timeout": timeout} | ||
|
|
||
|
|
@@ -1073,6 +1081,10 @@ def _do_download( | |
| end=end, | ||
| checksum=checksum, | ||
| retry=retry, | ||
| # NOTE: single_shot_download is only supported in Download and RawDownload | ||
| # classes, i.e., when chunk_size is set to None (the default value). It is | ||
| # not supported for chunked downloads. | ||
| single_shot_download=single_shot_download, | ||
| ) | ||
| with create_trace_span( | ||
| name=f"Storage.{download_class}/consume", | ||
|
|
@@ -1127,6 +1139,7 @@ def download_to_file( | |
| timeout=_DEFAULT_TIMEOUT, | ||
| checksum="auto", | ||
| retry=DEFAULT_RETRY, | ||
| single_shot_download=False, | ||
| ): | ||
| """Download the contents of this blob into a file-like object. | ||
|
|
||
|
|
@@ -1222,6 +1235,12 @@ def download_to_file( | |
| (google.cloud.storage.retry) for information on retry types and how | ||
| to configure them. | ||
|
|
||
| :type single_shot_download: bool | ||
| :param single_shot_download: | ||
| (Optional) If true, download the object in a single request. | ||
| Caution: Enabling this will increase the memory overload for your application. | ||
| Please enable this as per your use case. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for adding the note on memory consumption. Based on the design doc, I understand we are introducing single shot download support in multiple phases. Note that if and when we want to have
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cojenco how is that a breaking change?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure @cojenco, will keep these things in mind. |
||
|
|
||
| :raises: :class:`google.cloud.exceptions.NotFound` | ||
| """ | ||
| with create_trace_span(name="Storage.Blob.downloadToFile"): | ||
|
|
@@ -1240,6 +1259,7 @@ def download_to_file( | |
| timeout=timeout, | ||
| checksum=checksum, | ||
| retry=retry, | ||
| single_shot_download=single_shot_download, | ||
| ) | ||
|
|
||
| def _handle_filename_and_download(self, filename, *args, **kwargs): | ||
|
|
@@ -1285,6 +1305,7 @@ def download_to_filename( | |
| timeout=_DEFAULT_TIMEOUT, | ||
| checksum="auto", | ||
| retry=DEFAULT_RETRY, | ||
| single_shot_download=False, | ||
| ): | ||
| """Download the contents of this blob into a named file. | ||
|
|
||
|
|
@@ -1370,6 +1391,12 @@ def download_to_filename( | |
| (google.cloud.storage.retry) for information on retry types and how | ||
| to configure them. | ||
|
|
||
| :type single_shot_download: bool | ||
| :param single_shot_download: | ||
| (Optional) If true, download the object in a single request. | ||
| Caution: Enabling this will increase the memory overload for your application. | ||
| Please enable this as per your use case. | ||
|
|
||
| :raises: :class:`google.cloud.exceptions.NotFound` | ||
| """ | ||
| with create_trace_span(name="Storage.Blob.downloadToFilename"): | ||
|
|
@@ -1388,6 +1415,7 @@ def download_to_filename( | |
| timeout=timeout, | ||
| checksum=checksum, | ||
| retry=retry, | ||
| single_shot_download=single_shot_download, | ||
| ) | ||
|
|
||
| def download_as_bytes( | ||
|
|
@@ -1405,6 +1433,7 @@ def download_as_bytes( | |
| timeout=_DEFAULT_TIMEOUT, | ||
| checksum="auto", | ||
| retry=DEFAULT_RETRY, | ||
| single_shot_download=False, | ||
| ): | ||
| """Download the contents of this blob as a bytes object. | ||
|
|
||
|
|
@@ -1484,6 +1513,12 @@ def download_as_bytes( | |
| (google.cloud.storage.retry) for information on retry types and how | ||
| to configure them. | ||
|
|
||
| :type single_shot_download: bool | ||
| :param single_shot_download: | ||
| (Optional) If true, download the object in a single request. | ||
shubham-up-47 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Caution: Enabling this will increase the memory overload for your application. | ||
| Please enable this as per your use case. | ||
|
|
||
| :rtype: bytes | ||
| :returns: The data stored in this blob. | ||
|
|
||
|
|
@@ -1507,6 +1542,7 @@ def download_as_bytes( | |
| timeout=timeout, | ||
| checksum=checksum, | ||
| retry=retry, | ||
| single_shot_download=single_shot_download, | ||
| ) | ||
| return string_buffer.getvalue() | ||
|
|
||
|
|
@@ -1524,6 +1560,7 @@ def download_as_string( | |
| if_metageneration_not_match=None, | ||
| timeout=_DEFAULT_TIMEOUT, | ||
| retry=DEFAULT_RETRY, | ||
| single_shot_download=False, | ||
| ): | ||
| """(Deprecated) Download the contents of this blob as a bytes object. | ||
|
|
||
|
|
@@ -1594,6 +1631,12 @@ def download_as_string( | |
| (google.cloud.storage.retry) for information on retry types and how | ||
| to configure them. | ||
|
|
||
| :type single_shot_download: bool | ||
| :param single_shot_download: | ||
| (Optional) If true, download the object in a single request. | ||
| Caution: Enabling this will increase the memory overload for your application. | ||
| Please enable this as per your use case. | ||
|
|
||
| :rtype: bytes | ||
| :returns: The data stored in this blob. | ||
|
|
||
|
|
@@ -1616,6 +1659,7 @@ def download_as_string( | |
| if_metageneration_not_match=if_metageneration_not_match, | ||
| timeout=timeout, | ||
| retry=retry, | ||
| single_shot_download=single_shot_download, | ||
| ) | ||
|
|
||
| def download_as_text( | ||
|
|
@@ -1633,6 +1677,7 @@ def download_as_text( | |
| if_metageneration_not_match=None, | ||
| timeout=_DEFAULT_TIMEOUT, | ||
| retry=DEFAULT_RETRY, | ||
| single_shot_download=False, | ||
| ): | ||
| """Download the contents of this blob as text (*not* bytes). | ||
|
|
||
|
|
@@ -1705,6 +1750,12 @@ def download_as_text( | |
| (google.cloud.storage.retry) for information on retry types and how | ||
| to configure them. | ||
|
|
||
| :type single_shot_download: bool | ||
| :param single_shot_download: | ||
| (Optional) If true, download the object in a single request. | ||
| Caution: Enabling this will increase the memory overload for your application. | ||
| Please enable this as per your use case. | ||
|
|
||
| :rtype: text | ||
| :returns: The data stored in this blob, decoded to text. | ||
| """ | ||
|
|
@@ -1722,6 +1773,7 @@ def download_as_text( | |
| if_metageneration_not_match=if_metageneration_not_match, | ||
| timeout=timeout, | ||
| retry=retry, | ||
| single_shot_download=single_shot_download, | ||
| ) | ||
|
|
||
| if encoding is not None: | ||
|
|
@@ -4019,6 +4071,7 @@ def open( | |
| For downloads only, the following additional arguments are supported: | ||
|
|
||
| - ``raw_download`` | ||
| - ``single_shot_download`` | ||
|
|
||
| For uploads only, the following additional arguments are supported: | ||
|
|
||
|
|
@@ -4209,6 +4262,7 @@ def _prep_and_do_download( | |
| timeout=_DEFAULT_TIMEOUT, | ||
| checksum="auto", | ||
| retry=DEFAULT_RETRY, | ||
| single_shot_download=False, | ||
| command=None, | ||
| ): | ||
| """Download the contents of a blob object into a file-like object. | ||
|
|
@@ -4294,6 +4348,12 @@ def _prep_and_do_download( | |
| (google.cloud.storage.retry) for information on retry types and how | ||
| to configure them. | ||
|
|
||
| :type single_shot_download: bool | ||
| :param single_shot_download: | ||
| (Optional) If true, download the object in a single request. | ||
| Caution: Enabling this will increase the memory overload for your application. | ||
| Please enable this as per your use case. | ||
|
|
||
| :type command: str | ||
| :param command: | ||
| (Optional) Information about which interface for download was used, | ||
|
|
@@ -4349,6 +4409,7 @@ def _prep_and_do_download( | |
| timeout=timeout, | ||
| checksum=checksum, | ||
| retry=retry, | ||
| single_shot_download=single_shot_download, | ||
| ) | ||
| except InvalidResponse as exc: | ||
| _raise_from_invalid_response(exc) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.