yamle.utils.file_utils module#

yamle.utils.file_utils.import_config_function_from_file(config_file)[source]#

This method is used to import a config function from a file.

Note that the function name needs to be exactly configuration_space.

Return type:

Callable

yamle.utils.file_utils.current_time()[source]#

This method is used to get the current time to the millisecond.

Return type:

str

yamle.utils.file_utils.log_file(save_path)[source]#

This method is used to create the log file.

Return type:

str

yamle.utils.file_utils.config_logger(log_path)[source]#

This method is used to configure the logger.

Return type:

None

yamle.utils.file_utils.create_experiment_folder(save_path, src_folder, cache_scripts=True)[source]#

This method is used to create the experiment folder and archite any code in the the src_folder.

Return type:

str

yamle.utils.file_utils.save_scripts(save_path, src_folder)[source]#

This method is used to copy all the files in the the src_folder to the save_path while preserving the folder structure relative the to src_folder.

Return type:

None

yamle.utils.file_utils.get_experiment_name(args, mode='train')[source]#

This method is used to get the experiment name.

Return type:

str

yamle.utils.file_utils.argparse_to_dictionary(args)[source]#

This method is used to convert an argparse.Namespace to a dictionary.

Return type:

Dict[str, Any]

yamle.utils.file_utils.argparse_to_command(args)[source]#

This is a method to convert an argparse.Namespace to a command arguments executable in the terminal.

Return type:

str

yamle.utils.file_utils.argparse_to_config_file(args, config_file, ignore_arguments=['save_path', 'load_path', 'st_checkpoint_dir', 'label', 'seed', 'trainer_devices'], replace_arguments={'trainer_mode': 'train'}, import_lines=[])[source]#

This method is used to convert an argparse.Namespace to a config file.

It creates a function def config_space(): and returns the config dictionary with an argument per line.

Parameters:
  • args (argparse.Namespace) – The arguments.

  • config_file (str) – The config file path.

  • ignore_arguments (List[str], optional) – The arguments to ignore. Defaults to [].

  • replace_arguments (Dict[str, str], optional) – The arguments to replace. Defaults to {}.

  • import_lines (List[str], optional) – The import lines to add to the config file. Defaults to [].

Return type:

str

yamle.utils.file_utils.parse_args(args)[source]#

This method is used to post process the arguments.

Return type:

Namespace

yamle.utils.file_utils.store_metrics(results, metrics, prefix)[source]#

This method is used to store the metrics.

Parameters:
  • results (Dict[str, Any]) – The dictionary where the metrics are stored.

  • metrics (nn.ModuleDict) – The metrics.

  • prefix (str) – The prefix to be used for the metrics.

Return type:

None

yamle.utils.file_utils.results_file(save_path)[source]#

This method is used to create the results file.

Return type:

str

yamle.utils.file_utils.tuning_results_file(save_path)[source]#

This method is used to create the results file.

Return type:

str

yamle.utils.file_utils.model_file(save_path)[source]#

This method is used to create the model file.

Return type:

str

yamle.utils.file_utils.model_onnx_file(save_path)[source]#

This method is used to create the model file.

Return type:

str

yamle.utils.file_utils.model_initial_file(save_path)[source]#

This method is used to create the randomly initialized model file.

Return type:

str

yamle.utils.file_utils.model_quantized_file(save_path)[source]#

This method is used to create the quantized model file.

Return type:

str

yamle.utils.file_utils.model_best_on_validation_file(save_path)[source]#

This method is used to create the model which is the best on the validation set file.

Return type:

str

yamle.utils.file_utils.model_train_epoch_file(save_path, epoch)[source]#

This method is used to create the model file for a specific epoch.

Return type:

str

yamle.utils.file_utils.method_file(save_path)[source]#

This method is used to create the method file.

Return type:

str

yamle.utils.file_utils.args_file(save_path)[source]#

This method is used to create the args file.

Return type:

str

yamle.utils.file_utils.args_dictionary_file(save_path)[source]#

This method is used to create the args dictionary file.

Return type:

str

yamle.utils.file_utils.plots_file(save_path, specific_name='')[source]#

This method is used to create the plots file.

Return type:

str

yamle.utils.file_utils.config_file(save_path)[source]#

This method is used to create the config file.

Return type:

str

yamle.utils.file_utils.predictions_file(save_path, special_name='')[source]#

This method is used to create the predictions file.

Return type:

str

yamle.utils.file_utils.save_pickle(obj, path)[source]#

This method is used to save a pickle file.

Return type:

None

yamle.utils.file_utils.load_pickle(path)[source]#

This method is used to load a pickle file.

Return type:

Any

yamle.utils.file_utils.save_model(model, path)[source]#

This method is used to save a model.

Return type:

None

yamle.utils.file_utils.load_model(model, path)[source]#

This method is used to load a model.

Return type:

Module

yamle.utils.file_utils.save_model_onnx(model, path)[source]#

This method is used to save a model.

Return type:

None

yamle.utils.file_utils.save_method(method, path)[source]#

This method is used to save a method.

Return type:

None

yamle.utils.file_utils.load_method(method, path)[source]#

This method is used to load a method.

Return type:

None

yamle.utils.file_utils.save_args(args, path)[source]#

This method is used to save the arguments.

Return type:

None

yamle.utils.file_utils.load_args(path)[source]#

This method is used to load the arguments.

Return type:

Namespace

yamle.utils.file_utils.save_args_dictionary(args, path)[source]#

This method is used to save the arguments dictionary.

Return type:

None

yamle.utils.file_utils.load_args_dictionary(path)[source]#

This method is used to load the arguments dictionary.

Return type:

Dict[str, Any]

yamle.utils.file_utils.save_results(results, path)[source]#

This method is used to save the results.

Return type:

None

yamle.utils.file_utils.load_results(path)[source]#

This method is used to load the results.

Return type:

Dict[str, Any]

yamle.utils.file_utils.save_tuning_results(results, path)[source]#

This method is used to save the results.

Return type:

None

yamle.utils.file_utils.load_tuning_results(path)[source]#

This method is used to load the results.

Return type:

DataFrame

yamle.utils.file_utils.save_experiment(save_path, args, method, results, overwrite=False, overwrite_results=False)[source]#

This method is used to save the experiment.

Parameters:
  • save_path (str) – The experiment path folder.

  • args (argparse.Namespace) – The arguments.

  • method (LightningModule) – The method.

  • model (nn.Module) – The model.

  • results (Optional[Dict[str, Any]]) – The results dictionary.

  • overwrite (bool, optional) – Whether to overwrite the experiment. Defaults to False.

  • overwrite_results (bool, optional) – Whether to overwrite the results. Defaults to False.

Return type:

None

yamle.utils.file_utils.remove_argparse_argument(parser, arg_name)[source]#

This method is used to remove an argument from the parser.

Return type:

None