scalarstop.datablob_metadata¶
Tools for storing metadata about DataBlob s.
Module Contents¶
Classes¶
Represents the metadata from a |
- class DataBlobMetadata(*, name: str, group_name: str, hyperparams: scalarstop.hyperparams.HyperparamsType, save_load_version: int, num_shards: int)¶
Represents the metadata from a
DataBlobthat is saved to or loaded from the filesystem.When we save metadata to the filesystem, we save the same information in two files–one in JSON format and the other in Python Pickle format. The JSON file is human-readable and can be parsed by non-Python programs. The Pickle file is kept to ensure that the
DataBlob‘s hyperparams can be accurately deserialized–even if the hyperparams are not JSON-serializable.Creates a
DataBlobMetadataobject in memory.- Parameters
name – The
DataBlobname.group_name – The
DataBlobgroup name.hyperparams – The
Hyperparamsobject for theDataBlob. This has to be an instance ofHyperparamsTypeand not a Python dictionary.save_load_version – The protocol version used to save or load this
DataBlobto/from the filesystem.num_shards – The number of shards to divide the
DataBlobinto when saving to the filesystem.
- classmethod load(cls, path: str) DataBlobMetadata¶
Loads metadata from a
DataBlob‘s directory on the filesystem.
- classmethod from_datablob(cls, datablob: scalarstop.datablob.DataBlob, *, save_load_version: int, num_shards: int)¶
Creates a
DataBlobMetadataobject in memory from aDataBlobinstance.- Parameters
datablob – The
DataBlobfor which thisDataBlobMetadataobject is being created for.save_load_version – The protocol version used to save or load this
DataBlobto/from the filesystem.num_shards – The number of shards to divide the
DataBlobinto when saving to the filesystem.
- to_dict(self, *, hyperparams_as_dict: bool = False) Dict[str, Any]¶
Return the metadata as a Python dictionary.
- Parameters
hyperparams_as_dict – Set to
Trueto convert a
:param
HyperparamsType: :param object to a Python dictionary.: