Skip to content

Commit

Permalink
fix blob download and handle exception in compute (#12152)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 27b7eb6365b1a5d08678d86c147d6e797754a592
  • Loading branch information
tkrause authored and Descartes Labs Build committed Sep 8, 2023
1 parent c3a9024 commit 1f6b2aa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
14 changes: 8 additions & 6 deletions descarteslabs/core/catalog/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

from strenum import StrEnum

from descarteslabs.exceptions import NotFoundError

from ..client.services.service import ThirdPartyService
from ..common.collection import Collection
from ..common.property_filtering import Properties
Expand All @@ -30,14 +32,9 @@
parse_iso_datetime,
)
from .blob_download import BlobDownload
from .catalog_base import (
CatalogClient,
CatalogObject,
check_deleted,
)
from .catalog_base import CatalogClient, CatalogObject, check_deleted
from .search import AggregateDateField, GeoSearch, SummarySearchMixin


properties = Properties()


Expand Down Expand Up @@ -835,6 +832,11 @@ def get_data(
def _do_download(self, dest=None, range=None):
download = BlobDownload.get(id=self.id, client=self._client)

# BlobDownload.get() returns None if the blob does not exist
# raise a NotFoundError in this case
if not download:
raise NotFoundError("Blob {} does not exist".format(self.id))

headers = {}
if self.hash:
headers["if-match"] = self.hash
Expand Down
5 changes: 5 additions & 0 deletions descarteslabs/core/compute/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
from typing import TYPE_CHECKING, Dict, List, Optional, Type

from strenum import StrEnum

from descarteslabs.exceptions import NotFoundError

from ..catalog import Blob, CatalogClient, DeletedObjectError, StorageType
from ..common.client import (
Attribute,
Expand Down Expand Up @@ -277,6 +280,8 @@ def result(self, cast_type: Optional[Type[Serializable]] = None):
storage_type=StorageType.COMPUTE,
client=client,
)
except NotFoundError:
return None
except ValueError:
raise
except DeletedObjectError:
Expand Down

0 comments on commit 1f6b2aa

Please sign in to comment.