Skip to content

Commit 62c7ba7

Browse files
committed
fixup - process file 0 too
1 parent 920a964 commit 62c7ba7

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

ImageD11/sinograms/lima_segmenter.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,14 @@ def main(h5name, jobid):
374374
# Gemini suggested fork to suppress the multiprocessing context errors
375375
# We must ensure that hdf5 has not got any files open when doing this
376376
# Both spawn and forkserver run into problems reproducibly.
377-
ctx = multiprocessing.get_context('fork')
377+
ctx_type = 'spawn' # windows/mac
378+
if 'linux' in sys.platform:
379+
ctx_type = 'fork'
380+
# Long term: this is going to break. We need a better model for the
381+
# nested parallel processing of running many slurm jobs and each job
382+
# running a bunch of processes. Or we need to fix /dev/shm at ESRF.
383+
# The SemLocks are not multi-multi-process safe.
384+
ctx = multiprocessing.get_context(ctx_type)
378385
num_processes = min(options.cores_per_job, len(args))
379386
print("# Starting pool with", num_processes, " workers...", flush=True)
380387

@@ -435,7 +442,7 @@ def setup_slurm_array(dsname, dsgroup="/", pythonpath=None):
435442
" %.2f %% pixels are active" % (100 * options.mask.mean()),
436443
)
437444
files_per_job = options.files_per_core * options.cores_per_job
438-
jobs_needed = math.ceil(nfiles / files_per_job)
445+
jobs_needed = math.ceil(nfiles / files_per_job) - 1
439446
sbat = os.path.join(sdir, "lima_segmenter_slurm.sh")
440447
if pythonpath is None:
441448
cmd = sys.executable
@@ -451,7 +458,7 @@ def setup_slurm_array(dsname, dsgroup="/", pythonpath=None):
451458
#SBATCH --job-name=array-lima_segmenter
452459
#SBATCH --output=%s/lima_segmenter_%%A_%%a.out
453460
#SBATCH --error=%s/lima_segmenter_%%A_%%a.err
454-
#SBATCH --array=1-%d
461+
#SBATCH --array=0-%d
455462
#SBATCH --time=02:00:00
456463
# define memory needs and number of tasks for each array job
457464
#SBATCH --ntasks=1

0 commit comments

Comments
 (0)