Skip to content

refactor(cv): shared prototype-build core; tidy PipelineRunner introspection methods#67

Merged
rwlove merged 1 commit into
mainfrom
refactor/prototype-core-and-runner-tidy
Jul 3, 2026
Merged

refactor(cv): shared prototype-build core; tidy PipelineRunner introspection methods#67
rwlove merged 1 commit into
mainfrom
refactor/prototype-core-and-runner-tidy

Conversation

@rwlove

@rwlove rwlove commented Jul 3, 2026

Copy link
Copy Markdown
Owner

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) → 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. New pump_cv.classify.build_prototype_from_video owns the pipeline; both callers thin-wrap it.

  • healthd catches NoAthleteDetectedError → HTTP 422
  • add_reference catches FileNotFoundError → exit 1, NoAthleteDetectedError → exit 2

Behavior 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_thresholds were 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 report PipelineRunner.foo instead of foo.

Test plan

  • 47 pass / 1 skip (was 42/1). Ruff clean.

Tag: pump-cv-v0.6.1.

🤖 Generated with Claude Code

…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>
@rwlove rwlove merged commit 7178093 into main Jul 3, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant