Skip to content

Commit

Permalink
Merge pull request #237 from lsst-sqre/tickets/DM-47986
Browse files Browse the repository at this point in the history
DM-47986: Catch errors from initializing Butler in worker
  • Loading branch information
rra authored Dec 12, 2024
2 parents 97843f0 + dc3f5ed commit c57be2a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
3 changes: 3 additions & 0 deletions changelog.d/20241211_181509_rra_DM_47986.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Bug fixes

- Catch errors from parsing the dataset ID or creating a Butler in the backend worker and report them as proper worker exceptions so that they don't produce uncaught exception errors.
27 changes: 22 additions & 5 deletions src/vocutouts/workers/cutout.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,19 @@ def _get_backend(butler_label: str, token: str) -> ImageCutoutBackend:
-------
lsst.image_cutout_backend.ImageCutoutBackend
Backend to use.
Raises
------
WorkerFatalError
Raised if a Butler for the given label could not be created.
"""
butler = _BUTLER_FACTORY.create_butler(
label=butler_label, access_token=token
)
try:
butler = _BUTLER_FACTORY.create_butler(
label=butler_label, access_token=token
)
except Exception as e:
msg = f"Cannot create Butler for label {butler_label}"
raise WorkerFatalError(msg, str(e)) from e

# At present, projection finders and image cutout backend have no internal
# caching and are cheap to construct, so we just make a new one for each
Expand All @@ -86,9 +95,17 @@ def _parse_uri(uri: str) -> tuple[str, UUID]:
Butler label.
UUID
Object UUID.
Raises
------
WorkerUsageError
Raised if the dataset reference could not be parsed.
"""
parsed_uri = urlparse(uri)
return parsed_uri.netloc, UUID(parsed_uri.path[1:])
try:
parsed_uri = urlparse(uri)
return parsed_uri.netloc, UUID(parsed_uri.path[1:])
except Exception as e:
raise WorkerUsageError(f"Invalid data ID {uri}", str(e)) from e


def cutout(
Expand Down

0 comments on commit c57be2a

Please sign in to comment.