serialization

pyrosetta.distributed.cluster.serialization._parse_compression(obj: Any) Optional[Union[str, bool]]

Parse the input compression attribute of Serialization class.

pyrosetta.distributed.cluster.serialization.update_scores(packed_pose: PackedPose) PackedPose

Cache scores into the PackedPose object that are not cached in the Pose object and do not have keys with reserved scoretypes, then return the updated PackedPose object.

Args:

packed_pose: the input PackedPose object in which to update scores.

Returns:

A new PackedPose object with scores cached in its Pose object if scores could be cached, otherwise the input PackedPose object.

class pyrosetta.distributed.cluster.serialization.MessagePacking

Bases: Generic[G]

PyRosettaCluster MessagePack base class.

pack
unpack
__init__() None

Method generated by attrs for class MessagePacking.

_is_protocol = False
class pyrosetta.distributed.cluster.serialization.NonceCache(*, instance_id: str, prk=None, max_nonce: int)

Bases: Generic[G]

PyRosettaCluster nonce cache base class.

static _get_state(self) Dict[str, Any]

A method used to override the default NonceCache.__getstate__() method that sets the pseudo-random key value to None in the returned state.

static _on_worker() bool

Test if the nonce cache is on a dask worker.

_cache_nonce(sealed: bytes) None

Run Hash-based Message Authentication Code (HMAC) verification and cache nonces for replay protection without data decompression.

__init__(*, instance_id: str, prk=None, max_nonce: int) None

Method generated by attrs for class NonceCache.

_is_protocol = False
class pyrosetta.distributed.cluster.serialization.Serialization(*, instance_id: Optional[str] = None, prk=None, compression: Any = 'xz', with_nonce: bool = False)

Bases: Generic[G]

PyRosettaCluster serialization base class.

classmethod zlib_compress(obj: bytes) bytes

Compress an object with zlib level 9.

requires_compression() T

Wrapper testing if compression is enabled, and skips compression if it’s disabled.

_seal(data: bytes) bytes

Seal data with MessagePack.

_unseal(obj: bytes) bytes

Unseal data with MessagePack and perform Hash-based Message Authentication Code (HMAC) verification.

compress_packed_pose(packed_pose: Any) Union[NoReturn, None, bytes]

Compress a PackedPose object with the custom serialization module. If the ‘packed_pose’ argument parameter is None, then just return None.

Args:

packed_pose: the input PackedPose object to compress. If None, then just return None.

Returns:

A bytes object representing the compressed PackedPose object, or a NoneType object.

Raises:

TypeError if the ‘packed_pose’ argument parameter is not of type NoneType or PackedPose.

decompress_packed_pose(compressed_packed_pose: Any) Union[NoReturn, None, PackedPose]

Decompress a bytes object with the custom serialization module and secure implementation of the pickle module. If the ‘compressed_packed_pose’ argument parameter is None, then just return None.

Args:

compressed_packed_pose: the input bytes object to decompress. If None, then just return None.

Returns:

A PackedPose object representing the decompressed bytes object, or a NoneType object.

Raises:

TypeError if the ‘compressed_packed_pose’ argument parameter is not of type NoneType or bytes.

loads_object(compressed_obj: bytes) Any

Unseal data and run the cloudpickle.loads method.

dumps_object(obj: Any) bytes

Run the cloudpickle.dumps method and seal data.

compress_kwargs(kwargs: Any) Union[NoReturn, bytes]

Compress a dict object with the cloudpickle and custom serialization modules.

Args:

kwargs: the input dict object to compress.

Returns:

A bytes object representing the compressed dict object.

Raises:

TypeError if the ‘kwargs’ argument parameter is not of type dict.

decompress_kwargs(compressed_kwargs: bytes) Union[NoReturn, Dict[Any, Any]]

Decompress a bytes object with the custom serialization and cloudpickle modules.

Args:

compressed_kwargs: the input bytes object to decompress.

Returns:

A dict object representing the decompressed bytes object.

Raises:

TypeError if the ‘compressed_packed_pose’ argument parameter is not of type bytes. TypeError if the returned kwargs is not of type dict.

compress_object(obj: Any) bytes

Compress an object with the cloudpickle and custom serialization modules.

Args:

obj: the input object to compress.

Returns:

A bytes object representing the compressed object.

decompress_object(compressed_obj: bytes) Any

Decompress a bytes object with the custom serialization and cloudpickle modules.

Args:

compressed_obj: the input bytes object to decompress.

Returns:

An object representing the decompressed bytes object.

Raises:

TypeError if the ‘compressed_obj’ argument parameter is not of type bytes.

classmethod deepcopy_kwargs(kwargs: Any) Union[NoReturn, Dict[Any, Any]]

The cloudpickle module makes it possible to serialize Python constructs not supported by the default pickle module from the Python standard library.

Args:

kwargs: the dict object to be deep copied.

Returns:

A deep copy of the dict object.

Raises:

TypeError if the ‘kwargs’ argument parameter is not of type dict.

__init__(*, instance_id: Optional[str] = None, prk=None, compression: Any = 'xz', with_nonce: bool = False) None

Method generated by attrs for class Serialization.

_is_protocol = False