Summary
Add validation logic to lib/score_calibrations.py that enforces calibration controls reference variants belonging to the calibration's associated score set.
Background
Controls are restricted to variants in the calibration's score set by design — a control without a DMS score would be meaningless for calibration. This constraint must be enforced at the API layer before any controls are persisted.
Proposed Behavior
When controls are provided in a calibration create or modify request:
- Resolve each control's
variant_urn to a Variant record
- Verify
variant.score_set_id == calibration.score_set_id for every control
- Raise a
ValidationError (consistent with existing validation patterns) for any controls whose variant does not belong to the score set, listing the offending URNs
- Raise a
ValidationError if any variant_urn does not exist in MaveDB at all
Acceptance Criteria
Implementation Notes
- Validation should be placed in
lib/score_calibrations.py, consistent with the location of other calibration validation helpers
- Batch the DB query: look up all variant URNs in one query and diff against the submitted set — avoid per-control round trips
- Follow the pattern of
validate_index_existence_in_score_set in lib/validation/dataframe/calibration.py
- Duplicate
(calibration_id, variant_id) pairs are handled by the UNIQUE DB constraint; the API should still return a friendly validation error before hitting the DB constraint
Summary
Add validation logic to
lib/score_calibrations.pythat enforces calibration controls reference variants belonging to the calibration's associated score set.Background
Controls are restricted to variants in the calibration's score set by design — a control without a DMS score would be meaningless for calibration. This constraint must be enforced at the API layer before any controls are persisted.
Proposed Behavior
When controls are provided in a calibration create or modify request:
variant_urnto aVariantrecordvariant.score_set_id == calibration.score_set_idfor every controlValidationError(consistent with existing validation patterns) for any controls whose variant does not belong to the score set, listing the offending URNsValidationErrorif anyvariant_urndoes not exist in MaveDB at allAcceptance Criteria
ValidationErrornaming the invalid URNsvariant_urnis rejected with aValidationErrorcontrolsisNoneor emptyImplementation Notes
lib/score_calibrations.py, consistent with the location of other calibration validation helpersvalidate_index_existence_in_score_setinlib/validation/dataframe/calibration.py(calibration_id, variant_id)pairs are handled by the UNIQUE DB constraint; the API should still return a friendly validation error before hitting the DB constraint