Extract EmbeddingResult to a shared, path-agnostic module#1710
Extract EmbeddingResult to a shared, path-agnostic module#1710JonasWurst wants to merge 1 commit into
Conversation
Rename ImageEmbeddingResult -> EmbeddingResult and move it out of image_embedding.py into its own dependency-free module (dataset/embedding_result.py). The type carries embeddings plus kept_indices and is not image-specific; giving it a neutral home lets the image, image-crop, and (future) video embedding paths reuse it without importing a path-specific module. Pure rename/move: no behavior change. All references and docstrings updated. Only the image embedding path is touched here; the crop path still returns NDArray on main and adopts EmbeddingResult in the stacked crop PR. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughAdds a shared frozen ChangesEmbedding result standardization
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
❌ Fast Track: checks did not passFailed guardrails: backend/complexity (Guardrail threw: spawn uv ENOENT), backend/coverage (Guardrail threw: spawn uv ENOENT)
Reflects |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d2f988d9c4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Apply the per-item broken-file handling from the full-image embedding path (#1691) to the crop path, on top of the shared EmbeddingResult foundation (#1710). - embed_image_crops_batched catches (OSError, UnidentifiedImageError) per source file; a broken/undecodable file skips all of its crops instead of aborting the run, and is recorded once as BROKEN in a FileOutcomeReport. Returns an EmbeddingResult carrying kept_indices (input positions of the embedded crops) and raises AllInputFilesFailedError when every source file is broken. - Propagate EmbeddingResult through the ImageEmbeddingGenerator protocol embed_image_crops and its implementations (mobileclip, perception_encoder, RandomEmbeddingGenerator, custom-model example). - embedding_manager.embed_annotations filters annotation sample IDs by kept_indices before storing, keeping sample IDs and embeddings in sync. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
/review |
Summary
Prefactor sliced out of #1706. Pure rename/move — no behavior change.
ImageEmbeddingResult→EmbeddingResultand move it out ofimage_embedding.pyinto its own dependency-free moduledataset/embedding_result.py.embeddings+kept_indicesand is not image-specific. Giving it a neutral home lets the image, image-crop, and (future) video embedding paths reuse it without importing a path-specific module.NDArrayonmainand adoptsEmbeddingResultin the stacked crop PR (Tolerate broken files per-item in image crop embedding #1706).Stacking
#1706 (crop broken-file handling) will be rebased to stack on top of this PR.
Testing
make static-checks— ruff + format + mypy clean.pytest tests/dataset/{test_embedding_manager,test_mobileclip_embedding_generator,test_perception_encoder_embedding_generator,test_embedding_generator}.py— 46 passed.🤖 Generated with Claude Code
Summary by CodeRabbit