Skip to content

Commit

Permalink
Core-255 (#12478)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 49522bb6cee32080ed4d37ecf4e93892f4648476
  • Loading branch information
jjmckee authored and Descartes Labs Build committed Mar 6, 2024
1 parent d0248a3 commit fd86983
Show file tree
Hide file tree
Showing 2 changed files with 854 additions and 8 deletions.
12 changes: 4 additions & 8 deletions descarteslabs/core/catalog/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def get(
raise TypeError("Must specify exactly one of id or name parameters")
if not id:
id = f"{storage_type}/{Blob.namespace_id(namespace)}/{name}"
return super(cls, Blob).get(id)
return super(cls, Blob).get(id, client=client)

@classmethod
def get_or_create(
Expand Down Expand Up @@ -660,7 +660,7 @@ def download(self, file, range=None):
Parameters
----------
file : str or io.IOBase
File or files to be uploaded. Can be string with path to the file in the
Where to write the downloaded blob. Can be string with path to the file in the
local filesystem, or an file opened for writing (``io.IOBase``). If a file like
object and already open, must be binary mode and writable. Open file-like
objects remain open on return and must be closed by the caller.
Expand Down Expand Up @@ -689,7 +689,6 @@ def download(self, file, range=None):

if isinstance(file, str):
file = io.open(file, "wb")
close = True
elif isinstance(file, io.IOBase):
close = file.closed
if close:
Expand Down Expand Up @@ -942,9 +941,6 @@ def delete_many(cls, ids, client=None):
:ref:`Spurious exception <network_exceptions>` that can occur during a
network request.
"""
if client is None:
client = CatalogClient.get_default_client()

blob_delete = BlobDelete(ids=ids, client=client)

blob_delete.save()
Expand Down Expand Up @@ -973,9 +969,9 @@ def _do_download(self, dest=None, range=None):
elif len(range) == 2:
range_str = f"bytes={range[0]}-{range[1]}"
else:
ValueError("invalid range value")
raise ValueError("invalid range value")
else:
ValueError("invalid range value")
raise ValueError("invalid range value")

headers["range"] = range_str

Expand Down
Loading

0 comments on commit fd86983

Please sign in to comment.