fix(perception): guard EdgeTAM import with actionable error for missing sam2#2110
fix(perception): guard EdgeTAM import with actionable error for missing sam2#2110spomichter wants to merge 1 commit into
Conversation
…ng sam2 EdgeTAMProcessor crashes with a cryptic Hydra InstantiationException when the 'edgetam-dimos' package (which provides the sam2 module) is not installed. This package lives in the [misc] optional extra, but the unitree-go2-agentic blueprint unconditionally instantiates SecurityModule → EdgeTAMProcessor, causing fresh installs to fail. Add an early ImportError guard with a clear message pointing users to 'uv sync --extra misc'.
Greptile SummaryThis PR guards the
Confidence Score: 5/5This is a safe, minimal guard that fires only when sam2 is absent and is otherwise a no-op on working installs. The change is a single try/except block added at the very top of init, with no effect on the happy path. The guard correctly surfaces a clear, actionable message before Hydra's opaque instantiation error would otherwise appear. The only open question is whether to preserve the original exception cause, which is a minor style concern. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[EdgeTAMProcessor.__init__ called] --> B{try: import sam2}
B -- ImportError --> C[raise ImportError with install hint\nuv sync --extra misc]
B -- success --> D[Load edgetam.yaml config]
D --> E{local_config_path.exists?}
E -- No --> F[raise FileNotFoundError]
E -- Yes --> G{torch.cuda.is_available?}
G -- No --> H[raise RuntimeError CUDA required]
G -- Yes --> I[OmegaConf.load + overrides]
I --> J[instantiate SAM2VideoPredictor via Hydra]
J --> K[Patch sam2.sam2_video_predictor.tqdm]
K --> L[Load checkpoint weights]
L --> M[Move predictor to CUDA + eval mode]
M --> N[Init complete]
Reviews (1): Last reviewed commit: "fix(perception): guard EdgeTAM import wi..." | Re-trigger Greptile |
| except ImportError: | ||
| raise ImportError( | ||
| "EdgeTAM requires the 'edgetam-dimos' package (provides sam2). " | ||
| "Install with: uv sync --extra misc" | ||
| ) from None |
There was a problem hiding this comment.
Using
from None suppresses the original ImportError's __cause__, so if sam2 is partially installed and raises a more informative sub-error (e.g., a missing native .so), that detail is silently discarded. Keeping the cause chain lets developers distinguish "package not installed at all" from "package installed but broken", without harming the curated message.
| except ImportError: | |
| raise ImportError( | |
| "EdgeTAM requires the 'edgetam-dimos' package (provides sam2). " | |
| "Install with: uv sync --extra misc" | |
| ) from None | |
| except ImportError as exc: | |
| raise ImportError( | |
| "EdgeTAM requires the 'edgetam-dimos' package (provides sam2). " | |
| "Install with: uv sync --extra misc" | |
| ) from exc |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Problem
unitree-go2-agenticblueprint crashes on fresh installs with a cryptic HydraInstantiationException:The
sam2module is provided by theedgetam-dimospackage, which lives in the[misc]optional extra. But the agentic blueprint unconditionally instantiatesSecurityModule→EdgeTAMProcessor, so anyuv syncwithout--extra miscproduces an unactionable crash.Introduced in: PR #1619 (
feat(security): add security demo) which addedSecurityModuleto theunitree_go2_spatialblueprint without movingedgetam-dimosfrommiscto core dependencies.Solution
Add an early
try: import sam2guard inEdgeTAMProcessor.__init__that raises a clearImportErrorwith install instructions before Hydra'sinstantiate()produces an opaque error.Breaking Changes
None
How to Test
Contributor License Agreement