Skip to content

Commit 0a8b95c

Browse files
author
dPys
committed
Reduce /tmp storage
1 parent a764d34 commit 0a8b95c

File tree

3 files changed

+29
-22
lines changed

3 files changed

+29
-22
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ RUN apt-get update -qq \
8585
&& rm -r fsl* \
8686
&& chmod 777 -R $FSLDIR/bin \
8787
&& chmod 777 -R /usr/lib/fsl/5.0 \
88-
&& echo "tmpfs /tmp tmpfs rwx,nodev,nosuid,size=15G 0 0" >> /etc/fstab
88+
&& echo "tmpfs /tmp tmpfs rw,nodev,nosuid,size=10G 0 0" >> /etc/fstab
8989

9090
ENV FSLDIR=/usr/share/fsl/5.0 \
9191
FSLOUTPUTTYPE=NIFTI_GZ \

pynets/cli/pynets_collect.py

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ def load_pd_dfs(file_):
113113
except:
114114
print(f"Cannot load {file_}")
115115
df = pd.DataFrame()
116-
return df
117116
if "Unnamed: 0" in df.columns:
118117
df.drop(df.filter(regex="Unnamed: 0"), axis=1, inplace=True)
119118
id = op.basename(file_).split("_topology")[0].split('auc_')[1]
@@ -175,14 +174,13 @@ def load_pd_dfs(file_):
175174
os.remove(f"{file_.split('.csv')[0]}{'_clean.csv'}")
176175
df.to_csv(f"{file_.split('.csv')[0]}{'_clean.csv'}", index=False)
177176
del id
178-
177+
gc.collect()
179178
else:
180179
print(f"{Fore.RED}Cleaned {file_} missing...{Style.RESET_ALL}")
181180
df = pd.DataFrame()
182181
else:
183182
print(f"{Fore.RED}{file_} missing...{Style.RESET_ALL}")
184183
df = pd.DataFrame()
185-
gc.collect()
186184

187185
return df
188186

@@ -531,6 +529,7 @@ def load_pd_dfs_auc(atlas_name, prefix, auc_file, modality, drop_cols):
531529
from colorama import Fore, Style
532530
import pandas as pd
533531
import re
532+
import numpy as np
534533
import os
535534

536535
pd.set_option("display.float_format", lambda x: f"{x:.8f}")
@@ -545,8 +544,7 @@ def load_pd_dfs_auc(atlas_name, prefix, auc_file, modality, drop_cols):
545544
auc_file, chunksize=100000, compression="gzip",
546545
encoding="utf-8", engine='python').read()
547546
except:
548-
df_pref = pd.DataFrame()
549-
return df_pref
547+
df = pd.DataFrame()
550548

551549
#print(f"{'Atlas: '}{atlas_name}")
552550
prefix = f"{atlas_name}{'_'}{prefix}{'_'}"
@@ -813,6 +811,7 @@ def collect_all(working_path, modality, drop_cols):
813811
def build_collect_workflow(args, retval):
814812
import os
815813
import glob
814+
import psutil
816815
import warnings
817816
warnings.filterwarnings("ignore")
818817
import ast
@@ -862,20 +861,6 @@ def build_collect_workflow(args, retval):
862861

863862
wf = collect_all(working_path, modality, drop_cols)
864863

865-
hardcoded_params = load_runconfig()
866-
runtime_dict = {}
867-
execution_dict = {}
868-
for i in range(len(hardcoded_params["resource_dict"])):
869-
runtime_dict[
870-
list(hardcoded_params["resource_dict"][i].keys())[0]
871-
] = ast.literal_eval(
872-
list(hardcoded_params["resource_dict"][i].values())[0][0]
873-
)
874-
for i in range(len(hardcoded_params["execution_dict"])):
875-
execution_dict[
876-
list(hardcoded_params["execution_dict"][i].keys())[0]
877-
] = list(hardcoded_params["execution_dict"][i].values())[0][0]
878-
879864
run_uuid = f"{strftime('%Y%m%d_%H%M%S')}_{uuid.uuid4()}"
880865
os.makedirs(f"{work_dir}/pynets_out_collection{run_uuid}", exist_ok=True)
881866
wf.base_dir = f"{work_dir}/pynets_out_collection{run_uuid}"
@@ -912,9 +897,30 @@ def build_collect_workflow(args, retval):
912897
handler = logging.FileHandler(callback_log_path)
913898
logger.addHandler(handler)
914899

900+
execution_dict = {}
915901
execution_dict["crashdump_dir"] = str(wf.base_dir)
916902
execution_dict["plugin"] = str(plugin_type)
903+
execution_dict["poll_sleep_duration"] = 0.5
904+
execution_dict["crashfile_format"] = "txt"
905+
execution_dict["local_hash_check"] = False
906+
execution_dict["stop_on_first_crash"] = False
907+
execution_dict['hash_method'] = 'timestamp'
908+
execution_dict["keep_inputs"] = True
909+
execution_dict["use_relative_paths"] = False
910+
execution_dict["remove_unnecessary_outputs"] = False
911+
execution_dict["remove_node_directories"] = False
912+
execution_dict["raise_insufficient"] = False
913+
nthreads = psutil.cpu_count() * 2
914+
procmem = [int(nthreads),
915+
int(list(psutil.virtual_memory())[4] / 1000000000) - 2]
916+
plugin_args = {
917+
"n_procs": int(procmem[0]),
918+
"memory_gb": int(procmem[1]),
919+
"scheduler": "topological_sort",
920+
}
921+
execution_dict["plugin_args"] = plugin_args
917922
cfg = dict(execution=execution_dict)
923+
918924
for key in cfg.keys():
919925
for setting, value in cfg[key].items():
920926
wf.config[key][setting] = value
@@ -976,7 +982,8 @@ def main():
976982
args_dict_all['plug'] = 'MultiProc'
977983
args_dict_all['v'] = False
978984
#args_dict_all['pm'] = '48,67'
979-
args_dict_all['pm'] = '224,2000'
985+
args_dict_all['pm'] = '128,500'
986+
#args_dict_all['pm'] = '224,2000'
980987
#args_dict_all['basedir'] = '/working/tuning_set/outputs_clustering/pynets'
981988
#args_dict_all['basedir'] = '/working/tuning_set/outputs_shaeffer/pynets'
982989
#args_dict_all['basedir'] = '/working/tuning_set/outputs_language/pynets'

pynets/dmri/estimation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ def streams2graph(
815815
),
816816
)
817817

818-
tmp_files = [streams, warped_fa, atlas_mni]
818+
tmp_files = [streams, warped_fa]
819819
for j in tmp_files:
820820
if j is not None:
821821
if os.path.isfile(j):

0 commit comments

Comments
 (0)