Cache per-video pose attributes to skip load-time pose scan (KLAUS-506)#413
Open
gbeane wants to merge 2 commits into
Open
Cache per-video pose attributes to skip load-time pose scan (KLAUS-506)#413gbeane wants to merge 2 commits into
gbeane wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces a persistent, per-video cache of pose-derived metadata to avoid opening and scanning every pose HDF5 file on subsequent project loads, significantly reducing load time for large projects.
Changes:
- Added
pose_attribute_cachemodule to load/save a schema-versioned JSON cache keyed by video filename and pose-filestattoken. - Updated
Project._run_video_scanto reuse cached per-video pose attributes and rescan only new/changed pose files (while bypassing cache whenenable_video_check=True). - Added unit + integration-style tests covering cache hits, invalidation, new-video-only scans, and
use_cache=False.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/project/test_pose_attribute_cache.py | Adds tests validating cache persistence, cache-hit behavior, and invalidation scenarios. |
| src/jabs/project/project.py | Implements cached scan path and reconstructs scan results from cached pose attributes. |
| src/jabs/project/project_paths.py | Adds pose_attribute_cache_file path helper (returns None when caching is disabled). |
| src/jabs/project/pose_attribute_cache.py | New module handling token generation and resilient cache load/save. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+76
to
+83
| def _pose_cache_entry_matches(entry: object, token: str, pose_file: str) -> bool: | ||
| """Return True when a cache entry is usable for a video's current pose file.""" | ||
| return ( | ||
| isinstance(entry, dict) | ||
| and entry.get("token") == token | ||
| and entry.get("pose_file") == pose_file | ||
| and all(field in entry for field in _POSE_CACHE_FIELDS) | ||
| ) |
…e-attribute-cache
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.
Summary
Caches the per-video pose attributes read at project load (frame count, identity count, static objects, lixit keypoints, cm-per-pixel) so subsequent loads rescan only new/changed pose files instead of opening all of them.
Measured on a 488-video project (external SSD): cold load 3.88s (488 pose scans) → cached load 0.01s (0 scans), with identical identity counts and pose version.
What changed
jabs/cache/pose_attribute_cache.json, keyed by video filename and gated by a cheapstattoken (size:mtime_ns) of the pose file; schema-versioned.pose_attribute_cache.py(pose_token/load/save);ProjectPaths.pose_attribute_cache_file(returnsNonewhenuse_cache=False)._run_video_scansplit into_scan_jobs+_run_cached_video_scan. The opt-inenable_video_checkpath bypasses the cache, since video frame counts are not cached.VideoManager/FeatureManager(sameVideoScanResult); no consumer changes.Behavior
stattoken) or a pose-version upgrade invalidates that entry; removed videos are pruned.clear_cache()removes the file harmlessly;use_cache=False→ no persistence.Tests
13 new tests: module unit tests plus cache-hit (no rescan), token invalidation, new-video-only scan,
use_cache=False, and fresh-vs-cached parity. Full suite green.Jira: KLAUS-506