schrodinger.seam.coders module

exception schrodinger.seam.coders.UnserializableMolError

Bases: Exception

__init__(*args, **kwargs)
args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class schrodinger.seam.coders.MolToSmilesCoder

Bases: apache_beam.coders.coders.Coder

encode(mol: rdkit.Chem.rdchem.Mol) bytes

Encodes the given object into a byte string.

decode(smiles_bytes: bytes) rdkit.Chem.rdchem.Mol

Decodes the given byte string into the corresponding object.

is_deterministic()

Whether this coder is guaranteed to encode values deterministically.

A deterministic coder is required for key coders in GroupByKey operations to produce consistent results.

For example, note that the default coder, the PickleCoder, is not deterministic: the ordering of picked entries in maps may vary across executions since there is no defined order, and such a coder is not in general suitable for usage as a key coder in GroupByKey operations, since each instance of the same key may be encoded differently.

Returns:

Whether coder is deterministic.

estimate_size(mol: rdkit.Chem.rdchem.Mol) int

Estimates the encoded size of the given value, in bytes.

Dataflow estimates the encoded size of a PCollection processed in a pipeline step by using the estimated size of a random sample of elements in that PCollection.

The default implementation encodes the given value and returns its byte size. If a coder can provide a fast estimate of the encoded size of a value (e.g., if the encoding has a fixed size), it can provide its estimate here to improve performance.

Arguments:

value: the value whose encoded size is to be estimated.

Returns:

The estimated encoded size of the given value.

as_deterministic_coder(step_label, error_message=None)

Returns a deterministic version of self, if possible.

Otherwise raises a value error.

decode_nested(encoded)

Uses the underlying implementation to decode in nested format.

encode_nested(value)

Uses the underlying implementation to encode in nested format.

classmethod from_runner_api(coder_proto: Type[apache_beam.coders.coders.CoderT], context: org.apache.beam.model.pipeline.v1.beam_runner_api_pb2.Coder) apache_beam.coders.coders.CoderT

Converts from an FunctionSpec to a Fn object.

Prefer registering a urn with its parameter type and constructor.

classmethod from_type_hint(unused_typehint: Type[apache_beam.coders.coders.CoderT], unused_registry: Any) apache_beam.coders.coders.CoderT
get_impl()

For internal use only; no backwards-compatibility guarantees.

Returns the CoderImpl backing this Coder.

is_kv_coder() bool
key_coder() apache_beam.coders.coders.Coder
static register_structured_urn(urn: str, cls: Type[apache_beam.coders.coders.Coder]) None

Register a coder that’s completely defined by its urn and its component(s), if any, which are passed to construct the instance.

classmethod register_urn(urn, parameter_type, fn=None)

Registers a urn with a constructor.

For example, if ‘beam:fn:foo’ had parameter type FooPayload, one could write RunnerApiFn.register_urn('bean:fn:foo', FooPayload, foo_from_proto) where foo_from_proto took as arguments a FooPayload and a PipelineContext. This function can also be used as a decorator rather than passing the callable in as the final parameter.

A corresponding to_runner_api_parameter method would be expected that returns the tuple (‘beam:fn:foo’, FooPayload)

to_runner_api(context: PipelineContext) beam_runner_api_pb2.Coder
to_runner_api_parameter(context: Optional[PipelineContext]) Tuple[str, Any, Sequence[Coder]]
to_type_hint()
value_coder() apache_beam.coders.coders.Coder
class schrodinger.seam.coders.SafeMolToSmilesCoder

Bases: schrodinger.seam.coders.MolToSmilesCoder

Encodes and decodes Mol’s to and from SMILES strings similar to MolToSmilesCoder. However, this coder will raise an exception if the molecule is not sanitizable.

“Sanitizable” in this context is defined as a smiles that will return None when passed to Chem.MolFromSmiles (which by default attempts to sanitize the molecule). This is not as fast as MolToSmilesCoder because of the additional check, but will

encode(mol: rdkit.Chem.rdchem.Mol) bytes

Encodes the given object into a byte string.

as_deterministic_coder(step_label, error_message=None)

Returns a deterministic version of self, if possible.

Otherwise raises a value error.

decode(smiles_bytes: bytes) rdkit.Chem.rdchem.Mol

Decodes the given byte string into the corresponding object.

decode_nested(encoded)

Uses the underlying implementation to decode in nested format.

encode_nested(value)

Uses the underlying implementation to encode in nested format.

estimate_size(mol: rdkit.Chem.rdchem.Mol) int

Estimates the encoded size of the given value, in bytes.

Dataflow estimates the encoded size of a PCollection processed in a pipeline step by using the estimated size of a random sample of elements in that PCollection.

The default implementation encodes the given value and returns its byte size. If a coder can provide a fast estimate of the encoded size of a value (e.g., if the encoding has a fixed size), it can provide its estimate here to improve performance.

Arguments:

value: the value whose encoded size is to be estimated.

Returns:

The estimated encoded size of the given value.

classmethod from_runner_api(coder_proto: Type[apache_beam.coders.coders.CoderT], context: org.apache.beam.model.pipeline.v1.beam_runner_api_pb2.Coder) apache_beam.coders.coders.CoderT

Converts from an FunctionSpec to a Fn object.

Prefer registering a urn with its parameter type and constructor.

classmethod from_type_hint(unused_typehint: Type[apache_beam.coders.coders.CoderT], unused_registry: Any) apache_beam.coders.coders.CoderT
get_impl()

For internal use only; no backwards-compatibility guarantees.

Returns the CoderImpl backing this Coder.

is_deterministic()

Whether this coder is guaranteed to encode values deterministically.

A deterministic coder is required for key coders in GroupByKey operations to produce consistent results.

For example, note that the default coder, the PickleCoder, is not deterministic: the ordering of picked entries in maps may vary across executions since there is no defined order, and such a coder is not in general suitable for usage as a key coder in GroupByKey operations, since each instance of the same key may be encoded differently.

Returns:

Whether coder is deterministic.

is_kv_coder() bool
key_coder() apache_beam.coders.coders.Coder
static register_structured_urn(urn: str, cls: Type[apache_beam.coders.coders.Coder]) None

Register a coder that’s completely defined by its urn and its component(s), if any, which are passed to construct the instance.

classmethod register_urn(urn, parameter_type, fn=None)

Registers a urn with a constructor.

For example, if ‘beam:fn:foo’ had parameter type FooPayload, one could write RunnerApiFn.register_urn('bean:fn:foo', FooPayload, foo_from_proto) where foo_from_proto took as arguments a FooPayload and a PipelineContext. This function can also be used as a decorator rather than passing the callable in as the final parameter.

A corresponding to_runner_api_parameter method would be expected that returns the tuple (‘beam:fn:foo’, FooPayload)

to_runner_api(context: PipelineContext) beam_runner_api_pb2.Coder
to_runner_api_parameter(context: Optional[PipelineContext]) Tuple[str, Any, Sequence[Coder]]
to_type_hint()
value_coder() apache_beam.coders.coders.Coder
class schrodinger.seam.coders.StructureCoder

Bases: apache_beam.coders.coders.Coder

encode(st: schrodinger.structure._structure.Structure) bytes

Encodes the given object into a byte string.

decode(mae_bytes: bytes) schrodinger.structure._structure.Structure

Decodes the given byte string into the corresponding object.

is_deterministic()

Whether this coder is guaranteed to encode values deterministically.

A deterministic coder is required for key coders in GroupByKey operations to produce consistent results.

For example, note that the default coder, the PickleCoder, is not deterministic: the ordering of picked entries in maps may vary across executions since there is no defined order, and such a coder is not in general suitable for usage as a key coder in GroupByKey operations, since each instance of the same key may be encoded differently.

Returns:

Whether coder is deterministic.

as_deterministic_coder(step_label, error_message=None)

Returns a deterministic version of self, if possible.

Otherwise raises a value error.

decode_nested(encoded)

Uses the underlying implementation to decode in nested format.

encode_nested(value)

Uses the underlying implementation to encode in nested format.

estimate_size(value)

Estimates the encoded size of the given value, in bytes.

Dataflow estimates the encoded size of a PCollection processed in a pipeline step by using the estimated size of a random sample of elements in that PCollection.

The default implementation encodes the given value and returns its byte size. If a coder can provide a fast estimate of the encoded size of a value (e.g., if the encoding has a fixed size), it can provide its estimate here to improve performance.

Arguments:

value: the value whose encoded size is to be estimated.

Returns:

The estimated encoded size of the given value.

classmethod from_runner_api(coder_proto: Type[apache_beam.coders.coders.CoderT], context: org.apache.beam.model.pipeline.v1.beam_runner_api_pb2.Coder) apache_beam.coders.coders.CoderT

Converts from an FunctionSpec to a Fn object.

Prefer registering a urn with its parameter type and constructor.

classmethod from_type_hint(unused_typehint: Type[apache_beam.coders.coders.CoderT], unused_registry: Any) apache_beam.coders.coders.CoderT
get_impl()

For internal use only; no backwards-compatibility guarantees.

Returns the CoderImpl backing this Coder.

is_kv_coder() bool
key_coder() apache_beam.coders.coders.Coder
static register_structured_urn(urn: str, cls: Type[apache_beam.coders.coders.Coder]) None

Register a coder that’s completely defined by its urn and its component(s), if any, which are passed to construct the instance.

classmethod register_urn(urn, parameter_type, fn=None)

Registers a urn with a constructor.

For example, if ‘beam:fn:foo’ had parameter type FooPayload, one could write RunnerApiFn.register_urn('bean:fn:foo', FooPayload, foo_from_proto) where foo_from_proto took as arguments a FooPayload and a PipelineContext. This function can also be used as a decorator rather than passing the callable in as the final parameter.

A corresponding to_runner_api_parameter method would be expected that returns the tuple (‘beam:fn:foo’, FooPayload)

to_runner_api(context: PipelineContext) beam_runner_api_pb2.Coder
to_runner_api_parameter(context: Optional[PipelineContext]) Tuple[str, Any, Sequence[Coder]]
to_type_hint()
value_coder() apache_beam.coders.coders.Coder
class schrodinger.seam.coders.RouteNodeCoder

Bases: apache_beam.coders.coders.Coder

encode(route_node: schrodinger.application.pathfinder.route.RouteNode) bytes

Encodes the given object into a byte string.

decode(route_node_bytes: bytes) schrodinger.application.pathfinder.route.RouteNode

Decodes the given byte string into the corresponding object.

is_deterministic()

Whether this coder is guaranteed to encode values deterministically.

A deterministic coder is required for key coders in GroupByKey operations to produce consistent results.

For example, note that the default coder, the PickleCoder, is not deterministic: the ordering of picked entries in maps may vary across executions since there is no defined order, and such a coder is not in general suitable for usage as a key coder in GroupByKey operations, since each instance of the same key may be encoded differently.

Returns:

Whether coder is deterministic.

as_deterministic_coder(step_label, error_message=None)

Returns a deterministic version of self, if possible.

Otherwise raises a value error.

decode_nested(encoded)

Uses the underlying implementation to decode in nested format.

encode_nested(value)

Uses the underlying implementation to encode in nested format.

estimate_size(value)

Estimates the encoded size of the given value, in bytes.

Dataflow estimates the encoded size of a PCollection processed in a pipeline step by using the estimated size of a random sample of elements in that PCollection.

The default implementation encodes the given value and returns its byte size. If a coder can provide a fast estimate of the encoded size of a value (e.g., if the encoding has a fixed size), it can provide its estimate here to improve performance.

Arguments:

value: the value whose encoded size is to be estimated.

Returns:

The estimated encoded size of the given value.

classmethod from_runner_api(coder_proto: Type[apache_beam.coders.coders.CoderT], context: org.apache.beam.model.pipeline.v1.beam_runner_api_pb2.Coder) apache_beam.coders.coders.CoderT

Converts from an FunctionSpec to a Fn object.

Prefer registering a urn with its parameter type and constructor.

classmethod from_type_hint(unused_typehint: Type[apache_beam.coders.coders.CoderT], unused_registry: Any) apache_beam.coders.coders.CoderT
get_impl()

For internal use only; no backwards-compatibility guarantees.

Returns the CoderImpl backing this Coder.

is_kv_coder() bool
key_coder() apache_beam.coders.coders.Coder
static register_structured_urn(urn: str, cls: Type[apache_beam.coders.coders.Coder]) None

Register a coder that’s completely defined by its urn and its component(s), if any, which are passed to construct the instance.

classmethod register_urn(urn, parameter_type, fn=None)

Registers a urn with a constructor.

For example, if ‘beam:fn:foo’ had parameter type FooPayload, one could write RunnerApiFn.register_urn('bean:fn:foo', FooPayload, foo_from_proto) where foo_from_proto took as arguments a FooPayload and a PipelineContext. This function can also be used as a decorator rather than passing the callable in as the final parameter.

A corresponding to_runner_api_parameter method would be expected that returns the tuple (‘beam:fn:foo’, FooPayload)

to_runner_api(context: PipelineContext) beam_runner_api_pb2.Coder
to_runner_api_parameter(context: Optional[PipelineContext]) Tuple[str, Any, Sequence[Coder]]
to_type_hint()
value_coder() apache_beam.coders.coders.Coder