wf_psf.utils.configs_handler

Configs_Handler.

A module which provides general utility methods to manage the parameters of the config files

Authors:

Jennifer Pollack <jennifer.pollack@cea.fr>

Functions

get_run_config(run_config_name, *config_params)

Get Run Configuration Instance.

register_configclass(config_class)

Register Config Class.

set_run_config(config_name)

Set Run Configuration Class.

Classes

DataConfigHandler(data_conf, ...[, ...])

DataConfigHandler.

MetricsConfigHandler(metrics_conf, file_handler)

MetricsConfigHandler.

PlottingConfigHandler(plotting_conf, ...)

PlottingConfigHandler.

TrainingConfigHandler(training_conf, ...)

TrainingConfigHandler.

Exceptions

ConfigParameterError([message])

Custom Config Parameter Error exception class for specific error scenarios.

exception wf_psf.utils.configs_handler.ConfigParameterError(message='An error with your config settings occurred.')[source]

Bases: Exception

Custom Config Parameter Error exception class for specific error scenarios.

class wf_psf.utils.configs_handler.DataConfigHandler(data_conf, training_model_params, batch_size=16, load_data=True)[source]

Bases: object

DataConfigHandler.

A class to handle data configuration parameters.

Parameters:
  • data_conf (str) – Path of the data configuration file

  • training_model_params (Recursive Namespace object) – Recursive Namespace object containing the training model parameters

  • batch_size (int) – Training hyperparameter used for batched pre-processing of data.

class wf_psf.utils.configs_handler.MetricsConfigHandler(metrics_conf, file_handler, training_conf=None)[source]

Bases: object

MetricsConfigHandler.

A class to handle metrics configuation parameters.

Parameters:
  • ids (tuple) – A tuple containing a string id for the Configuration Class

  • metrics_conf (str) – Path to the metrics configuration file

  • file_handler (object) – An instance of the FileIOHandler

  • training_conf (RecursiveNamespace object) – RecursiveNamespace object containing the training configuration parameters

Attributes:
data_conf

Get Data Conf.

metrics_conf

Get Metrics Conf.

metrics_dir

Get Metrics Directory.

plotting_conf

Get Plotting Conf.

psf_model

Get PSF Model.

training_conf

Get Training Conf.

weights_basename_filepath

Get PSF model weights filepath.

weights_path

Get Weights Path.

Methods

call_plot_config_handler_run(model_metrics)

Make Metrics Plots.

run()

Run.

call_plot_config_handler_run(model_metrics)[source]

Make Metrics Plots.

A function to call the PlottingConfigHandler run command to generate metrics plots.

Parameters:

model_metrics (dict) – A dictionary storing the metrics output generated during evaluation of the trained PSF model.

property data_conf

Get Data Conf.

A function to return an instance of the DataConfigHandler class.

Return type:

An instance of the DataConfigHandler class.

ids = ('metrics_conf',)
property metrics_conf

Get Metrics Conf.

A function to return the metrics configuration file name.

Returns:

An instance of the metrics configuration file.

Return type:

RecursiveNamespace

property metrics_dir

Get Metrics Directory.

A function that returns path of metrics directory.

Returns:

Absolute path to metrics directory

Return type:

str

property plotting_conf

Get Plotting Conf.

A function to return the plotting configuration file name.

Returns:

Name of plotting configuration file

Return type:

str

property psf_model

Get PSF Model.

A function to return an instance of the PSF model to be evaluated.

Returns:

psf_model – An instance of the PSF model to be evaluated.

Return type:

obj

run()[source]

Run.

A function to run wave-diff according to the input configuration.

property training_conf

Get Training Conf.

A function to return the training configuration file name.

Returns:

An instance of the training configuration file.

Return type:

RecursiveNamespace

property weights_basename_filepath

Get PSF model weights filepath.

A function to return the basename of the user-specified psf model weights path.

Returns:

weights_basename – The basename of the psf model weights to be loaded.

Return type:

str

property weights_path

Get Weights Path.

A function to return the full path of the user-specified psf model weights to be loaded.

Returns:

A string representing the full path to the psf model weights to be loaded.

Return type:

str

class wf_psf.utils.configs_handler.PlottingConfigHandler(plotting_conf, file_handler)[source]

Bases: object

PlottingConfigHandler.

A class to handle plotting config settings.

Parameters:
  • ids (tuple) – A tuple containing a string id for the Configuration Class

  • plotting_conf (str) – Name of plotting configuration file

  • file_handler (obj) – An instance of the FileIOHandler class

Methods

check_and_update_metrics_confs()

Check and Update Metrics Confs.

load_metrics_into_dict()

Load Metrics into Dictionary.

make_dict_of_metrics()

Make dictionary of metrics.

run()

Run.

check_and_update_metrics_confs()[source]

Check and Update Metrics Confs.

A function to check if user provided inputs metrics dir to add to metrics_confs dictionary.

ids = ('plotting_conf',)
load_metrics_into_dict()[source]

Load Metrics into Dictionary.

A method to load a metrics file of a trained model from a previous run into a dictionary.

Returns:

metrics_files_dict – A dictionary containing all of the metrics from the loaded metrics files.

Return type:

dict

make_dict_of_metrics()[source]

Make dictionary of metrics.

A function to create a dictionary for each metrics per run.

Returns:

A dictionary containing metrics or an empty dictionary.

Return type:

dict

run()[source]

Run.

A function to run wave-diff according to the input configuration.

class wf_psf.utils.configs_handler.TrainingConfigHandler(training_conf, file_handler)[source]

Bases: object

TrainingConfigHandler.

A class to handle training configuration parameters.

Parameters:
  • ids (tuple) – A tuple containing a string id for the Configuration Class

  • training_conf (str) – Path of the training configuration file

  • file_handler (object) – A instance of the FileIOHandler class

Methods

run()

Run.

ids = ('training_conf',)
run()[source]

Run.

A function to run wavediff according to the input configuration.

wf_psf.utils.configs_handler.get_run_config(run_config_name, *config_params)[source]

Get Run Configuration Instance.

A function to retrieve an instance of the appropriate configuration class for a WF-PSF run.

Parameters:
  • run_config_name (str) – Name of the run configuraton

  • *config_params (str) – Run configuration parameters used for class instantiation.

Returns:

config_class – A class instance of the selected configuration class.

Return type:

object

wf_psf.utils.configs_handler.register_configclass(config_class)[source]

Register Config Class.

A wrapper function to register all config classes in a dictionary.

Parameters:

config_class (type) – Config Class

Returns:

config_class – Config class

Return type:

type

wf_psf.utils.configs_handler.set_run_config(config_name)[source]

Set Run Configuration Class.

A function to retrieve the appropriate configuration class based on the provided config name.

Parameters:

config_name (str) – Name of config

Returns:

config_class – Name of config class

Return type:

class