Skip to content

Commit 096b091

Browse files
authored
Merge pull request #818 from HEXRD/cli-preload-data
Preload data for CLI fit-grains
2 parents 20bb998 + b6facd6 commit 096b091

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

hexrd/fitgrains.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,16 @@ def fit_grains(cfg,
386386
else:
387387
nproc = min(ncpus, len(grains_table))
388388
chunksize = max(1, len(grains_table)//ncpus)
389+
390+
if multiprocessing.get_start_method() == 'fork':
391+
# For frame cache, we need to load in all of the data up-front
392+
# so it can use fork multiprocessing to share with the other
393+
# processes. Otherwise, every process will load in the data on
394+
# its own. Accessing one frame in the imageseries is currently
395+
# all we need to do to trigger frame caches to load in all the data.
396+
for ims in imsd.values():
397+
ims[0]
398+
389399
logger.info("\tstarting fit on %d processes with chunksize %d",
390400
nproc, chunksize)
391401
start = timeit.default_timer()

hexrd/imageseries/load/hdf5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def __getitem__(self, key):
6767
if not isinstance(key, int):
6868
# FIXME: we do not yet support fancy indexing here.
6969
# Fully expand the array then apply the fancy indexing.
70-
return self[key[0]][*key[1:]]
70+
return self[key[0]][tuple(key[1:])]
7171

7272
if self._ndim == 2:
7373
if key != 0:

hexrd/imageseries/load/imagefiles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __getitem__(self, key):
4848
if not isinstance(key, int):
4949
# FIXME: we do not yet support fancy indexing here.
5050
# Fully expand the array then apply the fancy indexing.
51-
return self[key[0]][*key[1:]]
51+
return self[key[0]][tuple(key[1:])]
5252

5353
if self.singleframes:
5454
frame = None

hexrd/imageseries/load/rawimage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def __getitem__(self, key):
114114
if not isinstance(key, int):
115115
# FIXME: we do not yet support fancy indexing here.
116116
# Fully expand the array then apply the fancy indexing.
117-
return self[key[0]][*key[1:]]
117+
return self[key[0]][tuple(key[1:])]
118118

119119
count = key * self._frame_bytes + self.skipbytes
120120

0 commit comments

Comments
 (0)