IO-tools#
This module provides some handy methods for creating paths and pickling and saving/checking/loading checkpoint files.
Under normal circumstances you shouldn’t have to use any of the methods in here if you use
the run module to run GPry.
Module containing i/o utilities.
- gpry.io.create_path(path, verbose=True)[source]#
Creates a path if it doesn’t exist already and prints a message if creating a new directory. If the directory already exits it does nothing.
- Parameters:
path (string or path) – The path which shall be created.
- gpry.io.check_checkpoint(path=None)[source]#
Checks if there are checkpoint files in a specific location and if so if they are complete. Returns a list of bools.
- Parameters:
path (string, optional) – The path where the files are located. If
None, reports files as non-found.- Returns:
A boolean array containing whether the files exist in the specified
location in the following order
[truth, gp, acquisition, convergence, options]
- gpry.io.read_checkpoint(path, truth=None)[source]#
Loads checkpoint files to be able to resume a run or save the results for further processing.
- Parameters:
path (string) – The path where the files are located.
truth (gpry.truth.Truth, optional) – If passed, it will be used instead of the loaded one.
- Returns:
(truth, gpr, acquisition, convergence, options, progress)
If any of the files does not exist or cannot be read the function will
return None instead.
- gpry.io.save_checkpoint(path, truth, gpr, acquisition, convergence, options, progress)[source]#
This function is used to save all relevant parts of the GP loop for reuse as checkpoint in case the procedure crashes. This function creates
.pklfiles which contain the instances of the different modules. The files can be loaded with the read_checkpoint function.- Parameters:
path (The path where the files shall be saved) – The files will be saved as path +(mod, gpr, acq, con, opt).pkl
truth (Truth)
gpr (GaussianProcessRegressor)
acquisition (GPAcquisition)
convergence (Convergence_criterion)
options (dict)
progress (Progress instance)
- gpry.io.ensure_gpr(gpr, truth=None, acquisition=None, convergence=None, options=None, progress=None)[source]#
Returns (if instance passed) or loads (if string) the given gpr and associated objects.
If loading, any object passed as a keyword will be preferred to the loaded one.
- Parameters:
gpr (GaussianProcessRegressor)
truth (Truth)
acquisition (GPAcquisition, optional)
convergence (Convergence_criterion, optional)
options (dict, optional)
progress (Progress instance, optional)
- Returns:
(truth, gpr, acquisition, convergence, options, progress)
If any of the files does not exist or cannot be read the function will
return None instead.