gemseo.caches.hdf5_cache module#

Caching module to store all the entries in an HDF file.

class HDF5Cache(tolerance=0.0, name='', hdf_file_path='cache.hdf5', hdf_node_path='node')[source]#

Bases: BaseFullCache

Cache using disk HDF5 file to store the data.

Parameters:
  • name (str) --

    A name for the cache. If empty, use hdf_node_path`.

    By default it is set to "".

  • hdf_file_path (str | Path) --

    The path of the HDF file. Initialize a singleton to access the HDF file. This singleton is used for multithreading/multiprocessing access with a lock.

    By default it is set to "cache.hdf5".

  • hdf_node_path (str) --

    The name to the HDF node, possibly passed as a path root_name/.../group_name/.../node_name.

    By default it is set to "node".

  • tolerance (float) --

    By default it is set to 0.0.

Warning

This class relies on some multiprocessing features, it is therefore necessary to protect its execution with an if __name__ == '__main__': statement when working on Windows. Currently, the use of an HDF5Cache is not supported in parallel on Windows platforms. This is due to the way subprocesses are forked in this architecture. The method DOEScenario.set_optimization_history_backup() is recommended as an alternative.

clear()[source]#

Clear the cache.

Return type:

None

get_all_entries()[source]#

Return an iterator over all the entries.

The tolerance is ignored.

Yields:

The entries.

Return type:

Iterator[CacheEntry]

static update_file_format(hdf_file_path)[source]#

Update the format of a HDF5 file.

See also

HDF5FileSingleton.update_file_format().

Parameters:

hdf_file_path (str | Path) -- A HDF5 file path.

Return type:

None

property hdf_file: HDF5FileSingleton#

The HDF file handler.

property hdf_node_path: str#

The path to the HDF node.