Fetching a test case's history
In Opik 2.0, datasets and experiments are project-scoped. Pass a project_name when you get the dataset or test
suite so it resolves in the right project.
To see how one test case has scored over time, fetch its results from every experiment that ran it. Opik reads them server-side, so you don’t need to list experiments or download whole experiments and filter them yourself. Each result says which experiment it came from, so you can chart a test case’s scores in your own dashboards.
One dataset item across every experiment
Get the dataset, then pass the item’s id. You get one result per experiment that ran the item, across every version of the dataset.
The item id is the id of each item returned by dataset.get_items(). A dataset item keeps its id when you edit
it, so the results cover every version of the item.
One test suite item across every experiment
A test suite has the same method, with the same parameters. When a suite runs each item more than once
(runs_per_item above 1), you get one result per run, each with its own trace and assertion results.
Narrowing to dataset versions
Without dataset_versions, results span every version of the item, including runs from before it was edited.
To compare only experiments that ran against particular versions, pass their hashes or tags:
A version that doesn’t exist raises opik.exceptions.DatasetVersionNotFound. Version names such as v3 aren’t
accepted yet; use the version’s hash or a tag. A test suite takes the same dataset_versions parameter for its
versions.
Labeling results with experiment names
Results carry the experiment’s id. To label them with experiment names, look the experiments up once:
Use get_test_suite_experiments(name=...) for a test suite. An experiment’s creation date is available from
experiment.get_experiment_data().created_at.
Several test cases at once
To read a slice of test cases in one call, for example every item with a team’s tag, use the experiments client with a filter on the dataset items. It returns the same result objects, grouped by item:
tags matches the item’s own tags, which you set in the Opik UI or with the REST client. A "tags" key passed to
dataset.insert() is stored as an ordinary data field, not as item tags. To tag items from code:
Tagging creates a new dataset version, and the filter matches each item as of the newest version among the experiments read. Tags added after the last experiment don’t match anything yet; once an experiment runs on the tagged version, the item’s earlier results match too.
The filter accepts dataset item fields: id, data, full_data, source, trace_id, span_id, tags,
created_at, last_updated_at, created_by and last_updated_by. Other fields, such as feedback scores, raise a
ValueError before any request is sent. This call also takes dataset_versions.
What each result carries
To see the input an experiment actually ran with, before a later edit, fetch its trace by trace_id.
Limits
- Optimizer trial, mini-batch and mutation experiments aren’t included; only regular experiments are.
max_resultsdefaults to 1,000. Results are read experiment by experiment, so a read that stops atmax_resultscan miss later experiments entirely. The SDK logs a warning when that happens; raisemax_resultsor narrow the read.
Next steps
- Exporting experiment results: export one experiment’s full result set to CSV.
- Building test suites: create test suites and run them.
- Manage datasets: dataset items, versions and tags.