-
[OPIK-5269] [BE] feat: expose trace metadata on experiment item compare (#6940)
发布于
2026-06-02 09:33:59 +00:00 - [OPIK-5269] [BE] feat: expose trace metadata on experiment item compare
Surfaces the trace's
metadataJSON on the experiment-item join
returned byGET /v1/private/datasets/{id}/items/experiments/items.
The ClickHouse query already pulledtfs.metadatainto the per-item
tuple (position 16) for both the live and the version-pinned paths;
the mapper just dropped it on the floor.This unblocks
opik.evaluate_resume(OPIK-5269) — the SDK reads
trace metadata from the item-compare response to distinguish trials
that completed the full happy path from those whose task succeeded
but whose scoring crashed mid-way (the marker is set by the SDK and
round-trips through this field). Without this projection, resume
would have to fetch each trace individually, one round-trip per row.Adds
ExperimentItem.traceMetadata: JsonNode(Compare view) and
the matching mapper line inDatasetItemResultMapper. No schema
migration, no new join, no query change.Includes the regenerated
openapi.yamlfor both the docs spec and
Fern's input. The Python and TypeScriptrest_apiregens land in a
follow-up auto-PR after this merges.- chore: drop openapi.yaml regen; rely on main's autogen PR
openapi.yaml lands via the automated regen PR (see history:
8930b66fcb,5c618b7f33,dc90a9116bet al). Feature BE PRs shouldn't carry it.- test(be): cover trace_metadata projection on the experiment-item compare
Two focused tests under
DatasetsResourceTest.TraceMetadataOnExperimentItemCompareTest:- Trace metadata round-trips through the compare endpoint into
ExperimentItem.traceMetadataverbatim — the SDK consumer uses
this forevaluate_resume's marker-based completion check
(OPIK-5269). traceMetadataisnullwhen the trace has no metadata.
Locks in the new mapper line (tuple position 16) so a future ordering
change in the ClickHouse query tuple would be caught here, not later
in SDK integration.- test(be): ignore traceMetadata in shape-comparison list
The 16 failing assertions in
FindDatasetItemsWithExperimentItems
compared a PODAM-built expectedExperimentItem(notraceMetadata
override → null) against the actual response where the new mapper
correctly projects the trace's metadata. Same pattern already in place
for sibling fields the tests don't drive (feedbackScores,
comments,createdAt…);traceMetadatajoins them.The dedicated
TraceMetadataOnExperimentItemCompareTestclass still
exercises the projection explicitly.- test(be): consolidate trace-metadata projection tests via @ParameterizedTest
Address baz-reviewer feedback on #6940: collapses the two @Test
methods into a single @ParameterizedTest backed bytraceMetadataCases,
parameterizing over the (trace.metadata, expected) pair. The
workspace/dataset/experiment scaffolding is now defined once.下载附件