[Refactor] receive_dict() returns the status and the error as dict#1029
Conversation
|
Warning Review limit reached
Next review available in: 4 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughSocketInterface.receive_dict now returns the raw deserialized payload rather than unwrapping "result"/"error"; shutdown extracts ["result"] explicitly. Task scheduler paths (blockallocation.py, shared.py) replace try/except exception handling around send_and_receive_dict with direct dict-key branching on "result"/"error". Tests updated accordingly. ChangesDict-based result/error handling refactor
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Shared
participant BlockAllocation
participant SocketInterface
participant Socket
Shared->>SocketInterface: send_and_receive_dict(task_dict)
SocketInterface->>Socket: send serialized data
Socket-->>SocketInterface: raw bytes
SocketInterface->>SocketInterface: receive_dict() returns cloudpickle.loads(data)
SocketInterface-->>Shared: dict output {"result"} or {"error"}
alt output has "result"
Shared->>Shared: set future_obj result
else output["error"] is ExecutorlibSocketError
Shared-->>Shared: return False
else other error
Shared->>Shared: set future_obj exception
end
BlockAllocation->>SocketInterface: send_and_receive_dict(init message)
SocketInterface-->>BlockAllocation: dict output
BlockAllocation->>BlockAllocation: set interface_initialization_exception if "error" present
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/executorlib/standalone/interactive/communication.py (1)
78-89: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
receive_dict()should return an error dict on crash
src/executorlib/standalone/interactive/communication.py:78-89still raisesExecutorlibSocketErrorwhen the spawner dies, buttests/unit/standalone/interactive/test_communication.py::test_interface_serial_with_stopped_processand the downstream task code now expect{"error": ExecutorlibSocketError(...)}. That exception will bypass the newoutput["error"]handling. Replace the raise with an error dict here.🤖 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 `@src/executorlib/standalone/interactive/communication.py` around lines 78 - 89, `receive_dict()` in `Communication` still raises `ExecutorlibSocketError` when `_spawner.poll()` indicates the process has crashed, but callers now expect an error payload instead. Update the crash branch in `receive_dict()` to return a dictionary with an `error` key containing the `ExecutorlibSocketError` instance, and keep the existing receive/logging flow unchanged for the non-crash path.
🤖 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 `@src/executorlib/task_scheduler/interactive/shared.py`:
- Around line 146-150: In the success path inside the shared task scheduler
flow, `result` is undefined when handling the `if "result" in output` branch,
causing a `NameError` after cache writes. Update the
`future_obj.set_result(...)` call in the relevant function in `shared.py` to use
the value already extracted from `output` (the same one stored in
`data_dict["output"]`), and keep the cache-hit and cache-miss branches
consistent.
---
Outside diff comments:
In `@src/executorlib/standalone/interactive/communication.py`:
- Around line 78-89: `receive_dict()` in `Communication` still raises
`ExecutorlibSocketError` when `_spawner.poll()` indicates the process has
crashed, but callers now expect an error payload instead. Update the crash
branch in `receive_dict()` to return a dictionary with an `error` key containing
the `ExecutorlibSocketError` instance, and keep the existing receive/logging
flow unchanged for the non-crash path.
🪄 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: 6d9ef240-a317-4665-863d-03059fea6136
📒 Files selected for processing (4)
src/executorlib/standalone/interactive/communication.pysrc/executorlib/task_scheduler/interactive/blockallocation.pysrc/executorlib/task_scheduler/interactive/shared.pytests/unit/standalone/interactive/test_communication.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1029 +/- ##
==========================================
- Coverage 94.23% 94.22% -0.02%
==========================================
Files 39 39
Lines 2118 2113 -5
==========================================
- Hits 1996 1991 -5
Misses 122 122 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary by CodeRabbit