docs: add Google-style docstrings to detection.py and tracker.py#78
docs: add Google-style docstrings to detection.py and tracker.py#78SiddharthRiot wants to merge 2 commits into
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughThe PR refactors detection output to use ChangesDetection Output Schema and Visualization Refactoring
Tracker Documentation Enhancement
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
services/detection/detection.py (1)
31-33: ⚡ Quick winRemove stale zone-membership work from
detect()and align the docstrings with the actual return contract.
get_zones_for_point(cx, cy)is executed per detection and discarded, so this adds avoidable work in a hot loop. At the same time, the docstrings still claim zone memberships are part of returned detections, which no longer matches the constructedDetectionSchema.Proposed cleanup
-from services.detection.zones import DEFAULT_ZONES, get_zones_for_point +from services.detection.zones import DEFAULT_ZONES @@ - DetectionFrameSchema objects with bounding boxes, labels, confidence - scores, and zone memberships. + DetectionFrameSchema objects with bounding boxes, labels, and confidence + scores. @@ - DetectionFrameSchema with all detected objects and zone memberships. + DetectionFrameSchema with all detected objects. @@ - _ = [z.name for z in get_zones_for_point(cx, cy)] - detections.append(DetectionSchema(Also applies to: 71-72, 92-93
🤖 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/detection/detection.py` around lines 31 - 33, The detect() function still calls get_zones_for_point(cx, cy) per detection and mentions zone memberships in its docstring even though returned objects are DetectionSchema/DetectionFrameSchema without zone data; remove the per-detection get_zones_for_point call and any unused zone-handling variables from detect(), update the detect() and related docstrings to reflect that detections no longer include zone memberships (only bounding boxes, labels, and confidence), and ensure DetectionFrameSchema/DetectionSchema construction matches the docstrings; search for and remove the same stale calls/comments around the other noted locations (lines ~71-72 and ~92-93) so the implementation and docs are consistent.
🤖 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.
Inline comments:
In `@services/tracking/tracker.py`:
- Around line 317-318: The docstring for the cosine similarity function
(cosine_similarity) incorrectly states the return range as [0, 1]; update it to
reflect the true range of cosine similarity: "Float in [-1, 1] representing
similarity; 0.0 if either norm is zero." Modify the docstring text in tracker.py
(the cosine_similarity function) to use [-1, 1] and keep the note about the
zero-norm early return.
---
Nitpick comments:
In `@services/detection/detection.py`:
- Around line 31-33: The detect() function still calls get_zones_for_point(cx,
cy) per detection and mentions zone memberships in its docstring even though
returned objects are DetectionSchema/DetectionFrameSchema without zone data;
remove the per-detection get_zones_for_point call and any unused zone-handling
variables from detect(), update the detect() and related docstrings to reflect
that detections no longer include zone memberships (only bounding boxes, labels,
and confidence), and ensure DetectionFrameSchema/DetectionSchema construction
matches the docstrings; search for and remove the same stale calls/comments
around the other noted locations (lines ~71-72 and ~92-93) so the implementation
and docs are consistent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5306bbbb-8977-4efd-ac30-11a09042a5f0
📒 Files selected for processing (2)
services/detection/detection.pyservices/tracking/tracker.py
| Float in [0, 1] representing similarity; 0.0 if either norm is zero. | ||
| """ |
There was a problem hiding this comment.
Fix incorrect cosine similarity return range in docstring.
Line 317 says similarity is in [0, 1], but cosine similarity is typically in [-1, 1] (except zero-norm early return). Please update the docstring range to match the implementation.
Suggested docstring fix
- Float in [0, 1] representing similarity; 0.0 if either norm is zero.
+ Float in [-1, 1] representing similarity; 0.0 if either norm is zero.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| Float in [0, 1] representing similarity; 0.0 if either norm is zero. | |
| """ | |
| Float in [-1, 1] representing similarity; 0.0 if either norm is zero. | |
| """ |
🤖 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 317 - 318, The docstring for the
cosine similarity function (cosine_similarity) incorrectly states the return
range as [0, 1]; update it to reflect the true range of cosine similarity:
"Float in [-1, 1] representing similarity; 0.0 if either norm is zero." Modify
the docstring text in tracker.py (the cosine_similarity function) to use [-1, 1]
and keep the note about the zero-norm early return.
|
Hey @Devnil434, the CI failure is not related to my changes. The lint check passes successfully. the test job fails due to missing |
Closes #4
Changes
services/detection/detection.pyandservices/tracking/tracker.pyDetectionFrame→DetectionFrameSchema,Detection→DetectionSchema)ruff checkpasses with no errorsTesting
python -m ruff check services/detection/detection.py services/tracking/tracker.py
All checks passed!
Summary by CodeRabbit
Release Notes
Improvements
Documentation