Skip to content

Commit 086a5f1

Browse files
committed
abandon MPIPoolExecutor
1 parent 91cf2e0 commit 086a5f1

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

py/fastspecfit/mpi.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,12 @@ def plan(size=1, specprod=None, specprod_dir=None, coadd_type='healpix',
283283

284284
if merge:
285285
if len(outfiles) == 0:
286-
if rank == 0:
287-
log.debug(f'No {outprefix} files in {outdir} found!')
286+
log.debug(f'No {outprefix} files in {outdir} found!')
288287
return '', list(), list(), list(), None
289288
return outdir, redrockfiles, outfiles, None, None
290289
elif makeqa:
291290
if len(outfiles) == 0:
292-
if rank == 0:
293-
log.debug(f'No {outprefix} files in {outdir} left to do!')
291+
log.debug(f'No {outprefix} files in {outdir} left to do!')
294292
return '', list(), list(), list(), None
295293
# hack--build the output directories and pass them in the 'redrockfiles'
296294
# position! for coadd_type==cumulative, strip out the 'lastnight' argument
@@ -300,8 +298,7 @@ def plan(size=1, specprod=None, specprod_dir=None, coadd_type='healpix',
300298
redrockfiles = np.array([os.path.dirname(outfile).replace(outdir, htmldir) for outfile in outfiles])
301299
else:
302300
if len(redrockfiles) == 0:
303-
if rank == 0:
304-
log.info('All files have been processed!')
301+
log.info('All files have been processed!')
305302
return '', list(), list(), list(), None
306303

307304
return outdir, redrockfiles, outfiles, groups, ntargets

py/fastspecfit/util.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,23 @@ class MPPool(object):
5353
rather than a list of positional arguments.
5454
5555
"""
56-
def __init__(self, nworkers, initializer=None, init_argdict=None, comm=None):
56+
def __init__(self, nworkers, initializer=None, init_argdict=None):
5757
"""
5858
create a pool with nworkers workers, using the current
5959
process if nworkers is 1. If initiializer is not None,
6060
apply this function to the arguments in keyword dictionary
6161
init_argdict on startup in each each worker subprocess.
6262
6363
"""
64-
6564
initfunc = None if initializer is None else self.apply_to_dict
6665

66+
## If multiprocessing, create a pool of worker processes and initialize
67+
## single-copy objects in each worker.
68+
#if args.mp > 1 and not 'NERSC_HOST' in os.environ:
69+
# import multiprocessing
70+
# multiprocessing.set_start_method('fork')
6771
if nworkers > 1:
68-
if comm is not None:
69-
from mpi4py.futures import MPIPoolExecutor as Pool
70-
else:
71-
from multiprocessing import Pool
72+
from multiprocessing import Pool
7273
self.pool = Pool(nworkers,
7374
initializer=initfunc,
7475
initargs=(initializer, init_argdict,))

0 commit comments

Comments
 (0)