serialization¶
- pyrosetta.distributed.cluster.serialization._parse_compression(obj: Any) Optional[Union[str, bool]]¶
Parse the compression keyword argument value of the Serialization class.
- pyrosetta.distributed.cluster.serialization.update_scores(packed_pose: PackedPose) PackedPose¶
Cache scores from the PackedPose.scores dictionary that are not cached in the Pose.cache dictionary and do not have keys with reserved scoretypes, then return a new PackedPose object.
Warning: This function uses the pickle module to deserialize pickled Pose objects. Using the pickle module is not secure, so please only run with input files you trust. Learn more about the pickle module and its security here.
- Args:
- packed_pose:
An input PackedPose object in which to update scores.
- Returns:
A new PackedPose object, with scores cached in its Pose.cache dictionary if scores could be cached.
- class pyrosetta.distributed.cluster.serialization.MessagePacking¶
Bases:
objectMessagePack base class for PyRosettaCluster.
- pack: partial¶
- unpack: partial¶
- class pyrosetta.distributed.cluster.serialization.NonceCache(*, instance_id: str, prk=None, max_nonce: int)¶
Bases:
objectNonce cache base class for PyRosettaCluster.
- instance_id: str¶
- prk: Optional[bytes]¶
- max_nonce: int¶
- _seen: Set¶
- _order: deque[bytes]¶
- _debug: bool¶
- static _get_state(self) Dict[str, Any]¶
A method used to override the default NonceCache.__getstate__() method that sets the value of the the ‘prk’ key (i.e., the pseudorandom key (PRK)) to None in the returned state.
- static _on_worker() bool¶
Test if the nonce cache is on a Dask worker.
- class pyrosetta.distributed.cluster.serialization.Serialization(*, instance_id: Optional[str] = None, prk=None, compression: Any = 'xz', with_nonce: bool = False)¶
Bases:
objectSerialization base class for PyRosettaCluster.
- instance_id: Optional[str]¶
- prk: Optional[bytes]¶
- compression: Optional[Union[str, bool]]¶
- with_nonce: bool¶
- _nonce_size: int¶
- classmethod zlib_compress(obj: bytes) bytes¶
Compress an object with zlib level 9.
- with_update_scores() CallableType¶
Decorator that caches detached PackedPose.scores items into the Pose.cache dictionary.
Warning: This method uses the pickle module to deserialize pickled Pose objects. Using the pickle module is not secure, so please only run with input files you trust. Learn more about the pickle module and its security here.
- requires_compression() CallableType¶
Decorator testing if compression is enabled, and skips compression if it is 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: Optional[PackedPose]) Optional[bytes]¶
Compress a PackedPose object with the custom serialization module. If the ‘packed_pose’ argument value is None, then just return None.
- Args:
- packed_pose:
An input PackedPose object to compress. If None, then just return None.
- Returns:
A bytes object representing the compressed PackedPose object, or None.
- Raises:
TypeError if the packed_pose argument value is not of type NoneType or PackedPose.
- decompress_packed_pose(compressed_packed_pose: Optional[bytes]) Optional[PackedPose]¶
Decompress a bytes object with the custom serialization module and secure implementation of the pickle module. If the compressed_packed_pose argument value is None, then just return None.
Warning: This function uses the pickle module to deserialize pickled Pose objects. Using the pickle module is not secure, so please only run with input files you trust. Learn more about the pickle module and its security here.
- Args:
- compressed_packed_pose:
An input bytes object to decompress. If None, then just return None.
- Returns:
A PackedPose object representing the decompressed bytes object, or None.
- Raises:
TypeError if the compressed_packed_pose argument value is not of type NoneType or bytes.
- loads_object(compressed_obj: bytes) Any¶
Unseal data and run the cloudpickle.loads method.
Warning: This method uses the cloudpickle module to deserialize objects. Using the cloudpickle module is not secure, so please only run with input data you trust. Learn more about the cloudpickle module and its security here and here.
- dumps_object(obj: Any) bytes¶
Run the cloudpickle.dumps method and seal data.
- compress_kwargs(kwargs: Dict[str, Any]) bytes¶
Compress a dict object with the cloudpickle and custom serialization modules.
- Args:
- kwargs:
An input dict object to compress.
- Returns:
A bytes object representing the compressed dict object.
- Raises:
TypeError if the ‘kwargs’ argument value is not of type dict.
- decompress_kwargs(compressed_kwargs: bytes) Dict[str, Any]¶
Decompress a bytes object with the custom serialization and cloudpickle modules.
Warning: This method uses the cloudpickle module to deserialize objects. Using the cloudpickle module is not secure, so please only run with input data you trust. Learn more about the cloudpickle module and its security here and here.
- Args:
- compressed_kwargs:
An input bytes object to decompress.
- Returns:
A dict object representing the decompressed bytes object.
- Raises:
TypeError if the compressed_packed_pose argument value is not of type bytes. TypeError if the decompressed object is not of type dict.
- compress_object(obj: Any) bytes¶
Compress an object with the cloudpickle and custom serialization modules.
- Args:
- obj:
An 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.
Warning: This method uses the cloudpickle module to deserialize objects. Using the cloudpickle module is not secure, so please only run with input data you trust. Learn more about the cloudpickle module and its security here and here.
- Args:
- compressed_obj:
An input bytes object to decompress.
- Returns:
An object representing the decompressed bytes object.
- Raises:
TypeError if the compressed_obj argument value is not of type bytes.
- classmethod deepcopy_kwargs(kwargs: Dict[str, Any]) Dict[str, Any]¶
The cloudpickle module makes it possible to serialize Python constructs not supported by the default pickle module from the Python standard library.
Warning: This method uses the cloudpickle module to serialize and subsequently deserialize dict objects. Using the cloudpickle module is not secure, so please only run with input data you trust. Learn more about the cloudpickle module and its security here and here.
- Args:
- kwargs:
A dict object to be deep copied.
- Returns:
A deep copy of the dict object.
- Raises:
TypeError if the kwargs argument value is not of type dict.