feat(benchmark): task-level routing stats for Harbor runs#116
Conversation
|
Signed-off-by: Ryan Lempka <rlempka@nvidia.com>
… sidecar Signed-off-by: Ryan Lempka <rlempka@nvidia.com>
…at finalize Signed-off-by: Ryan Lempka <rlempka@nvidia.com>
eb58d51 to
e192824
Compare
WalkthroughSwitchyard now tags proxy requests with task/session metadata, optionally logs routing details for completed responses, and summarizes those logs into per-task benchmark artifacts during manifest finalization. CLI behavior, benchmark wiring, documentation, and tests cover the new flow. ChangesRouting observability
Estimated code review effort: 3 (Moderate) | ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 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 `@benchmark/run_manifest.py`:
- Around line 248-261: Update the aggregation logic around the model bucket in
the manifest processing function to key buckets by both model and tier,
preventing records with different tiers from being merged. Preserve the existing
call and token accumulation behavior within each model/tier bucket, and add
coverage in test_run_manifest.py for mixed-tier records.
- Around line 265-272: Add a concise triple-quoted docstring to the public
finalize_manifest function describing its artifact-copy behavior, optional
routing-log aggregation, and returned exit code. Keep the documentation focused
on the function’s existing behavior without changing its implementation.
In `@switchyard/lib/processors/routing_log_response_processor.py`:
- Around line 41-54: The public process method lacks the required documentation.
Add a concise triple-quoted docstring to RoutingLogResponseProcessor.process
stating that it returns the response unchanged and emits streaming records only
after normal drain; leave the callback and response-processing behavior
unchanged.
- Around line 46-69: Update the response completion callback `_emit` and
`_write_record` flow so the synchronous lock acquisition and file append run via
`asyncio.to_thread()` instead of blocking the event loop. Preserve the existing
record construction, serialization, and write behavior while awaiting the
offloaded operation from `_emit`.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 6a4fdbfb-6276-43aa-9285-3bd1640c218b
📒 Files selected for processing (11)
benchmark/README.mdbenchmark/closed_book_proxy/proxy/rewriter.pybenchmark/prepare_harbor_dataset.pybenchmark/run-baseline.shbenchmark/run_manifest.pydocs/cli_reference.mdswitchyard/cli/switchyard_cli.pyswitchyard/lib/processors/routing_log_response_processor.pytests/test_prepare_harbor_dataset.pytests/test_routing_log_response_processor.pytests/test_run_manifest.py
Signed-off-by: Ryan Lempka <rlempka@nvidia.com>
Signed-off-by: Ryan Lempka <rlempka@nvidia.com>
Harbor runs previously captured routing stats only as one run-global snapshot. This adds task-level routing stats to every Switchyard benchmark run.
serve --routing-log-fileappends one JSONL record per request: task, session, selected model, tier, token usagex-switchyard-intake-task(baked per task at dataset prep) and a per-trialproxy_x_session_idon model-bound requestsrun-baseline.shenables the log and finalize rolls it up intorouting_stats_by_task.jsonnext torouting_stats_final.jsonTested with the unit suite, a live serve driven by headless claude and codex plus all three inbound formats (records attribute correctly, streaming included), and a 2-task concurrent Harbor smoke where both task ids appear in the log and the rollup matches the job results.
Linear: SWITCH-1033
Summary by CodeRabbit
New Features
switchyard serve, including model, routing tier, task, session, and token usage details.Documentation
Tests