Skip to content

Commit

Permalink
Merge pull request #3741 from yukihira1992/yukihira1992/fix-download-…
Browse files Browse the repository at this point in the history
…as-string

Replace deprecated download_as_string method with download_as_bytes method
  • Loading branch information
jcrist authored Dec 1, 2020
2 parents 53152d4 + cc719d7 commit dd5f561
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions changes/pr3741.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fix:
- "Replace deprecated download_as_string method with download_as_bytes method - [#3741](https://github.com/PrefectHQ/prefect/pull/3741)"

contributor:
- "[Takayuki Hirayama](https://github.com/yukihira1992)"
2 changes: 1 addition & 1 deletion src/prefect/engine/result_handlers/gcs_result_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def read(self, uri: str) -> Any:
"""
try:
self.logger.debug("Starting to download result from {}...".format(uri))
result = self.gcs_bucket.blob(uri).download_as_string()
result = self.gcs_bucket.blob(uri).download_as_bytes()
try:
return_val = cloudpickle.loads(base64.b64decode(result))
except EOFError:
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/engine/results/gcs_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def read(self, location: str) -> Result:

try:
self.logger.debug("Starting to download result from {}...".format(location))
serialized_value = self.gcs_bucket.blob(location).download_as_string()
serialized_value = self.gcs_bucket.blob(location).download_as_bytes()
try:
new.value = new.serializer.deserialize(serialized_value)
except EOFError:
Expand Down
2 changes: 1 addition & 1 deletion tests/engine/results/test_gcs_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_gcs_writes_to_blob_using_rendered_template_name(self, google_client):

def test_gcs_reads_and_updates_location(self, google_client):
bucket = MagicMock()
bucket.blob.return_value.download_as_string.return_value = b""
bucket.blob.return_value.download_as_bytes.return_value = b""
google_client.return_value.bucket = MagicMock(return_value=bucket)
result = GCSResult(bucket="foo", location="{thing}/here.txt")
new_result = result.read("path/to/my/stuff.txt")
Expand Down

0 comments on commit dd5f561

Please sign in to comment.