Skip to content

[NA] [SDK] chore: better exception for evaluate_experiment with no te…#5855

Open
kriogenia wants to merge 1 commit intocomet-ml:mainfrom
kriogenia:NA-meaningful-error-for-evaluate-experiment-with-no-test-case
Open

[NA] [SDK] chore: better exception for evaluate_experiment with no te…#5855
kriogenia wants to merge 1 commit intocomet-ml:mainfrom
kriogenia:NA-meaningful-error-for-evaluate-experiment-with-no-test-case

Conversation

@kriogenia
Copy link
Copy Markdown

Details

Adds a custom and meaningful error to return when evaluate_experiment is called
with an experiment with no test cases. Previously the error was an index out of bounds.

Change checklist

  • User facing
  • Documentation update

Issues

  • NA

AI-WATERMARK

AI-WATERMARK: [no]

Testing

  • No suitable place for the unit test was found
  • Logic is the same but a better error is thrown

Documentation

  • Updated evaluate_experiment docstring to signal the test case requirement.

@kriogenia kriogenia marked this pull request as ready for review March 25, 2026 16:00
@kriogenia kriogenia requested a review from a team as a code owner March 25, 2026 16:00
Comment on lines 578 to 582
"""Update the existing experiment with new evaluation metrics. You can use either `scoring_metrics` or `scorer_functions` to calculate
evaluation metrics. The scorer functions doesn't require `scoring_key_mapping` and use reserved parameters
to receive inputs and outputs from the task.
to receive inputs and outputs from the task. The experiment requires at least one test case.

Args:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring doesn't mention that exceptions.EmptyExperiment is raised when test_cases is empty — should we document this in the Raises section?

Finding type: Document behavior and context | Severity: 🟢 Low


Want Baz to fix this for you? Activate Fixer

Other fix methods

Fix in Cursor

Prompt for AI Agents:

Before applying, verify this suggestion against the current code. In
sdks/python/src/opik/evaluation/evaluator.py around lines 578 to 582, the
evaluate_experiment docstring mentions that the experiment requires at least one test
case but does not document the new runtime behavior where the function raises
exceptions.EmptyExperiment if there are no test cases. Update the docstring by adding a
concise 'Raises' subsection (or one-line sentence in the existing docstring) that
states: exceptions.EmptyExperiment is raised when the experiment has no test traces/test
cases to evaluate. Keep the wording consistent with the existing Args style and place it
near the top of the docstring so callers know to catch or propagate this exception.

@kriogenia kriogenia force-pushed the NA-meaningful-error-for-evaluate-experiment-with-no-test-case branch from 86aff04 to 2341fbe Compare March 25, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant