fix: limit swarm callback concurrency - #129
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughAdded a ChangesSwarm callback concurrency
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Hatchet
participant HatchetMageflow
participant OnSwarmItemDone
Hatchet->>HatchetMageflow: init_mageflow_hatchet_tasks()
HatchetMageflow->>OnSwarmItemDone: register task with ConcurrencyExpression(swarm_task_id, swarm_item_id)
Hatchet-->>OnSwarmItemDone: duplicate done/error trigger
OnSwarmItemDone-->>OnSwarmItemDone: run serialized via GROUP_ROUND_ROBIN (max_runs=1)
Related issues: None specified. Suggested labels: bug, mageflow Suggested reviewers: None specified. Poem: 🚥 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.
🧹 Nitpick comments (1)
libs/mageflow/tests/unit/clients/test_hatchet_mageflow_tasks.py (1)
21-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicated
fake_durable_tasktest double.Same closure is redefined in both tests. Consider extracting it into a shared fixture/helper to avoid drift between the two copies.
♻️ Example fixture extraction
+@pytest.fixture +def registered_tasks_recorder(hatchet_mock, monkeypatch): + registered_tasks = {} + + def fake_durable_task(**kwargs): + registered_tasks[kwargs["name"]] = kwargs + + def decorator(func): + return func + + return decorator + + monkeypatch.setattr(hatchet_mock, "durable_task", fake_durable_task) + return registered_tasksAlso applies to: 69-75
🤖 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 `@libs/mageflow/tests/unit/clients/test_hatchet_mageflow_tasks.py` around lines 21 - 27, The test double fake_durable_task is duplicated across the two tests, so extract it into a shared helper or pytest fixture and reuse it from both test cases. Keep the behavior centralized around the registered_tasks capture and decorator closure so future changes only need to be made in one place, and update the tests to reference the shared helper instead of redefining fake_durable_task locally.
🤖 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 `@libs/mageflow/tests/unit/clients/test_hatchet_mageflow_tasks.py`:
- Around line 21-27: The test double fake_durable_task is duplicated across the
two tests, so extract it into a shared helper or pytest fixture and reuse it
from both test cases. Keep the behavior centralized around the registered_tasks
capture and decorator closure so future changes only need to be made in one
place, and update the tests to reference the shared helper instead of redefining
fake_durable_task locally.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 380a8f23-84d0-4a74-91e7-a99028fd5743
📒 Files selected for processing (4)
CHANGELOG.mdlibs/mageflow/mageflow/clients/hatchet/mageflow.pylibs/mageflow/mageflow/swarm/consts.pylibs/mageflow/tests/unit/clients/test_hatchet_mageflow_tasks.py
55eff4e to
a486a3a
Compare
a486a3a to
978bcd4
Compare
978bcd4 to
ff6432c
Compare
ff6432c to
9521891
Compare
Summary
swarm_task_idandswarm_item_idfill_running_tasksconcurrency behavior unchangedTesting
uv run pytest tests/unit -W errorfromlibs/mageflow- 257 passeduv run pytest tests/unit/clientsfromlibs/mageflow- 50 passeduv run pytest tests/unit/workflowsfromlibs/mageflow- 27 passeduv run black --check mageflow/clients/hatchet/workflow.py mageflow/testing/_adapter.py mageflow/testing/plugin.pyfromlibs/mageflowuv run ruff check mageflow/clients/hatchet/workflow.py mageflow/testing/_adapter.py mageflow/testing/plugin.py pyproject.tomlfromlibs/mageflowNotes
Linear issue lookup could not be completed because the Linear app connection requires reauthentication (
oauth_token_invalid_grant), so this PR uses the fallback branch name from the implementation plan.