nntool.experiment¶

Classes¶

BaseExperimentConfig

Configuration class for setting up an experiment.

Functions¶

get_current_time

get current time in this format: MMDDYYYY/HHMMSS

get_output_path

Get output path based on environment variable OUTPUT_PATH and NNTOOL_OUTPUT_PATH.

read_toml_file

Read a toml file and return the content as a dictionary

Descriptions¶

class nntool.experiment.BaseExperimentConfig(config_name, output_folder, experiment_name_key='EXP_NAME', env_toml_path='env.toml', append_date_to_path=True, existing_output_path_ok=False)[source]¶

Configuration class for setting up an experiment.

Parameters:
  • config_name (str) – The name of the configuration.

  • output_folder (str) – The folder path where the outputs will be saved.

  • experiment_name_key (str) – Key for experiment name in the environment variable, default is ‘EXP_NAME’.

  • env_toml_path (str) – Path to the env.toml file, default is ‘env.toml’.

  • append_date_to_path (bool) – If True, the current date and time will be appended to the output path, default is True.

  • existing_output_path_ok (bool) – If True, the existing output path is ok to be reused, default is False.

get_current_time()[source]¶

Return the current time for the experiment.

Returns:

current time for the experiment

Return type:

str

get_output_path()[source]¶

Return the output path prepared for the experiment.

Returns:

output path for the experiment

Return type:

str

set_up_stateful_fields()[source]¶

Post configuration steps for stateful fields such as output_path in the derived class. This method should be overridden in the derived class.

start()[source]¶

Start the experimen. This will - cache NNTOOL_OUTPUT_PATH and NNTOOL_OUTPUT_PATH_DATE into environment variables, which means the later launched processes would inherit these variables. - create the output path if it does not exist.

nntool.experiment.get_current_time()[source]¶

get current time in this format: MMDDYYYY/HHMMSS

Returns:

time in the format MMDDYYYY/HHMMSS

Return type:

str

nntool.experiment.get_output_path(output_path='./', append_date=True, cache_into_env=True)[source]¶

Get output path based on environment variable OUTPUT_PATH and NNTOOL_OUTPUT_PATH. The output path is appended with the current time if append_date is True (e.g. /OUTPUT_PATH/xxx/MMDDYYYY/HHMMSS).

Parameters:
  • append_date (bool) – append a children folder with the date time, defaults to True

  • cache_into_env (bool) – whether cache the newly created path into env, defaults to True

Returns:

(output path, current time)

Return type:

tuple[str, str]

nntool.experiment.read_toml_file(file_path)[source]¶

Read a toml file and return the content as a dictionary

Parameters:

file_path (str) – path to the toml file

Returns:

content of the toml file as a dictionary

Return type:

dict