schrodinger.application.models.library.library module¶
- class schrodinger.application.models.library.library.Library(client: AbstractLibraryClient)¶
Bases:
objectHigh-level library API providing composite operations and access to model trees for querying and validation.
- __init__(client: AbstractLibraryClient)¶
Initialize the library with a client for CRUD operations.
- Parameters:
client – The library client for CRUD operations
- getAllExecutionRecords() list[ExecutionRecord]¶
Get all execution records in the library.
- Returns:
List of all execution records
- getModelTree(model_def: ModelDefinition) ModelTree¶
Get the ModelTree for a given model definition.
- Parameters:
model_def – The model definition
- Returns:
The corresponding ModelTree
- Raises:
ValueError – If no ModelTree is found for the definition
- getDefinitions() list[ModelDefinition]¶
List all model definitions in the library.
- Returns:
List of all model definitions
- refresh() None¶
- buildCompositeFromSnapshot(version_snapshot: VersionSnapshot) CompositeModel¶
Build a CompositeModel from a version snapshot.
Fetches the exact definition and configuration versions stored in the VersionSnapshot to enable rerunning a model.
- Parameters:
version_snapshot – The version snapshot to reconstruct from.
- Returns:
A CompositeModel with the exact versions from the snapshot.
- Raises:
ModelNotFoundError – If any definition or configuration version is not found in the library.
- getDefinitionVersions(def_id: str) list[ModelDefinition]¶
Get all versions of a definition.
- Parameters:
def_id – The definition ID
- Returns:
List of all versions of the definition
- getConfigurationVersions(config_id: str) list[ModelConfiguration]¶
Get all versions of a configuration.
- Parameters:
config_id – The configuration ID
- Returns:
List of all versions of the configuration
- createDefinition(model_def: ModelDefinition) ModelDefinition¶
Create a new definition in the library.
- Parameters:
model_def – The model definition to create
- Returns:
The created definition
- Raises:
ModelExistsError – If a definition with the same ID and version already exists
- updateDefinition(model_def: ModelDefinition) ModelDefinition¶
Update an existing definition in the library.
After saving, synchronizes all child configurations so their inputs match the updated definition (adding missing inputs, removing stale ones).
- Parameters:
model_def – The model definition to update
- Returns:
The updated definition
- Raises:
ModelNotFoundError – If the definition ID is not found
- createConfiguration(model_config: ModelConfiguration) ModelConfiguration¶
Create a new configuration in the library.
- Parameters:
model_config – The model configuration to create
- Returns:
The created configuration
- Raises:
ModelExistsError – If a configuration with the same ID and version already exists
- updateConfiguration(model_config: ModelConfiguration) ModelConfiguration¶
Update an existing configuration in the library.
- Parameters:
model_config – The model configuration to update
- Returns:
The updated configuration
- Raises:
ModelNotFoundError – If the configuration ID is not found
UpdateVersionError – If the new version is less than the current highest version
- deleteDefinition(def_id: str) None¶
Delete a definition and all its configurations from the library.
- Parameters:
def_id – The definition ID to delete
- Raises:
ModelNotFoundError – If the definition is not found
- deleteConfiguration(config_id: str) None¶
Delete a configuration and all its child configurations.
- Parameters:
config_id – The configuration ID to delete
- Raises:
ModelNotFoundError – If the configuration is not found
- createExecutionRecord(record: ExecutionRecord) ExecutionRecord¶
Store an execution record and its output files in the library.
Takes a partial ExecutionRecord (without record_id) and returns a complete ExecutionRecord with record_id assigned and output_files processed.
- Parameters:
record – Partial ExecutionRecord from a runner.
- Returns:
Complete ExecutionRecord as stored in the library.
- getExecutionRecord(record_id: str) ExecutionRecord¶
Get an execution record from the library.
- Parameters:
record_id – The execution record ID
- Returns:
The execution record
- Raises:
ExecutionRecordNotFoundError – If the record is not found
- getCurrentUser() str¶
Get the current user’s username.
- Returns:
The current user’s username
- isLDLibrary() bool¶
Return True if the library uses the LiveDesign backend.
- getAllExecutionRecordIds() list[str]¶
Get all execution record IDs in the library.
- createStoredFile(source_path: str) StoredFile¶
Store a file in the library and return the complete StoredFile.
Copies the file at source_path into the library and returns a StoredFile with file_id, file_name, and timestamp assigned.
- Parameters:
source_path – Path to the file to store.
- Returns:
Complete StoredFile with file_id assigned.
- getStoredFile(file_id: str) StoredFile¶
Retrieve a stored file’s metadata by its ID.
- Parameters:
file_id – The unique ID of the stored file.
- Returns:
The StoredFile object with metadata.
- Raises:
StoredFileNotFoundError – If the file doesn’t exist.
- downloadStoredFile(file_id: str, dest_path: str) None¶
Download a stored file to the specified destination.
- Parameters:
file_id – The ID of the stored file to download.
dest_path – Path where the file should be written.
- Raises:
StoredFileNotFoundError – If the file doesn’t exist.
- getFileNameMapping(composite_model: CompositeModel) dict[str, str]¶
Build a mapping from stored file IDs to original filenames.
Scans the composite model for FILE and STRUCTURE inputs and resolves each file ID to its original filename via the library client.
- Parameters:
composite_model – The composite model to scan.
- Returns:
A dictionary mapping file IDs to filenames.