fix: resolve 3 syntax bugs blocking pytest collection#150
Conversation
…place em dash (U+2013) with hyphen in tracker.py docstring- Remove duplicate merged __init__ docstring in tracker.py - Fix settings.REDIS_URL -> settings.redis_url across codebase(pydantic BaseSettings normalizes field names to lowercase)Fixes #<149>
📝 WalkthroughWalkthroughThe PR fixes three syntax and attribute errors that block test collection (issue ChangesSettings Normalization and Tracker Fixes
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
services/tracking/tracker.py (1)
238-238:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winCritical:
gap_framesis undefined.The variable
gap_framesis referenced in the condition but is never defined before this line. This will cause aNameErrorat runtime when a track briefly disappears and then reappears (the interpolation path).The current test suite likely doesn't exercise trajectory gaps, which is why the 215 tests pass despite this bug. However, this will crash in production when the interpolation logic is triggered.
🔧 Proposed fix: Calculate gap_frames before using it
Insert the calculation before line 238:
prev_traj = prev.trajectory if prev else [] # ── Trajectory ──────────────────────────────────────────────── interpolated_points = [] max_gap = self.max_interpolation_gap # <-- Replaced self.config string access + gap_frames = self._frame_id - prev.last_seen_frame - 1 if prev else 0 if prev is not None and 0 < gap_frames <= max_gap:This calculates the number of frames between the last seen frame and the current frame, which is what the interpolation logic needs.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@services/tracking/tracker.py` at line 238, The condition references gap_frames which is never defined; before the line "if prev is not None and 0 < gap_frames <= max_gap:" compute gap_frames as the number of frames between the track's last seen frame and the current frame (for example: gap_frames = current_frame - prev.last_seen_frame - 1 or use whatever names your loop uses for the current frame index), then use that variable in the existing if. Ensure this computation is placed after confirming prev is not None (or use prev safely) and yields an integer; no other logic changes are required.
🧹 Nitpick comments (1)
services/tracking/tracker.py (1)
87-88: 💤 Low valueOptional: Remove "Returns: None" from init docstring.
__init__methods always implicitly returnNone, so documenting it is redundant. Python docstring conventions typically omit theReturnssection for constructors.✨ Optional cleanup
reid_similarity_threshold: Minimum confidence needed to reconnect an ID via ReID. max_interpolation_gap: Maximum frame gap size allowed to fill missing trajectories. - - Returns: - None Example:🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@services/tracking/tracker.py` around lines 87 - 88, Remove the redundant "Returns: None" section from the __init__ docstring in the class defined in services/tracking/tracker.py (the __init__ method around the shown diff); keep any parameter descriptions or other docstring content intact but delete the "Returns:" block since constructors implicitly return None.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@services/tracking/tracker.py`:
- Line 238: The condition references gap_frames which is never defined; before
the line "if prev is not None and 0 < gap_frames <= max_gap:" compute gap_frames
as the number of frames between the track's last seen frame and the current
frame (for example: gap_frames = current_frame - prev.last_seen_frame - 1 or use
whatever names your loop uses for the current frame index), then use that
variable in the existing if. Ensure this computation is placed after confirming
prev is not None (or use prev safely) and yields an integer; no other logic
changes are required.
---
Nitpick comments:
In `@services/tracking/tracker.py`:
- Around line 87-88: Remove the redundant "Returns: None" section from the
__init__ docstring in the class defined in services/tracking/tracker.py (the
__init__ method around the shown diff); keep any parameter descriptions or other
docstring content intact but delete the "Returns:" block since constructors
implicitly return None.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d6b0b857-4885-4c46-ad22-e7a20b59a22c
📒 Files selected for processing (6)
apps/backend/dependencies.pybenchmark.pyscripts/export_finetuning_dataset.pyscripts/inspect_tracks.pyservices/tracking/tracker.pytests/test_inspect_tracks.py
Summary
tracker.pydocstring (SyntaxError)__init__docstring intracker.py(unterminated string literal)settings.REDIS_URL→settings.redis_urlacross codebase — pydanticBaseSettingsnormalizes field names to lowercaseFiles Changed
services/tracking/tracker.pyscripts/inspect_tracks.pytests/test_inspect_tracks.pyapps/backend/dependencies.pybenchmark.pyscripts/export_finetuning_dataset.pyTest Results
Closes #149
Summary by CodeRabbit
Release Notes
New Features
max_interpolation_gapparameter to tracker configuration for enhanced control over trajectory interpolation behavior.Chores