From 439e7d54062b93397bc0d06e516e52f9d2f1f9b1 Mon Sep 17 00:00:00 2001 From: bud42 Date: Fri, 26 Oct 2018 14:36:37 -0400 Subject: [PATCH 1/7] Add support for setting dax_version_hash --- .DS_Store | Bin 14340 -> 14340 bytes dax/dax_tools_utils.py | 25 ++++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.DS_Store b/.DS_Store index ffbb913d599d8bdfe6e8a5e1868b9e33bf5761d0..4e084a62a646978ed272cdca1d17e52db2479826 100644 GIT binary patch delta 1030 zcma)*OH30{6o$`FE8dASItZ0gD6dM3sDKI)(Ex>NRYZ-VVthdBj9P@YwpBqQjRuVo zQR5`OjWHTyd`05}<0E0=!so&S7skYm8aFI7fsHZ7+YUiPTsVu#ob#P~?w#+Og0@i7i!1kGOgO2lQO|<&9zT0E-kNg^~*^UlSPx5s$H03){dH` zsG(A*_j_8^IFT$;29s^9VTaeZeTOg7uGeQtIf8tjtyeq|wJxCeHv3dXug{Y57+V+1 z*MwAl*VAIYR3OM6Rv-55)*Fk{#Ueot3-#N4{^6xF#S$hfQDIe!$E&vJ?PiN}m|QEY z*{O!YzJOm(&J!zG5~c|an*yz^sy`Ce(@v>|$i=^rH)CsK#HlE% zVx!^9R+X!`U8H;TfO_d6J)<}Djy}*A`bOVr zkcQ|73@{=QV<96A7G%JR0?a}QO5wy})S?bcu@dXC0gY&a3O@qaju6_g7yHnK{pi67 z z1zJ|RRU1g2YqVyHlGc%KkEU7DGjeT`B*#Rt{#ZE9A&GpHLOhu2;4ER76cuw~;8W9C zNvSBwV`N3p*Uc#xMcK$FsMCr{P80d4bXw!$l#=+jB>d$%I$HLBxqe0c^oe`^32?h2 zQn=q-3eU6vxkBhrGwVdfVx=RXT>z(M{X2j@nu+sx2ZdYKu(!raY#dGEXoWA95KCeS(nKr?lGX-gEBnf3`PmZ@Q2n zkZQPuyC18p(dz<@Rr&^>@i{ZkI4nHI-W;1T#AZROM`ZYWh%DPQjSMDW#nv zA<>#-W6aRAvchpwR5cnIkj8mUbFIF*Sr4@cr=moo_Q9Mj(YztwtbnH1>po3fQp|kk zV9pmul#(?*xofct!!tRn4$5|fH%(>ysPD+aWWSZ<_VWf{@O^bA4BqXMU zRRK~com}LhN~)%M3eXnXLr1BDuF^HSPWP#kUQ;)HqObIget-bHOA555==5@*Gi%`7Wt+5dFU{)cV>l*@EX{|p{D Date: Sun, 28 Oct 2018 12:33:18 -0400 Subject: [PATCH 2/7] Update singularity job template --- dax/processors.py | 2 +- dax/templates/SLURM/singularity_job_template.txt | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dax/processors.py b/dax/processors.py index 27b89abc..30df888e 100644 --- a/dax/processors.py +++ b/dax/processors.py @@ -1007,7 +1007,7 @@ def build_text(self, var2val, input_list, jobdir, dstdir): cmd += 'INDIR=$JOBDIR/INPUTS\n' cmd += 'OUTDIR=$JOBDIR/OUTPUTS\n' cmd += 'DSTDIR={}\n\n'.format(dstdir) - + cmd += 'CONTAINERPATH={}\n\n'.format(self.container_path) # Append the main command cmd += 'MAINCMD=\"' cmd += self.command.format(**var2val) diff --git a/dax/templates/SLURM/singularity_job_template.txt b/dax/templates/SLURM/singularity_job_template.txt index 6ec58b29..95018e3a 100644 --- a/dax/templates/SLURM/singularity_job_template.txt +++ b/dax/templates/SLURM/singularity_job_template.txt @@ -22,12 +22,14 @@ date #DSTDIR= #INLIST= #OUTLIST= +#CONTAINERPATH= #MAINCMD= ${job_cmds} #============================================================================= echo $DSTDIR echo $INDIR echo $OUTDIR +echo $CONTAINERPATH mkdir -p $INDIR mkdir -p $OUTDIR @@ -40,21 +42,21 @@ for IN in "${INLIST[@]}"; do elif [ $col2 == "DIRJ" ]; then CMD="curl -s -n $col3?format=zip -o $INDIR/${col1}.zip && unzip -j $INDIR/${col1}.zip -d $INDIR/$col1" else - CMD="curl -s -n $col3?format=zip -o $INDIR/${col1}.zip && unzip $INDIR/${col1}.zip -d $INDIR/$col1" + CMD="curl -s -n '$col3?format=zip&structure=simplified' -o $INDIR/${col1}.zip && unzip $INDIR/${col1}.zip -d $INDIR/$col1 && mv $INDIR/$col1/*/out/* $INDIR/$col1" fi echo $CMD eval $CMD done # Run main command -module load GCC Singularity echo $_JAVA_OPTIONS echo $MAINCMD eval $MAINCMD -# Write version file +# Write version files mkdir -p $DSTDIR echo $VERSION > $DSTDIR/version.txt +sha256sum $CONTAINERPATH | awk '{print $1}' > $DSTDIR/dax_version_hash.txt # Handle outputs errors=0 @@ -84,4 +86,7 @@ done if [ $errors -gt 0 ] || [ $haspdf != 1 ]; then echo "JOB_FAILED" && touch $DSTDIR/JOB_FAILED.txt; else echo "COMPLETE" && touch $DSTDIR/READY_TO_UPLOAD.txt; fi +rm -rf $INDIR $OUTDIR + echo "DONE" + From f151201db6ad644f1bfdbacebfc70fa3828f8153 Mon Sep 17 00:00:00 2001 From: bud42 Date: Mon, 29 Oct 2018 12:04:50 -0400 Subject: [PATCH 3/7] Handle input assessor attributes --- dax/processors.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dax/processors.py b/dax/processors.py index 30df888e..77103704 100644 --- a/dax/processors.py +++ b/dax/processors.py @@ -937,7 +937,7 @@ def build_cmds(self, assr, jobdir): """ assr_label = assr.label() dstdir = os.path.join(DAX_Settings().get_results_dir(), assr_label) - + # Find values for the xnat inputs var2val, input_list = self.parser.find_inputs(assr) @@ -968,6 +968,10 @@ def build_cmds(self, assr, jobdir): _ref = attr_in['ref'] _refval = assr_inputs[_ref].rsplit('/', 1)[1] _val = assr.parent().scan(_refval).attrs.get(_attr) + elif _obj == 'assessor': + _ref = attr_in['ref'] + _refval = assr_inputs[_ref].rsplit('/', 1)[1] + _val = assr.parent().assessor(_refval).attrs.get(_attr) else: LOGGER.error('invalid YAML') err = 'YAML File:contains invalid attribute:{}' From 78653ac79d8abbae6d32ad8adc791a0fe9baedc8 Mon Sep 17 00:00:00 2001 From: bud42 Date: Mon, 29 Oct 2018 12:31:38 -0400 Subject: [PATCH 4/7] Fix bug with XnatSwitchProcessStatus --- bin/Xnat_tools/XnatSwitchProcessStatus | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/Xnat_tools/XnatSwitchProcessStatus b/bin/Xnat_tools/XnatSwitchProcessStatus index 1adc1933..14184fb4 100755 --- a/bin/Xnat_tools/XnatSwitchProcessStatus +++ b/bin/Xnat_tools/XnatSwitchProcessStatus @@ -450,11 +450,13 @@ def set_need_inputs_proctype(xnat, assessor, need_inputs, full_regex=False): else: set_proc_status(assessor_obj, task.NEED_INPUTS) - li_assessors = xnat.get_assessor_out_resources( + li_assessors = XnatUtils.list_assessor_out_resources( + xnat, a_linked_dict['project_id'], a_linked_dict['subject_id'], a_linked_dict['session_id'], a_linked_dict['label']) + for resource in li_assessors: delete_assr_resource(assessor_obj, resource['label']) From 7ca1bee3ef76c3c4869735865bf6b323180957f7 Mon Sep 17 00:00:00 2001 From: bud42 Date: Mon, 29 Oct 2018 12:36:02 -0400 Subject: [PATCH 5/7] Fix another bug in XnatSwitchProcessStatus --- bin/Xnat_tools/XnatSwitchProcessStatus | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/Xnat_tools/XnatSwitchProcessStatus b/bin/Xnat_tools/XnatSwitchProcessStatus index 14184fb4..b1fbeb65 100755 --- a/bin/Xnat_tools/XnatSwitchProcessStatus +++ b/bin/Xnat_tools/XnatSwitchProcessStatus @@ -569,7 +569,8 @@ def set_status_assessor(xnat, assessor, status, for resource in resources: delete_assr_resource(assessor_obj, resource) else: - resources = xnat.get_assessor_out_resources( + resources = XnatUtils.list_assessor_out_resources( + xnat, assessor['project_id'], assessor['subject_label'], assessor['session_label'], assessor['label']) for resource in resources: From 4c46697857d06e492ddd32459019d60f72acba81 Mon Sep 17 00:00:00 2001 From: bud42 Date: Mon, 29 Oct 2018 12:54:15 -0400 Subject: [PATCH 6/7] Set a default for fmatch when type is FILE --- dax/processor_parser.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dax/processor_parser.py b/dax/processor_parser.py index 1fff958c..aeaba004 100644 --- a/dax/processor_parser.py +++ b/dax/processor_parser.py @@ -275,7 +275,13 @@ def find_inputs(self, assr): if 'fmatch' in cur_res: fmatch = cur_res['fmatch'] + elif cur_res['ftype'] == 'FILE': + # Default to all + fmatch = '*' + else: + fmatch = None + if fmatch: # Get list of all files in the resource file_list = robj.files().get() From 2b8d3c35a003a8729b1c2640d6b0a21470d4b312 Mon Sep 17 00:00:00 2001 From: bud42 Date: Mon, 29 Oct 2018 14:49:06 -0400 Subject: [PATCH 7/7] Fix handling of missing dax_version_hash --- dax/dax_tools_utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dax/dax_tools_utils.py b/dax/dax_tools_utils.py index 3309e89b..d1261ef9 100644 --- a/dax/dax_tools_utils.py +++ b/dax/dax_tools_utils.py @@ -829,10 +829,9 @@ def get_dax_version_hash_assessor(assessor_path): try: with open(fpath, 'r') as f_obj: dax_version_hash = f_obj.read().strip() - f_obj.close() except IOError as e: - LOGGER.warn('failed to read dax_version_hash:' + fpath + ':' + e) + LOGGER.warn('failed to read dax_version_hash:' + str(e)) return dax_version_hash