brain_pipe.save.default.SaveMetadata

class SaveMetadata(key_fn: ~typing.Callable[[~typing.Dict[str, ~typing.Any]], str] = <function default_metadata_key_fn>)

Bases: AttachSave, ABC

Abstract class for metadata to use when saving/reloading.

Attributes

FEATURE_NAME_STR

FILENAME_STR

OLD_FORMAT_STR

SET_NAME_STR

__init__(key_fn: ~typing.Callable[[~typing.Dict[str, ~typing.Any]], str] = <function default_metadata_key_fn>)

Create a new SaveMetadata.

Parameters:

key_fn (Callable[[Dict[str, Any]], str]) – The function to use to get the key from the data dict.

Methods

__init__([key_fn])

Create a new SaveMetadata.

add(data_dict, filepath, feature_name, set_name)

Add a metadata entry.

attach_saver(saver)

Initialize a new object with the saver.

clear()

Clear the metadata.

is_old_format(metadata_item)

Check if the metadata item is in the old format.

abstract add(data_dict: Dict[str, Any], filepath: str, feature_name: str | None, set_name: str | None)

Add a metadata entry.

Parameters:
  • data_dict (Dict[str, Any]) – The data dict containing the data to save.

  • filepath (str) – The path to the data.

  • feature_name (Optional[str]) – The name of the feature.

  • set_name (Optional[str]) – The name of the set.

attach_saver(saver)

Initialize a new object with the saver.

Parameters:

saver (Save) – The saver.

abstract clear()

Clear the metadata.

classmethod is_old_format(metadata_item: str | Dict[str, Any])

Check if the metadata item is in the old format.

Parameters:

metadata_item (Union[str, Dict[str, Any]]) – The metadata item to check.

Returns:

Whether the metadata item is in the old format.

Return type:

bool