Skip to content

Commit 5b44c2c

Browse files
author
dPys
committed
[FIX] Prevent leaked semaphores on tracking
1 parent f7fa9ce commit 5b44c2c

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

.vagrant/rgloader/loader.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# This file loads the proper rgloader/loader.rb file that comes packaged
2+
# with Vagrant so that encoded files can properly run with Vagrant.
3+
4+
if ENV["VAGRANT_INSTALLER_EMBEDDED_DIR"]
5+
require File.expand_path(
6+
"rgloader/loader", ENV["VAGRANT_INSTALLER_EMBEDDED_DIR"])
7+
else
8+
raise "Encoded files can't be read outside of the Vagrant installer."
9+
end

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ RUN apt-get update -qq \
8787
&& chmod 777 -R $FSLDIR/bin \
8888
&& chmod 777 -R /usr/lib/fsl/5.0 \
8989
&& echo "tmpfs /tmp tmpfs rw,nodev,nosuid,size=10G 0 0" >> /etc/fstab
90+
# && wget --retry-connrefused --waitretry=5 --read-timeout=60 --timeout=60 -t 0 -q -O examples.tar.gz "https://osf.io/ye4vf/download" && tar -xvzf examples.tar.gz -C /tmp \
91+
# && rm -rf examples.tar.gz
9092

9193
ENV FSLDIR=/usr/share/fsl/5.0 \
9294
FSLOUTPUTTYPE=NIFTI_GZ \

pynets/cli/pynets_run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ def build_workflow(args, retval):
795795
import psutil
796796
nthreads = psutil.cpu_count()
797797
procmem = [int(nthreads),
798-
int(list(psutil.virtual_memory())[4]/1000000000) - 2]
798+
int(list(psutil.virtual_memory())[4]/1000000000) - 1]
799799
else:
800800
procmem = list(eval(str(resources)))
801801
procmem[1] = procmem[1] - 1

pynets/dmri/track.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ def track_ensemble(
404404
import os
405405
import gc
406406
import time
407+
import warnings
407408
from joblib import Parallel, delayed
408409
import itertools
409410
from pynets.dmri.track import run_tracking
@@ -414,6 +415,7 @@ def track_ensemble(
414415
from nilearn.masking import intersect_masks
415416
from nilearn.image import math_img
416417
from pynets.core.utils import load_runconfig
418+
warnings.filterwarnings("ignore")
417419

418420
tmp_files_dir = f"{cache_dir}/tmp_files"
419421
joblib_dir = f"{cache_dir}/joblib_tracking"
@@ -480,7 +482,7 @@ def track_ensemble(
480482
while float(stream_counter) < float(target_samples) and float(ix) < 0.50*float(len(all_combs)):
481483
with Parallel(n_jobs=nthreads, backend='loky',
482484
mmap_mode='r+', temp_folder=joblib_dir,
483-
verbose=2, max_nbytes='25000M',
485+
verbose=0, max_nbytes='50000M',
484486
timeout=timeout) as parallel:
485487
out_streams = parallel(
486488
delayed(run_tracking)(
@@ -529,7 +531,7 @@ def track_ensemble(
529531
)
530532
gc.collect()
531533
print(Style.RESET_ALL)
532-
os.system(f"rm -f {joblib_dir}/* &")
534+
os.system(f"rm -f {joblib_dir}/*")
533535
except BaseException:
534536
os.system(f"rm -f {tmp_files_dir} &")
535537
return None

0 commit comments

Comments
 (0)