art.utils package

Submodules

art.utils.enums module

class art.utils.enums.TrainingStage(value)

Bases: Enum

Training stage enum

SANITY_CHECK = 'sanity_check'
TEST = 'test'
TRAIN = 'train'
VALIDATION = 'validate'

art.utils.exceptions module

All predefined exceptions.

exception art.utils.exceptions.CheckFailedException

Bases: Exception

Exception raised when a check fails.

exception art.utils.exceptions.SavingArtResultsException

Bases: Exception

Exception raised when saving ART results fails.

art.utils.paths module

art.utils.paths.get_checkpoint_logs_folder_path(full_step_name) Path
art.utils.paths.get_checkpoint_step_dir_path(full_step_name) Path

Get the name of the directory for the given step.

Parameters:
  • step_id (str) – The ID of the step.

  • step_name (str) – The name of the step.

Returns:

The name of the directory.

Return type:

str

art.utils.savers module

class art.utils.savers.JSONStepSaver

Bases: StepSaver

Class to save and load steps in JSON format.

RESULT_NAME = 'results.json'
load(full_step_name, filename: str = 'results.json')

Load an object from a JSON file.

Parameters:
  • full_step_name (str) – The full name of the step.

  • filename (str, optional) – The name of the JSON file. Defaults to “results.json”.

Returns:

Loaded object.

Return type:

Any

save(obj: Step, full_step_name: str, filename: str = 'results.json')

Save an object as a JSON file.

Parameters:
  • step (Step) – The step to save.

  • filename (str, optional) – The name of the JSON file. Defaults to “results.json”.

class art.utils.savers.MatplotLibSaver

Bases: StepSaver

Class to save figures using Matplotlib.

load(full_step_name: str, filename: str)

Load a Matplotlib figure. This method is not implemented.

Parameters:
  • full_step_name (str) – The full name of the step.

  • filename (str) – The name of the file containing the figure.

Raises:

NotImplementedError – This method is not implemented.

save(obj: Figure, full_step_name: str, filename: str = '')

Save a Matplotlib figure.

Parameters:
  • obj (plt.Figure) – The figure to save.

  • full_step_name (str) – The full name of the step.

  • filename (str) – The name of the file to save the figure to.

class art.utils.savers.StepSaver

Bases: ABC

Abstract base class for saving and loading steps.

ensure_directory(full_step_name: str)

Ensure the directory for the given step exists.

Parameters:

full_step_name (str) – The full name of the step.

Returns:

True if directory exists or is created successfully, otherwise False.

Return type:

bool

exists(full_step_name: str, filename: str)

Check if a file for a given step exists.

Parameters:
  • full_step_name (str) – The full name of the step.

  • filename (str) – The name of the file.

Returns:

True if the file exists, otherwise False.

Return type:

bool

get_path(full_step_name: str, filename: str)

Get the path for the given file of the step.

Parameters:
  • full_step_name (str) – The full name of the step.

  • filename (str) – The name of the file.

Returns:

The full path to the file.

Return type:

Path

abstract load(full_step_name: str, filename: str)

Abstract method to load an object.

Parameters:
  • full_step_name (str) – The full name of the step.

  • filename (str) – The name of the file to load from.

Returns:

Loaded object.

Return type:

Any

abstract save(obj: Any, full_step_name: str, filename: str = '')

Abstract method to save an object.

Parameters:
  • obj (Any) – The object to save.

  • full_step_name (str) – The full name of the step.

  • filename (str, optional) – The name of the file to save to. Defaults to an empty string.

Module contents