inspectus.data_logger package

Module contents

class inspectus.data_logger.DataLogger(path: str | Path)[source]

Bases: object

clear()[source]

Clears all the files in the directory specified in the path during the initialization of the DataLogger object. Raises a RuntimeError if a directory is found in the path.

get_all() Dict[str, List[dict]][source]

Gets all the data from all the files in the directory specified in the path during the initialization of the DataLogger object.

Returns:

A dictionary where the keys are the names of the files and the values are lists of dictionaries containing the data from the corresponding files.

Return type:

Dict[str, List[dict]]

get_names() List[str][source]

Gets the names of all the files in the directory specified in the path during the initialization of the DataLogger object.

Returns:

A list of strings containing the names of all the files in the directory.

Return type:

List[str]

read(name: str) List[dict][source]

Reads the data from a file in the directory specified in the path during the initialization of the DataLogger object.

Parameters:

name (str) – The name of the file from which the data will be read.

Returns:

A list of dictionaries containing the data read from the file.

Return type:

List[dict]

Raises:

RuntimeError – If the file is not found or is not a valid jsonl file.

save(name: str, data: Dict[str, Any] | np.ndarray | torch.tensor, step=-1)[source]

Saves the data to a file in the directory specified in the path during the initialization of the DataLogger object.

Parameters:
  • name (str) – The name of the file where the data will be saved.

  • data (Union[ Dict[str, Any], 'np.ndarray', 'torch.tensor']) – The data to be saved. This should be a dictionary, a numpy array or a pytorch tensor.

  • step (int, optional) – The step at which the data is saved. Default is -1.