From f803319373e76e8100fb530e0bd4a0440e686a83 Mon Sep 17 00:00:00 2001 From: bud42 Date: Tue, 3 Mar 2020 00:09:48 -0500 Subject: [PATCH 1/2] Fix list_project_assessors --- bin/Xnat_tools/XnatNDAR | 4 ++-- bin/Xnat_tools/Xnatdl | 4 ++-- bin/Xnat_tools/Xnatinfo | 2 +- bin/Xnat_tools/Xnatsessionupdate | 2 +- bin/supplemental_tools/Xnatreport_assessor.py | 2 +- bin/supplemental_tools/Xnatreport_assessors.py | 2 +- dax/launcher.py | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/Xnat_tools/XnatNDAR b/bin/Xnat_tools/XnatNDAR index 2cbd4ac5..ec48627f 100755 --- a/bin/Xnat_tools/XnatNDAR +++ b/bin/Xnat_tools/XnatNDAR @@ -554,7 +554,7 @@ def get_scan_xnat(options, xnat, directory, subjects): # list of scans and assessors for the full project scan_list = xnat.get_project_scans(options.project) - assessor_list = XnatUtils.list_project_assessors(xnat, options.project) + assessor_list = xnat.list_project_assessors(options.project) # filter to keep only the scan we need and keep the assessor that we need # for the qc Scans @@ -629,7 +629,7 @@ def get_processed_data_xnat(options, xnat, directory, subjects): scan_info, assessor_info = extract_info(proc_info) # list of scans and assessors for the full project - assessor_list = XnatUtils.list_project_assessors(xnat, options.project) + assessor_list = xnat.list_project_assessors(options.project) assessor_list = filter_list(subjects, 'subject_label', assessor_list) # From scan: diff --git a/bin/Xnat_tools/Xnatdl b/bin/Xnat_tools/Xnatdl index aba57378..a8416c0d 100755 --- a/bin/Xnat_tools/Xnatdl +++ b/bin/Xnat_tools/Xnatdl @@ -186,8 +186,8 @@ download_report.csv if you want to start from scratch.""" for project in projects_list: self.scans.extend(self.xnat.get_project_scans(project)) if XnatUtils.has_dax_datatypes(self.xnat): - self.assessors.extend(XnatUtils.list_project_assessors( - self.xnat, project)) + self.assessors.extend(self.xnat.list_project_assessors( + project)) # Filter using the options if they are set only if full project: self.filter(args) diff --git a/bin/Xnat_tools/Xnatinfo b/bin/Xnat_tools/Xnatinfo index ada80624..217987d9 100755 --- a/bin/Xnat_tools/Xnatinfo +++ b/bin/Xnat_tools/Xnatinfo @@ -176,7 +176,7 @@ def report_project(xnat, project, ignore_scans, ignore_unusable, running, scans_found[scan_dict['type']] = 1 # assessor loop - assessors_list = XnatUtils.list_project_assessors(xnat, project) + assessors_list = xnat.list_project_assessors(project) assessor_number = len(assessors_list) for assessor_dict in assessors_list: # add to dictionary of process diff --git a/bin/Xnat_tools/Xnatsessionupdate b/bin/Xnat_tools/Xnatsessionupdate index 4ef379f2..41f10691 100755 --- a/bin/Xnat_tools/Xnatsessionupdate +++ b/bin/Xnat_tools/Xnatsessionupdate @@ -157,7 +157,7 @@ def get_xnat_subject_need_inputs(xnat, project): :param project: project ID on XNAT :return: unique list of sessions labels on XNAT """ - assessors_list = XnatUtils.list_project_assessors(xnat, project) + assessors_list = xnat.list_project_assessors(project) assessors_list = [x for x in assessors_list if x['procstatus'] == 'NEED_INPUTS'] return list(set([x['session_label'] for x in assessors_list])) diff --git a/bin/supplemental_tools/Xnatreport_assessor.py b/bin/supplemental_tools/Xnatreport_assessor.py index 71ca63b5..5ea968ac 100755 --- a/bin/supplemental_tools/Xnatreport_assessor.py +++ b/bin/supplemental_tools/Xnatreport_assessor.py @@ -19,7 +19,7 @@ xnat = XnatUtils.get_interface() -Assrs = XnatUtils.list_project_assessors(xnat, project) +Assrs = xnat.list_project_assessors(project) R = list() for assr in Assrs : diff --git a/bin/supplemental_tools/Xnatreport_assessors.py b/bin/supplemental_tools/Xnatreport_assessors.py index 77051390..d60b3678 100755 --- a/bin/supplemental_tools/Xnatreport_assessors.py +++ b/bin/supplemental_tools/Xnatreport_assessors.py @@ -17,7 +17,7 @@ xnat = XnatUtils.get_interface() -Assrs = XnatUtils.list_project_assessors(xnat, args.project) +Assrs = xnat.list_project_assessors(args.project) xnat.disconnect() timestamp = time.strftime("%Y%m%d%H%M%S") diff --git a/dax/launcher.py b/dax/launcher.py index da063a87..69297ef7 100644 --- a/dax/launcher.py +++ b/dax/launcher.py @@ -980,7 +980,7 @@ def get_assessors_list(xnat, project_id, slocal): :return: list of assessors for a project """ # Get lists of assessors for this project - assr_list = XnatUtils.list_project_assessors(xnat, project_id) + assr_list = xnat.list_project_assessors(project_id) # filter the assessors to the sessions given as parameters if given if slocal and slocal.lower() != 'all': From c33f0b5e4d11170bbf0977ebf8f68db693cf6dd4 Mon Sep 17 00:00:00 2001 From: bud42 Date: Tue, 3 Mar 2020 00:27:44 -0500 Subject: [PATCH 2/2] Handle empty args --- dax/dax_manager.py | 5 +++-- dax/task.py | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dax/dax_manager.py b/dax/dax_manager.py index 91c76b7f..762acb03 100644 --- a/dax/dax_manager.py +++ b/dax/dax_manager.py @@ -265,8 +265,9 @@ def load_module_record(self, module, project): dax_rec['filepath'] = rc_rec[file_key] # Parse arguments - if rc_rec[key_prefix + '_args']: - rlist = rc_rec[key_prefix + '_args'].strip().split('\r\n') + args_key = key_prefix + '_args' + if rc_rec[args_key] and len(rc_rec[args_key]) > 0: + rlist = rc_rec[args_key].strip().split('\r\n') rdict = {} for arg in rlist: key, val = arg.split(':', 1) diff --git a/dax/task.py b/dax/task.py index d2bbc028..cd5576a8 100644 --- a/dax/task.py +++ b/dax/task.py @@ -1348,9 +1348,10 @@ def complete_task(self): # Move output file src = self.outlog_path() dst = self.upload_outlog_dir() - mkdirp(dst) - LOGGER.debug('moving outlog file from %s to %s' % (src, dst)) - shutil.move(src, dst) + if os.path.exists(src): + mkdirp(dst) + LOGGER.debug('moving outlog file from %s to %s' % (src, dst)) + shutil.move(src, dst) # Touch file for dax_upload to check create_flag(os.path.join(RESULTS_DIR, self.assessor_label,