File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 3535from .scorers import scorer_function , scorer_wrapper_metric
3636from . import test_result
3737from .types import ExperimentScoreFunction , LLMTask , ScoringKeyMappingType
38- from .. import url_helpers
38+ from .. import url_helpers , exceptions
3939from ..api_objects .dataset .evaluation_suite import suite_result_constructor
4040
4141if TYPE_CHECKING :
@@ -577,7 +577,7 @@ def evaluate_experiment(
577577) -> evaluation_result .EvaluationResult :
578578 """Update the existing experiment with new evaluation metrics. You can use either `scoring_metrics` or `scorer_functions` to calculate
579579 evaluation metrics. The scorer functions doesn't require `scoring_key_mapping` and use reserved parameters
580- to receive inputs and outputs from the task.
580+ to receive inputs and outputs from the task. The experiment requires at least one test case.
581581
582582 Args:
583583 experiment_name: The name of the experiment to update.
@@ -637,6 +637,11 @@ def evaluate_experiment(
637637 dataset_ = dataset_ ,
638638 scoring_key_mapping = scoring_key_mapping ,
639639 )
640+ if not test_cases :
641+ raise exceptions .EmptyExperiment (
642+ f"Experiment { experiment .id } does not have any test traces to run an evaluation"
643+ )
644+
640645 first_trace_id = test_cases [0 ].trace_id
641646 project_name = rest_operations .get_trace_project_name (
642647 client = client , trace_id = first_trace_id
Original file line number Diff line number Diff line change @@ -102,6 +102,12 @@ class ExperimentNotFound(OpikException):
102102 pass
103103
104104
105+ class EmptyExperiment (OpikException ):
106+ """Exception raised when an experiment requires test cases for evaluation and has none"""
107+
108+ pass
109+
110+
105111class DatasetNotFound (OpikException ):
106112 pass
107113
You can’t perform that action at this time.
0 commit comments