schrodinger.application.models.datamodels.upgrade module¶
Version-aware upgrade mechanism for v2 model configurations.
A transform’s Pydantic config class declares how its settings have been renamed
over time via version-keyed upgrade adapters (mirroring json.py’s
@adapter chain). When a new build ships a definition for a newer mmshare
version, upgrade_config walks a configuration’s transform bindings, looks up
each transform’s config class, and runs its adapters to bring the binding’s
setting names forward.
Adapters operate on a {name: SettingFields} dict (settings keyed by name for
easy lookup) and return the migrated dict; the result is serialized back into
SettingBinding objects. The definition itself carries no migration logic –
it is simply correct for the mmshare version it is tied to.
- class schrodinger.application.models.datamodels.upgrade.SettingFields(value: str, child_constraint: ChildConstraint)¶
Bases:
NamedTupleThe mutable fields of a
SettingBinding, used as the value type of the{name: SettingFields}dict that upgrade adapters operate on.- value: str¶
Alias for field number 0
- child_constraint: ChildConstraint¶
Alias for field number 1
- schrodinger.application.models.datamodels.upgrade.upgrade_adapter(version: int) Callable¶
Decorate a transform (or config) method that migrates a settings dict up to
versionand returns it (e.g. renaming a key). Each adapter only needs to bring settings current as ofversion; later renames add higher-versioned adapters and the chain composes.- Parameters:
version – The mmshare version this adapter brings settings up to.
- schrodinger.application.models.datamodels.upgrade.upgrade_config(config: ModelConfiguration, target_version: int) None¶
Bring
configup totarget_versionby running each transform’s upgrade adapters whose version is newer than the config’s current version, then stamp the config withtarget_version.- Parameters:
config – The model configuration to upgrade in place.
target_version – The mmshare version to bring the config up to.