fix(experiments): remove evals from main execution span #1433
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Important
Move evaluator execution outside the main execution span in
_process_experiment_item()to improve error handling and separation of concerns._process_experiment_item()inclient.py.This description was created by
for 65a9523. You can customize this summary. It will automatically update as commits are pushed.
Disclaimer: Experimental PR review
Greptile Overview
Greptile Summary
Refactored
_process_experiment_itemto move evaluator execution outside the main try-block, separating evaluation logic from the primary task execution within the span.output,input_data,trace_id, etc.) remain accessible since they're initialized before the try-block endswithstatement scopeConfidence Score: 5/5
Important Files Changed
File Analysis
Sequence Diagram
sequenceDiagram participant Client participant Span as Experiment Item Span participant Task as Main Task participant Evaluators Client->>Span: start_as_current_span("experiment-item-run") activate Span Note over Span: Try Block Start Span->>Span: Initialize variables (input_data, expected_output, etc.) Span->>Task: await _run_task(task, item) Task-->>Span: output Span->>Span: update(input, output, metadata) Note over Span: Try Block End alt Exception in try block Span->>Span: update(level=ERROR, status_message) Span-->>Client: raise exception Note over Evaluators: Evaluators NOT executed else Success Note over Span,Evaluators: NEW: Evaluators run AFTER try block loop For each evaluator Span->>Evaluators: await _run_evaluator() Evaluators-->>Span: eval_results Span->>Span: create_score() end Span-->>Client: return ExperimentItemResult end deactivate Span