diff --git a/CHAP/edd/utils.py b/CHAP/edd/utils.py index c698a32..c658292 100755 --- a/CHAP/edd/utils.py +++ b/CHAP/edd/utils.py @@ -1398,6 +1398,7 @@ def get_spectra_fits(spectra, energies, peak_locations, detector): numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray] """ + from os import getpid # Third party modules from nexusformat.nexus import NXdata, NXfield @@ -1432,6 +1433,7 @@ def get_spectra_fits(spectra, energies, peak_locations, detector): # 'method': 'trf', 'method': 'leastsq', # 'method': 'least_squares', + 'memfolder': f'/tmp/{getpid()}_joblib_memmap', } # Perform uniform fit diff --git a/CHAP/utils/fit.py b/CHAP/utils/fit.py index 077dcf3..132df2f 100755 --- a/CHAP/utils/fit.py +++ b/CHAP/utils/fit.py @@ -2084,7 +2084,7 @@ def __init__(self, nxdata, config): self._best_values = None self._inv_transpose = None self._max_nfev = None - self._memfolder = None + self._memfolder = config.memfolder self._new_parameters = None self._num_func_eval = None self._out_of_bounds = None @@ -2319,7 +2319,6 @@ def freemem(self): return try: rmtree(self._memfolder) - self._memfolder = None except: logger.warning('Could not clean-up automatically.') @@ -2514,7 +2513,6 @@ def fit(self, config=None, **kwargs): np.zeros(self._map_dim, dtype=np.float64) for _ in range(num_new_parameters)] else: - self._memfolder = 'joblib_memmap' try: mkdir(self._memfolder) except FileExistsError: diff --git a/CHAP/utils/models.py b/CHAP/utils/models.py index db08239..12d5ea5 100755 --- a/CHAP/utils/models.py +++ b/CHAP/utils/models.py @@ -568,6 +568,7 @@ class FitConfig(BaseModel): num_proc: conint(gt=0) = 1 plot: StrictBool = False print_report: StrictBool = False + memfolder: str = 'joblib_memmap' @field_validator('method') @classmethod