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: NamedTuple

The 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 version and returns it (e.g. renaming a key). Each adapter only needs to bring settings current as of version; 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 config up to target_version by running each transform’s upgrade adapters whose version is newer than the config’s current version, then stamp the config with target_version.

Parameters:
  • config – The model configuration to upgrade in place.

  • target_version – The mmshare version to bring the config up to.