fix a couple bugs#369
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to make project merging and prediction loading more robust when project metadata (identity counts) or the destination project’s in-memory video inventory is missing/stale, and adds tests for these edge cases.
Changes:
- Updated
PredictionManager.load_predictions()to tolerate missingproject_settings["video_files"][video]["identities"]and attempt fallback identity-count resolution. - Updated
merge_projects()to add a fallback pose-loading path for videos newly copied into the destination project (stale inventory scenario). - Added tests to cover prediction loading with missing metadata and merging with unique labeled videos; updated
.gitignore.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/jabs/project/prediction_manager.py |
Adds fallback logic for missing identity-count metadata during prediction load. |
src/jabs/project/project_merge.py |
Adds a fallback pose-loading path for newly-copied videos when destination inventory is stale. |
tests/project/test_prediction_manager.py |
Introduces a mock video manager and a test for missing video_files metadata fallback. |
tests/project/test_project_merge.py |
Adds a regression test for merging unique labeled videos with stale destination inventory. |
.gitignore |
Ignores scratch/. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
This PR improves robustness when loading predictions and merging projects in cases where project metadata or destination inventory is missing/stale, and adds targeted tests to cover these edge cases.
Changes:
- Updated
PredictionManager.load_predictions()to fall back tovideo_manageridentity counts (and infer identity count from the prediction file when still unknown). - Updated
merge_projects()to recover from stale destination inventory for newly-copied videos by opening the pose file directly from disk. - Added tests covering both fallback behaviors and updated mocks to support the new prediction-loading path.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/jabs/project/prediction_manager.py |
Adds identity-count fallback logic when project_settings["video_files"] is missing/stale. |
src/jabs/project/project_merge.py |
Adds a direct pose-file open fallback when destination inventory is stale for newly-copied videos. |
tests/project/test_prediction_manager.py |
Extends mocks and adds tests for missing video metadata and identity-count inference behavior. |
tests/project/test_project_merge.py |
Adds a regression test for merge behavior when destination pose loading fails due to stale inventory. |
.gitignore |
Ignores a scratch/ directory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This pull request improves robustness in handling missing or stale project metadata during prediction loading and project merging, and adds comprehensive tests to cover these edge cases. The main focus is on ensuring fallback mechanisms work correctly when expected metadata or inventory is unavailable, both in the core logic and in the test suite.
Robustness improvements for missing metadata and inventory:
load_predictionsinprediction_manager.pyto gracefully handle missingidentitiesmetadata inproject_settings['video_files']by falling back tovideo_manager.get_video_identity_count(video). If still unavailable, it attempts to infer the count from the prediction file itself.merge_projectsinproject_merge.py, added logic to handle cases where a video unique to the source project has just been copied and the destination's in-memory inventory is stale. If loading pose estimation fails, it falls back to opening the pose file directly from the cache.open_pose_fileinproject_merge.pyto support the new fallback logic.Test coverage enhancements:
MockVideoManagerto the test suite and updatedMockProjectto include it, enabling simulation of video identity count fallback scenarios. [1] [2]test_prediction_manager.pyverifying thatload_predictionsfalls back tovideo_managerwhenvideo_filesmetadata is missing.test_project_merge.pyto ensure that merging unique labeled videos correctly falls back when the destination's inventory is stale andload_pose_estfails.