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:

  1. Explicit credentials: Pass ldml_url and jsession_id to the transform config. setup_client() will call LDMLClient.createFromConfig() directly.

  2. Stored credentials: Pass only ldml_url. setup_client() looks up a refresh token from the credentials store (see schrodinger.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: BaseModel

Base 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 LDMLClient singleton for a config.

If jsession_id is set, configures the client directly. Otherwise, looks up a stored refresh token for the host derived from ldml_url and 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: LDMLConfig

Configuration 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: object

Intermediate 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 None if submission failed.

  • error_message – Error message if submission failed.

id_to_input_structure: dict[str, Structure]
job_id: str | None = None
error_message: str | None = None
__init__(id_to_input_structure: dict[str, Structure], job_id: str | None = None, error_message: str | None = 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: object

Result 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.

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
__init__(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) 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: PTransformWithConfig

A 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 InferenceSubmissionResult that can be passed to CollectInference to poll and retrieve results.

See InferenceConfig for available configuration options.

config_class

alias of InferenceConfig

class schrodinger.application.transforms.ldml.CollectInference(**kwargs)

Bases: PTransformWithConfig

A PTransform that polls and collects LDML inference results.

Takes an InferenceSubmissionResult from SubmitInference, polls for job completion, fetches results, and yields an InferenceResult for each input structure.

See InferenceConfig for available configuration options.

config_class

alias of InferenceConfig

class schrodinger.application.transforms.ldml.RunInference(**kwargs)

Bases: PTransformWithConfig

A PTransform that runs LDML inference and returns results.

Returns an InferenceResult for 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 InferenceConfig for available configuration options.

config_class

alias of InferenceConfig