schrodinger.application.transforms.baseconfig module

class schrodinger.application.transforms.baseconfig.PTransformWithConfig(*, _config: pydantic.main.BaseModel | None = None, **kwargs)

Bases: PTransform

Base class for PTransforms that use Pydantic models for configuration.

Subclasses should define a class variable config_class pointing to a Pydantic BaseModel class. The constructor will automatically create an instance of this config class and store it as self.config.

Example usage:

class MyTransformConfig(BaseModel):
    multiplier: float

class MyTransform(PTransformWithConfig):
    config_class = MyTransformConfig

    def expand(self, pcoll):
        # Access configuration via self.config
        return pcoll | beam.Map(lambda x: x * self.config.multiplier)
config_class: Type[BaseModel] = None
__init__(*, _config: pydantic.main.BaseModel | None = None, **kwargs)

Initialize the transform with configuration.

All keyword arguments are passed to the config_class constructor to create a validated configuration instance stored as self.config.

Parameters:
  • _config – An existing configuration model

  • kwargs – Configuration parameters for the config_class

Raises:
  • AttributeError – If config_class is not defined on the subclass

  • ValueError – If _config is combined with kwargs

  • ValidationError – If the configuration parameters are invalid

classmethod from_config(config: BaseModel, **kwargs: Any) → Self

Create a transform from an existing configuration model.

An exact config type is copied without validation. Other model types are validated while adapting them to the transform’s config class.

Parameters:
  • config – configuration model

  • kwargs – constructor-only transform arguments

display_data() → Dict[str, Any]

Return display data for the transform based on the configuration.

Automatically generates display data from all fields in the config, converting values to strings for display purposes.

Returns:

Dictionary of configuration data for display