feat(export): expose include_code_metric_metadata on export_records#587
Open
AnkushMalaker wants to merge 2 commits into
Open
feat(export): expose include_code_metric_metadata on export_records#587AnkushMalaker wants to merge 2 commits into
AnkushMalaker wants to merge 2 commits into
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
| ] | ||
| ) = UNSET | ||
| sort: Union["LogRecordsSortClause", None, Unset] = UNSET | ||
| include_code_metric_metadata: Unset | bool = False |
Contributor
There was a problem hiding this comment.
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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Summary
include_code_metric_metadata: bool = Falsekwarg toExportClient.recordsand the top-levelexport_recordsfunction 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 eachMetricSuccessin the exported payload.LogRecordsExportRequestmodel 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.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=Truewill succeed but the server will silently drop the field.The orbit-side
MetricSuccessBase.metadatadeclaration is already on orbitmain(orbit#596) and already in api's pinned orbit ref, so no orbit work is blocking this.Test plan
test_export_records_include_code_metric_metadata_default/_opt_inintests/test_export.pythat assert the kwarg flows into the request body and serializes correctly viato_dict.poetry run pytest tests/test_export.py— 17 passed locally.Generated description
Below is a concise technical summary of the changes proposed in this PR:
Add optional
include_code_metric_metadataparameters toExportClient.recordsandexport_recordsso callers can request per-row scorer metadata on each exportedMetricSuccess. UpdateLogRecordsExportRequestserialization to carry the new flag through the API payload.ExportClient.recordsandexport_recordsto acceptinclude_code_metric_metadataso callers can opt into per-row scorer metadata, and verify the flag defaults toFalseand flows through viatest_export_records_include_code_metric_metadata_default/_opt_in.Modified files (2)
Latest Contributors(2)
LogRecordsExportRequestto persistinclude_code_metric_metadatathroughto_dict/from_dictso the exported payload serializes the opt-in flag for the API.Modified files (1)
Latest Contributors(2)