Skip to content

[OPIK-5247] [BE] fix: preserve assertion results and status after experiment item aggregation#5999

Merged
thiagohora merged 1 commit intomainfrom
thiaghora/OPIK-5247-fix-assertion-results-not-displayed-after-aggregation
Mar 31, 2026
Merged

[OPIK-5247] [BE] fix: preserve assertion results and status after experiment item aggregation#5999
thiagohora merged 1 commit intomainfrom
thiaghora/OPIK-5247-fix-assertion-results-not-displayed-after-aggregation

Conversation

@thiagohora
Copy link
Copy Markdown
Contributor

Details

After experiment items are aggregated into experiment_item_aggregates, two DAO branches responsible for reading pre-computed data were silently discarding assertionResults and status:

  • ExperimentItemDAO (has_aggregated branch): was returning '' AS assertions_array (hardcoded empty string) instead of reading ei.assertions_array from the aggregates table.
  • DatasetItemVersionDAO (has_aggregated branch): was live-joining assertion_results at query time instead of reading the already-aggregated eia.assertions_array column.

This caused assertionResults and status to disappear from experiment items after aggregation runs.

Fix:

  • ExperimentItemDAO: read ei.assertions_array from experiment_item_aggregates
  • DatasetItemVersionDAO: read eia.assertions_array from experiment_item_aggregates instead of joining assertion_results
  • ExperimentAggregatesDAO: added GET_ASSERTIONS_ARRAY aggregation step that serializes assertion results (name, passed, reason) into a JSON array and stores it in assertions_array
  • ExperimentSourceData: added assertionsArray field to carry the aggregated data through the pipeline
  • Migration 000076: adds assertions_array String DEFAULT '[]' column to experiment_item_aggregates
  • ExperimentAggregatesIntegrationTest: two new integration tests covering both the stream endpoint and dataset items view, verifying that assertionResults and status are identical before and after aggregation

Change checklist

  • User facing
  • Documentation update

Issues

  • OPIK-5247

Testing

Two new integration tests added to ExperimentAggregatesIntegrationTest:

  1. assertionResultsArePreservedAfterExperimentItemAggregation — creates an evaluation suite experiment with assertion scores on one trace, verifies assertionResults and status are present in the raw path, runs aggregation, then verifies the aggregated path returns identical data via whole-object recursive comparison.

  2. assertionResultsInDatasetItemsArePreservedAfterAggregation — same scenario via the dataset items endpoint, verifies before/after parity using assertDatasetItemsWithExperimentItems (which now includes order-insensitive assertionResults comparison).

Documentation

No documentation changes required. Internal fix to aggregation pipeline.

…eriment item aggregation

When experiment items are aggregated into experiment_item_aggregates,
the has_aggregated branch in ExperimentItemDAO was returning an empty
string for assertions_array instead of reading the stored value from
the aggregates table. Similarly, DatasetItemVersionDAO was live-joining
assertion_results instead of reading from experiment_item_aggregates.

Changes:
- ExperimentItemDAO: has_aggregated branch now reads ei.assertions_array
  from experiment_item_aggregates instead of returning '' AS assertions_array
- DatasetItemVersionDAO: has_aggregated branch now reads eia.assertions_array
  from experiment_item_aggregates instead of live-joining assertion_results
- ExperimentAggregatesDAO: added GET_ASSERTIONS_ARRAY aggregation step that
  collects assertion names, pass/fail values, and reasons into a JSON array
  stored in experiment_item_aggregates.assertions_array
- ExperimentSourceData: added assertionsArray field to carry aggregated data
- Migration 000076: adds assertions_array String DEFAULT '[]' column to
  experiment_item_aggregates
- ExperimentAggregatesIntegrationTest: two new integration tests verifying
  that assertionResults and status are preserved before and after aggregation
  in both the stream endpoint and the dataset items view

Implements OPIK-5247
@thiagohora thiagohora requested a review from a team as a code owner March 31, 2026 12:10
@github-actions github-actions Bot added java Pull requests that update Java code Backend tests Including test files, or tests related like configuration. labels Mar 31, 2026
@thiagohora thiagohora added the test-environment Deploy Opik adhoc environment label Mar 31, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔄 Test environment deployment process has started

Phase 1: Deploying base version 1.10.57-4747 (from main branch) if environment doesn't exist
Phase 2: Building new images from PR branch thiaghora/OPIK-5247-fix-assertion-results-not-displayed-after-aggregation
Phase 3: Will deploy newly built version after build completes

You can monitor the progress here.

@github-actions
Copy link
Copy Markdown
Contributor

Backend Tests - Integration Group 15

 26 files   26 suites   3m 18s ⏱️
236 tests 235 ✅ 0 💤 0 ❌ 1 🔥
235 runs  235 ✅ 0 💤 0 ❌

For more details on these errors, see this check.

Results for commit 0232a93.

@CometActions
Copy link
Copy Markdown
Collaborator

Test environment is now available!

To configure additional Environment variables for your environment, run [Deploy Opik AdHoc Environment workflow] (https://github.com/comet-ml/comet-deployment/actions/workflows/deploy_opik_adhoc_env.yaml)

Access Information

The deployment has completed successfully and the version has been verified.

Copy link
Copy Markdown
Contributor

@ldaugusto ldaugusto left a comment

Choose a reason for hiding this comment

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

LGTM

@thiagohora thiagohora merged commit a24607c into main Mar 31, 2026
94 checks passed
@thiagohora thiagohora deleted the thiaghora/OPIK-5247-fix-assertion-results-not-displayed-after-aggregation branch March 31, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backend java Pull requests that update Java code test-environment Deploy Opik adhoc environment tests Including test files, or tests related like configuration.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants