From 61cbe684bbb50f082aefd8be0a37fcd1d7bb9d65 Mon Sep 17 00:00:00 2001 From: Guoli Lyu Date: Mon, 5 Oct 2020 17:24:08 +0800 Subject: [PATCH 1/2] matlab backward compatibility & slurm --- psom_build_dependencies.m | 3 +++ psom_pipeline_init.m | 2 +- psom_run_script.m | 18 +++++++++++------- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/psom_build_dependencies.m b/psom_build_dependencies.m index 009b8ba..d1dfcbf 100644 --- a/psom_build_dependencies.m +++ b/psom_build_dependencies.m @@ -163,6 +163,9 @@ num_out = num_all(length(cell_in)+1:length(cell_in)+length(cell_out)); num_clean = num_all(length(cell_in)+length(cell_out)+1:length(num_all)); nb_files = max(num_all); +if isempty(nb_files) + nb_files = 0; +end clear num_all val_tmp ind_tmp %% Build adjacency matrices for jobs x files diff --git a/psom_pipeline_init.m b/psom_pipeline_init.m index 182b13f..7169485 100644 --- a/psom_pipeline_init.m +++ b/psom_pipeline_init.m @@ -753,7 +753,7 @@ end path_work = path_search; -save(file_pipeline,'history','graph_deps','list_jobs','files_in','files_out','path_work') +save(file_pipeline,'history','graph_deps','list_jobs','files_in','files_out','path_work', '-mat') %% Save the status if flag_verbose>1 diff --git a/psom_run_script.m b/psom_run_script.m index 965128f..398f37b 100644 --- a/psom_run_script.m +++ b/psom_run_script.m @@ -264,7 +264,7 @@ instr_job = sprintf('%sexit\n',instr_job); end end - +instr_job = sprintf('#!/bin/sh\n%s',instr_job); %% Write the script if ~strcmp(opt.mode,'session') if opt.flag_debug @@ -404,13 +404,15 @@ % There might be a better way to find the job path and id, % however, I do not know the code well % enough at that point. - result_path = regexp(script,'(^.*)/logs','tokens'){1}{1}; - agent_id = regexp(script,'psom_*(\w*)','tokens'){1}{1}; + result_path = regexp(script,'(^.*)/logs','tokens'); + result_path = result_path{1}{1}; + agent_id = regexp(script,'psom_*(\w*)','tokens'); + agent_id = agent_id{1}{1}; instr_cbrain = sprintf('%s %s %s', sub, result_path, agent_id); % Check the max number of worker per node % This will start ppn worker per node - psom_ppn = getenv("PSOM_WORKER_PPN") + psom_ppn = getenv('PSOM_WORKER_PPN') if psom_ppn file_conf = [result_path '/logs/PIPE_config.mat']; pipe_opt = load(file_conf); @@ -443,8 +445,10 @@ script = [' SPLIT_LINE singularity_exec_options']; % There might be a better way to find the job path and id, however, I do not know the code well % enough at that point. - result_path = regexp(opt.path_search,'(^.*)/logs','tokens'){1}{1}; - agent_id = regexp(opt.name_job,'psom_*(\w*)','tokens'){1}{1}; + result_path = regexp(opt.path_search,'(^.*)/logs','tokens'); + result_path = result_path{1}{1}; + agent_id = regexp(opt.name_job,'psom_*(\w*)','tokens'); + agent_id = agent_id{1}{1}; if ~isempty(logs) qsub_logs = [' -e ' logs.eqsub ' -o ' logs.oqsub ' ']; @@ -461,7 +465,7 @@ , sub, name_job ,qsub_logs, opt.qsub_options ... , script , opt.singularity_image ,result_path, agent_id ); - psom_ppn = getenv("PSOM_WORKER_PPN") + psom_ppn = getenv('PSOM_WORKER_PPN') if psom_ppn file_conf = [result_path '/logs/PIPE_config.mat']; pipe_opt = load(file_conf); From 92724c1ad523ca443ee8a30e05ace7f8ad44fe3e Mon Sep 17 00:00:00 2001 From: fMeow Date: Sat, 31 Oct 2020 20:07:42 +0800 Subject: [PATCH 2/2] fix: wait 30 second before submitting jobs In some cases, jobs are submitted before workers are ready. --- psom_manager.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/psom_manager.m b/psom_manager.m index 45dcf42..56e612c 100644 --- a/psom_manager.m +++ b/psom_manager.m @@ -98,6 +98,9 @@ error('Could not find the pipeline file %s. Please use psom_run_pipeline instead of psom_manager directly.',file_jobs); end +% pause for ten second in case workers are not ready yet. +pause(30); + % a try/catch block is used to clean temporary file if the user is % interrupting the pipeline of if an error occurs try