Repository navigation
feat(ess): add Experiment.experiment_type with migration 018 - #1608
Draft
VLukiantsev wants to merge 3 commits into
Draft
VLukiantsev wants to merge 3 commits into
VLukiantsev wants to merge 3 commits into
Conversation
Introduce Experiment.ExperimentType {EXPERIMENT_TYPE_UNSPECIFIED, STANDARD,
STUDY} as immutable field 14 so that hyperparameter optimization studies can
be distinguished from regular experiments. "Standard" has a single meaning:
the server stores UNSPECIFIED as STANDARD, and experiments created before the
field existed read and filter as STANDARD.
Storage (dual backend, migration 018):
- Spanner: enum-typed column cloud.xmanager.v1.Experiment.ExperimentType
(added to the proto bundle), matching WorkUnits.WorkUnitType. The column
is nullable without a DEFAULT, because the Spanner emulator re-applies
DEFAULT values to columns omitted from Update mutations on tables with a
generated primary key, which would reset the type on every update. Legacy
NULL rows read as STANDARD, and the experiment_type filter uses
IFNULL(e.ExperimentType, STANDARD) while selecting the raw column.
- PostgreSQL: BIGINT NOT NULL DEFAULT 1 (STANDARD), so legacy rows get
STANDARD; the query field maps enum names via EnumValues.
- experiment_type = "STUDY" / "STANDARD" / != "STUDY" filters behave the same
on both backends. The value is written on insert and returned by
Fetch/List. Update paths never write it, and MergeExperiments rejects an
experiment_type update mask path, so the field stays immutable.
CreateExperiment normalizes UNSPECIFIED to STANDARD, rejects unknown enum
values with InvalidArgument (the field is create-only), and rejects STUDY
with Unimplemented before any XID or storage write. The STUDY guard is
temporary until CreateExperiment validates the components a study requires.
Bug: 580925123
TAG=agy
CONV=e35676e1-16d8-41b8-a81d-8654c90d18f6
There was a problem hiding this comment.
Code Review
This pull request introduces an ExperimentType field (supporting STANDARD and STUDY types) to the Experiment proto and integrates it across the application, including validation, PostgreSQL, and Spanner storage layers. It handles legacy database rows by defaulting them to STANDARD, ensures the field is immutable, and temporarily rejects the unsupported STUDY type with an unimplemented error. Feedback on the changes suggests improving a Spanner unit test by explicitly setting Valid: false in NullProtoEnum to represent a database NULL value more robustly.
The Spanner client requires a typed nil with Valid: true to represent NULL for NullProtoEnum; Valid: false is rejected by spanner.NewRow. Bug: 580925123 TAG=agy CONV=4c70456d-44cd-499c-a69d-9c5e775028d7
Cloud Spanner rejects inserting cloud.xmanager.v1.Experiment.ExperimentType
into the proto bundle unless its parent message cloud.xmanager.v1.Experiment
is bundled too ("references type ... which is not included in the proto
bundle"). The Spanner emulator does not enforce this, so it surfaced only
when applying migration 018 to a live Cloud Spanner instance. Bundle both,
matching WorkUnit / WorkUnit.WorkUnitType.
Bug: 580925123
TAG=agy
CONV=4c70456d-44cd-499c-a69d-9c5e775028d7
This branch has not been deployed
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.
Summary
Adds
Experiment.experiment_type(nested enumExperiment.ExperimentType:EXPERIMENT_TYPE_UNSPECIFIED,STANDARD,STUDY; field 14,IMMUTABLE) with migration 018 on Spanner and PostgreSQL. This is PR 1/2 of a stack for hyperparameter optimization (HPO) study ingestion;STUDYis rejected withUnimplementeduntil PR 2 adds component-requirement validation.Motivation & Context
HPO studies need to be distinguishable from regular experiments so that
CreateExperimentcan enforce their component requirements (hpo+ its dependencies) and later accept study configuration. Introducing the type first, behind a reject-all guard, keeps every change reachable without ever accepting a study that skipped the component check.Design choices:
WorkUnit.WorkUnitType, so filters use names on both backends (experiment_type = "STUDY"), likework_unit_type.UNSPECIFIEDasSTANDARD; experiments created before this field existed read and filter asSTANDARDon both backends.InvalidArgument) because the field is create-only and cannot be corrected later.Key Changes
api/protos/experiment/experiment.proto:ExperimentTypeenum +experiment_type = 14 [IMMUTABLE].DEFAULT, see Assumptions). Reads map NULL →STANDARD; the filter usesIFNULL(e.ExperimentType, STANDARD).BIGINT NOT NULL DEFAULT 1(STANDARD); query field maps enum names viaEnumValues.MergeExperimentsrejects anexperiment_typemask).CreateExperiment: normalizesUNSPECIFIED→STANDARD; temporarySTUDY→Unimplementedguard before any XID or storage write.internal/validator: rejects unknownExperimentTypevalues.Assumptions
DEFAULT— the Spanner emulator re-appliesDEFAULTvalues to columns omitted from partialUpdatemutations on tables with a generated primary key (observed in the emulator integration test: a title update resetSTUDY). Production Spanner does not do this — impact if wrong: none functionally; a later migration could backfill and addNOT NULL.api/testdata/protos_baseline.binpbis not refreshed — adding a field and nested enum is non-breaking, so//api:protos_breaking_testpasses unchanged.STUDYguard is intentionally temporary and is replaced in PR 2 of this stack.Verification & Testing
./.githooks/pre-commit(linters +./tools/run_affected_tests.py, 149/149 affected targets pass with the Spanner emulator and PostgreSQL in Docker); targetedbazel testfor Spanner data/experiment/migrations packages,//internal/storage/migrations/...(schema synchronization, up/down consistency, version parity),//internal/storage/postgres/experiment:experiment_test,//cmd/experiment_state_server/server:server_test.STANDARD/STUDYon both backends; legacy rows (Spanner NULL, PostgreSQL default) read asSTANDARDand match= "STANDARD"/!= "STUDY"but not= "STUDY";experiment_typeupdate mask rejected; title update keepsSTUDY(emulator);CreateExperiment(UNSPECIFIED)persistsSTANDARD;CreateExperiment(STUDY)returnsUnimplementedwith no XID or storage write; validator rejects unknown values.Related Issues / Bugs
Bug: 580925123
TAG=agy
CONV=4c70456d-44cd-499c-a69d-9c5e775028d7