hdf5_cache module¶
Caching module to store all the entries in an HDF file.
- class gemseo.caches.hdf5_cache.HDF5Cache(tolerance=0.0, name=None, hdf_file_path='cache.hdf5', hdf_node_path='node')[source]¶
Bases:
AbstractFullCache
Cache using disk HDF5 file to store the data.
- Parameters:
name (str) – A name for the cache. If
None
, usehdf_node_path`
.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 methodDOEScenario.set_optimization_history_backup()
is recommended as an alternative.- cache_jacobian(input_data, jacobian_data)¶
Cache the input and Jacobian data.
- cache_outputs(input_data, output_data)¶
Cache input and output data.
- get(k[, d]) D[k] if k in D, else d. d defaults to None. ¶
- items() a set-like object providing a view on D's items ¶
- keys() a set-like object providing a view on D's keys ¶
- to_dataset(name='', categorize=True, input_names=(), output_names=())¶
Build a
IODataset
from the cache.- Parameters:
name (str) –
A name for the dataset. If empty, use the name of the cache.
By default it is set to “”.
categorize (bool) –
Whether to distinguish between the different groups of variables. Otherwise, group all the variables in
Dataset.PARAMETER_GROUP`
.By default it is set to True.
The names of the inputs to be exported. If empty, use all the inputs.
By default it is set to ().
output_names (Iterable[str]) –
The names of the outputs to be exported. If empty, use all the outputs. If an output name is also an input name, the output name is suffixed with
[out]
.By default it is set to ().
- Returns:
A dataset version of the cache.
- Return type:
- to_ggobi(file_path, input_names=None, output_names=None)¶
Export the cache to an XML file for ggobi tool.
- update(other_cache)¶
Update from another cache.
- Parameters:
other_cache (AbstractFullCache) – The cache to update the current one.
- Return type:
None
- static update_file_format(hdf_file_path)[source]¶
Update the format of a HDF5 file.
See also
- Parameters:
hdf_file_path (str | Path) – A HDF5 file path.
- Return type:
None
- values() an object providing a view on D's values ¶
- property hdf_file: HDF5FileSingleton¶
The HDF file handler.
- property last_entry: CacheEntry¶
The last cache entry.
- lock: RLock¶
The lock used for both multithreading and multiprocessing.
Ensure safe multiprocessing and multithreading concurrent access to the cache.
- lock_hashes: RLock¶
The lock used for both multithreading and multiprocessing.
Ensure safe multiprocessing and multithreading concurrent access to the cache.