schrodinger.application.transforms.ldml module¶
LDML transforms for LiveDesign ML.
This module provides the shared LDMLConfig base configuration for all
LDML-based transforms, as well as Apache Beam transforms for running
inference predictions on molecular structures using the LiveDesign ML API.
Authentication¶
LDML transforms rely on the LDMLClient singleton for LDML API access.
Use setup_client() to configure the singleton before running transforms.
There are two ways to authenticate:
Explicit credentials: Pass
ldml_urlandjsession_idto the transform config.setup_client()will callLDMLClient.createFromConfig()directly.Stored credentials: Pass only
ldml_url.setup_client()looks up a refresh token from the credentials store (seeschrodinger.application.livedesign.credentials) and authenticates via LiveDesign.
The transforms do not disconnect the LDMLClient on teardown, since the
singleton may be shared with other transforms in the same pipeline.
- class schrodinger.application.transforms.ldml.LDMLConfig(*, ldml_url: HttpUrl, ld_url: pydantic.networks.HttpUrl | None = None, jsession_id: str | None = None, polling_interval: int = 600, max_retries: int = 5)¶
Bases:
BaseModelBase configuration for LDML transforms.
Provides common authentication and polling fields shared across all LDML-based transforms. Subclass this to add task-specific fields (e.g. dataset name, project name).
- Parameters:
ldml_url – LDML server URL.
ld_url – LiveDesign server URL for authentication. Defaults to the scheme and host extracted from
ldml_url.jsession_id – LiveDesign session token. If omitted, a stored refresh token will be used to authenticate.
polling_interval – Seconds between status polls.
max_retries – Max consecutive polling errors before failure.
- ldml_url: HttpUrl¶
- ld_url: pydantic.networks.HttpUrl | None¶
- jsession_id: str | None¶
- polling_interval: int¶
- max_retries: int¶
- model_config: ClassVar[ConfigDict] = {'frozen': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- schrodinger.application.transforms.ldml.setup_client(config: LDMLConfig)¶
Configure the
LDMLClientsingleton for a config.If
jsession_idis set, configures the client directly. Otherwise, looks up a stored refresh token for the host derived fromldml_urland authenticates via LiveDesign.- Parameters:
config – LDML configuration.
- Raises:
LDMLClientError – If authentication fails or no stored credentials are found.
- class schrodinger.application.transforms.ldml.InferenceConfig(*, ldml_url: HttpUrl, ld_url: pydantic.networks.HttpUrl | None = None, jsession_id: str | None = None, polling_interval: int = 600, max_retries: int = 5, dataset_display_name: str)¶
Bases:
LDMLConfigConfiguration for LDML inference transforms.
- Parameters:
dataset_display_name – LDML dataset display name for inference.
- dataset_display_name: str¶
- model_config: ClassVar[ConfigDict] = {'frozen': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class schrodinger.application.transforms.ldml.InferenceSubmissionResult(id_to_input_structure: dict[str, Structure], job_id: str | None = None, error_message: str | None = None)¶
Bases:
objectIntermediate result from submitting an LDML inference job.
Bridges the submit and collect phases, carrying enough state for the collect phase to poll, fetch results, and match them back to the original input structures.
- Parameters:
id_to_input_structure – Mapping of corporate ID to original input structure.
job_id – LDML job ID, or
Noneif submission failed.error_message – Error message if submission failed.
- job_id: str | None = None¶
- error_message: str | None = None¶
- class schrodinger.application.transforms.ldml.InferenceResult(input_structure: Structure, success: bool, job_id: str | None = None, corporate_id: str | None = None, ml_prediction: float | None = None, ml_uncertainty: float | None = None, error_message: str | None = None)¶
Bases:
objectResult of running inference on a single structure.
- Parameters:
input_structure – The input structure, unchanged.
success – Whether inference succeeded.
job_id – LDML inference job ID.
corporate_id – Corporate ID used to identify this structure in the LDML job.
ml_prediction – Model prediction value.
ml_uncertainty – Model uncertainty value.
error_message – Error message if processing failed.
- success: bool¶
- job_id: str | None = None¶
- corporate_id: str | None = None¶
- ml_prediction: float | None = None¶
- ml_uncertainty: float | None = None¶
- error_message: str | None = None¶
- schrodinger.application.transforms.ldml.assign_corporate_ids(structures: list[Structure]) tuple[list[Structure], dict[str, Structure]]¶
Assign unique corporate IDs to copies of structures.
Each copy gets a UUID as its corporate ID to guarantee uniqueness. The copies are submitted to LDML, and the mapping is used to match results back to input structures.
- Parameters:
structures – Input structures.
- Returns:
A tuple of (copies for LDML submission, mapping of corporate ID to original structure).
- class schrodinger.application.transforms.ldml.SubmitInference(**kwargs)¶
Bases:
PTransformWithConfigA PTransform that submits an LDML inference job and returns a submission.
Collects input structures into a batch, assigns corporate IDs, and submits the batch to LDML. Yields a single-element PCollection containing one
InferenceSubmissionResultthat can be passed toCollectInferenceto poll and retrieve results.See
InferenceConfigfor available configuration options.- config_class¶
alias of
InferenceConfig
- class schrodinger.application.transforms.ldml.CollectInference(**kwargs)¶
Bases:
PTransformWithConfigA PTransform that polls and collects LDML inference results.
Takes an
InferenceSubmissionResultfromSubmitInference, polls for job completion, fetches results, and yields anInferenceResultfor each input structure.See
InferenceConfigfor available configuration options.- config_class¶
alias of
InferenceConfig
- class schrodinger.application.transforms.ldml.RunInference(**kwargs)¶
Bases:
PTransformWithConfigA PTransform that runs LDML inference and returns results.
Returns an
InferenceResultfor every input structure, indicating whether processing succeeded and containing prediction values.Warning
This transform collects all input structures into memory before submitting to LDML, which can be memory intensive for large inputs.
Example usage:
>>> from schrodinger import adapter >>> st = adapter.to_structure('c1ccccc1') >>> with beam.Pipeline() as p: ... results = (p ... | beam.Create([st]) ... | RunInference( ... dataset_display_name='My Dataset') ... | beam.Map(lambda r: (r.success, r.ml_prediction)) ... | beam.LogElements())
See
InferenceConfigfor available configuration options.- config_class¶
alias of
InferenceConfig