Skip to content

feat(export): expose include_code_metric_metadata on export_records#587

Open
AnkushMalaker wants to merge 2 commits into
mainfrom
ankush/export-include-code-metric-metadata
Open

feat(export): expose include_code_metric_metadata on export_records#587
AnkushMalaker wants to merge 2 commits into
mainfrom
ankush/export-include-code-metric-metadata

Conversation

@AnkushMalaker
Copy link
Copy Markdown
Contributor

@AnkushMalaker AnkushMalaker commented May 15, 2026

User description

Summary

  • Adds an opt-in include_code_metric_metadata: bool = False kwarg to ExportClient.records and the top-level export_records function so SDK callers can request that per-row scorer metadata (the dict returned alongside the score by code-based scorers via the (score, metadata) tuple-return contract) be included on each MetricSuccess in the exported payload.
  • Adds the matching field to the generated LogRecordsExportRequest model so it serializes to the API correctly. This file is normally regenerated from the OpenAPI spec — once the API PR merges and the OpenAPI spec is regenerated, re-running the codegen will re-emit this cleanly. Until then, the manual patch is the source of truth.
  • Defaults to False, so existing callers and payload sizes are unchanged.

Dependency

This is the user-facing surface for an end-to-end change. The API-side change lives in rungalileo/api#6529. Until that merges and deploys, requests sent with include_code_metric_metadata=True will succeed but the server will silently drop the field.

The orbit-side MetricSuccessBase.metadata declaration is already on orbit main (orbit#596) and already in api's pinned orbit ref, so no orbit work is blocking this.

Test plan

  • Added test_export_records_include_code_metric_metadata_default / _opt_in in tests/test_export.py that assert the kwarg flows into the request body and serializes correctly via to_dict.
  • poetry run pytest tests/test_export.py — 17 passed locally.
  • End-to-end sanity check against a deployed API that includes the upstream change.

Generated description

Below is a concise technical summary of the changes proposed in this PR:
Add optional include_code_metric_metadata parameters to ExportClient.records and export_records so callers can request per-row scorer metadata on each exported MetricSuccess. Update LogRecordsExportRequest serialization to carry the new flag through the API payload.

TopicDetails
Metadata export opt-in Extend ExportClient.records and export_records to accept include_code_metric_metadata so callers can opt into per-row scorer metadata, and verify the flag defaults to False and flows through via test_export_records_include_code_metric_metadata_default/_opt_in.
Modified files (2)
  • src/galileo/export.py
  • tests/test_export.py
Latest Contributors(2)
UserCommitDate
AnkushMalakerstyle(test): apply ruf...May 15, 2026
thiago.bomfin@galileo.aifeat(log-stream): add ...May 13, 2026
Request serialization Update LogRecordsExportRequest to persist include_code_metric_metadata through to_dict/from_dict so the exported payload serializes the opt-in flag for the API.
Modified files (1)
  • src/galileo/resources/models/log_records_export_request.py
Latest Contributors(2)
UserCommitDate
AnkushMalakerfeat(export): expose i...May 15, 2026
thiago.bomfin@galileo.aifix: schema patches (#...April 29, 2026
Review this PR on Baz | Customize your next review

Adds an opt-in include_code_metric_metadata kwarg to ExportClient.records
and the top-level export_records function so callers can request that
per-row scorer metadata (the dict returned alongside the score by
code-based scorers via the (score, metadata) tuple-return contract) be
included on each MetricSuccess in the exported payload. Defaults to
False to preserve current payload sizes.

The matching field is added by hand to the generated
LogRecordsExportRequest model so it serializes correctly; the next
OpenAPI regen against an API that has merged the API-side change will
re-emit this cleanly.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.27%. Comparing base (df4b61b) to head (debeaf2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #587   +/-   ##
=======================================
  Coverage   83.27%   83.27%           
=======================================
  Files         125      125           
  Lines       10617    10617           
=======================================
  Hits         8841     8841           
  Misses       1776     1776           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

]
) = UNSET
sort: Union["LogRecordsSortClause", None, Unset] = UNSET
include_code_metric_metadata: Unset | bool = False
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.

Since src/galileo/resources/ is generated from openapi.yaml by scripts/auto-generate-api-client.sh, adding include_code_metric_metadata via a manual edit won’t survive regeneration—should we add the field to the LogRecordsExportRequest schema in the OpenAPI source and rerun the generator?

Finding type: AI Coding Guidelines | 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
src/galileo/resources/models/log_records_export_request.py around lines 75-169 (class
LogRecordsExportRequest, methods to_dict and from_dict), you manually added the
include_code_metric_metadata field and included it in serialization/deserialization.
This violates the auto-generated-client boundary (everything under
src/galileo/resources/ must come from the OpenAPI spec) and will be overwritten by the
next regeneration. Fix it by adding include_code_metric_metadata to the
LogRecordsExportRequest schema in openapi.yaml (with the correct type/optional behavior
matching the desired default), then rerun scripts/auto-generate-api-client.sh to
regenerate src/galileo/resources/, and finally delete/undo the manual edits so the
generated file reflects only the regenerated output.

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