refactor(cv): shared prototype-build core; tidy PipelineRunner introspection methods#67
Merged
Merged
Conversation
…pection methods Two low-risk cleanups I flagged during the codebase audit. ** Shared prototype-build core ** healthd._process_reference_clip and scripts/add_reference::_process both did the same thing: YOLOPoseSource(clip) → per-frame pick_athlete → pose_sequence_to_features → PrototypeStore.add. The overlap wasn't copy-paste identical (one is a coroutine returning exit codes, the other is sync + HTTPException) but if the pipeline evolved a shared step, one call site could silently drift out of sync. New pump_cv.classify.build_prototype_from_video owns the pipeline. Both callers thin-wrap it: - healthd catches NoAthleteDetectedError → HTTP 422 (was hand-rolled) - add_reference catches FileNotFoundError → exit 1 (was hand-rolled), NoAthleteDetectedError → exit 2 (was hand-rolled) Behavior identical; 5 new tests (empty-frames sentinel path, missing-file path, feature-shape sanity, PrototypeStore round-trip, sentinel-is-Exception-subclass check) prove it. ** PipelineRunner introspection methods ** snapshot_state / snapshot_thresholds / update_thresholds were three module-level functions monkey-patched onto PipelineRunner at import time. The runner file's own comment admitted the arrangement was odd. Moved into the class body next to _recount_reps. No behavior change; verified by a __qualname__ assertion that all three now report 'PipelineRunner.foo' instead of 'foo'. healthd's /api/v1/state and /api/v1/thresholds callers are unaffected. 47 pass / 1 skip (was 42/1). Ruff clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Two low-risk cleanups I flagged during the codebase audit.
Shared prototype-build core
healthd._process_reference_clipandscripts/add_reference::_processboth did the same thing:YOLOPoseSource(clip) → pick_athlete → pose_sequence_to_features → PrototypeStore.add. Not copy-paste identical — one is a coroutine returning exit codes, the other is sync +HTTPException— but the shared pipeline was a footgun if it ever evolved. Newpump_cv.classify.build_prototype_from_videoowns the pipeline; both callers thin-wrap it.NoAthleteDetectedError→ HTTP 422FileNotFoundError→ exit 1,NoAthleteDetectedError→ exit 2Behavior identical. 5 new tests cover the sentinel paths, missing-file path, feature-shape sanity, PrototypeStore round-trip, and sentinel-is-Exception check.
PipelineRunner introspection methods
snapshot_state/snapshot_thresholds/update_thresholdswere three module-level functions monkey-patched onto the class at import time. The file's own comment admitted the arrangement was odd. Moved into the class body next to_recount_reps. No behavior change; verified by a__qualname__assertion that all three now reportPipelineRunner.fooinstead offoo.Test plan
Tag:
pump-cv-v0.6.1.🤖 Generated with Claude Code