fix: resolve import errors blocking tracker tests + add get_zones_for_point#86
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughLoads detection zones from YAML config with hot-reload and shapely-based point queries; exposes tracking exports at package init; simplifies MemoryService lifecycle and rewrites MemoryStore Redis keying and event-history behavior. ChangesZone System & Package Configuration
Sequence Diagram(s)sequenceDiagram
participant Caller as Caller
participant ZoneLoader as ZoneConfigLoader
participant Config as config/zones.yaml
participant Shapely as shapely (optional)
participant Result as _Zone
Caller->>ZoneLoader: get_zones()
ZoneLoader->>Config: read definitions (ZONES_CONFIG_PATH)
Config-->>ZoneLoader: zone dicts
ZoneLoader-->>Caller: zone list
Caller->>Shapely: polygon.contains(Point(x,y)) (if installed)
Shapely-->>Caller: containment results
Caller->>Result: wrap matches (_Zone.name)
Result-->>Caller: matched zone names
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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.
🧹 Nitpick comments (1)
services/detection/zones.py (1)
55-59: ⚡ Quick winUse boundary-inclusive geometry predicate for zone membership checking.
Line 58 uses
contains, which excludes boundary points. When points fall exactly on polygon edges, they are incorrectly treated as outside the zone, causing potential tracking edge flicker. Replace withcoversto include boundary points.Suggested change
- if poly.contains(point): + if poly.covers(point): # Return a lightweight object with .name attribute🤖 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/zones.py` around lines 55 - 59, The loop that builds a Polygon instance with poly = Polygon(zone["polygon"]) and checks membership using poly.contains(point) excludes points on the polygon boundary; change the predicate to poly.covers(point) so boundary points are treated as inside. Locate the membership check (the poly.contains call) in the for zone in zones loop and replace contains with covers, keeping the same Polygon construction and return behavior (no other logic changes required).
🤖 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.
Nitpick comments:
In `@services/detection/zones.py`:
- Around line 55-59: The loop that builds a Polygon instance with poly =
Polygon(zone["polygon"]) and checks membership using poly.contains(point)
excludes points on the polygon boundary; change the predicate to
poly.covers(point) so boundary points are treated as inside. Locate the
membership check (the poly.contains call) in the for zone in zones loop and
replace contains with covers, keeping the same Polygon construction and return
behavior (no other logic changes required).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2bb79c91-bcd8-4172-aeb6-7abc1724da92
📒 Files selected for processing (4)
.gitignoreservices/__init__.pyservices/detection/zones.pyservices/tracking/__init__.py
|
Hi @Devnil434, The CI shows 2 pre-existing issues unrelated to this PR:
My changes ( Happy to work on the issues stated, if they haven’t already been assigned to someone else. Feel free to assign them to me! |
Problem
services/tracking/tracker.pyimportsget_zones_for_pointfromservices.detection.zones, but that function did not exist, causingall tracker tests to fail with ImportError/AttributeError.
Root Cause
Three issues compounding each other:
get_zones_for_point()missing fromzones.pyservices/tracking/__init__.pywas empty — broke@patchin testsservices/__init__.pywas empty — broke module resolutionChanges Made
services/detection/zones.pyget_zones_for_point(x, y)with shapely point-in-polygonservices/tracking/__init__.pytrackermodule for test@patchresolutionservices/__init__.pytrackingsubpackage for proper imports.gitignoreeagle_surveillance.egg-info/Test Results
Closes #67
Summary by CodeRabbit
New Features
Behavior Changes
Chores