dcnum.common
Attributes
Lazily loaded h5py module |
Classes
Lazily load a module |
Functions
|
Get the number of processes available |
|
Patiently join a worker (Thread or Process) |
|
|
|
Hook for LazyLoader that imports hdf5plugin |
Module Contents
- class dcnum.common.LazyLoader(modname: str, sibling: str = None, action: Callable = None)[source]
Lazily load a module
- Parameters:
modname (str) – The name of the module (e.g.
"scipy.ndimage")sibling (str) –
The
__name__of a sibling of the module. This is useful for performing relative imports. Consider this module structure:module-submod_1-submod_2
If
submod_1would like to lazily importsubmod_2:submod_2 = LazyLoader("submod_2", sibling==__name__)
action (Callable) – Method that should be called after the actual import. Must accept the module as an argument. This is useful if any setup steps need to be made after import (e.g. for ensuring reproducibility).
- _modname
- _mod = None
- _action = None
- dcnum.common.cpu_count() int[source]
Get the number of processes available
multiprocessing.cpu_count()returns the number of logical CPUs available. We are interested in the physical CPUs, because there is no performance advantage to using all logical CPUs and because using more CPUs would imply more workers and thus more RAM usage.On cluster systems, with jobs possibly having CPU affinity, we want to stick to that limitation as well.
This method handles both cases by:
Get the number of physical CPUs using psutil.cpu_count(logical=False)
Get the number of CPUs according to process affinity
Get the number of CPUs using multiprocessing.cpu_count()
Return the minimum of all of the above
- dcnum.common.join_worker(worker, timeout=30, retries=10, logger=None, name=None)[source]
Patiently join a worker (Thread or Process)
- dcnum.common.h5py
Lazily loaded h5py module