feat(zettasets): Fall back to zettasets images#26
Open
Conversation
torms3
reviewed
Feb 26, 2026
There was a problem hiding this comment.
Control flow via exception (Claude Code)
Using raise ValueError just to catch it a few lines later is a code smell:
if sample.src_image_path is None:
raise ValueError("No src_image_path available")
# ...
except (InfoUnavailableError, ValueError) as e:This also has the side effect of catching genuine ValueErrors from CloudVolume internals. Consider restructuring to avoid exceptions as control flow:
vol = None
if sample.src_image_path is not None:
try:
vol = CloudVolume(
sample.src_image_path,
mip=resolution,
fill_missing=True,
bounded=False,
)[image_bbox.to_slices()]
except InfoUnavailableError as e:
logging.warning(f"src_image_path failed ({e}), falling back to sample image volume")
if vol is None:
vol = CloudVolume(
sample.volumes["image"].cloudpath,
mip=resolution,
fill_missing=True,
bounded=False,
)[image_bbox.to_slices()]This makes the None check and the InfoUnavailableError handling separate concerns, and avoids accidentally swallowing unrelated ValueErrors.
Unguarded fallback (@torms3)
The fallback assumes sample.volumes["image"] always exists. If it doesn't, the user gets an unhandled KeyError with no context. Consider validating before accessing:
if "image" not in sample.volumes:
raise RuntimeError(
f"src_image_path failed ({e}) and sample has no 'image' volume to fall back to"
) from eThis applies to both multi_zettaset.py and zettaset.py.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.