diff --git a/dax/XnatUtils.py b/dax/XnatUtils.py index 2e84105b..e2491328 100644 --- a/dax/XnatUtils.py +++ b/dax/XnatUtils.py @@ -2619,7 +2619,7 @@ def get(self, name): def type(self): if self.proctype is None: - self.proctype = self.info()['proctype'] + self.proctype = self.info().get('proctype', None) return self.proctype def info(self): diff --git a/dax/processor_parser.py b/dax/processor_parser.py index c84910d8..101b6fa8 100644 --- a/dax/processor_parser.py +++ b/dax/processor_parser.py @@ -946,28 +946,37 @@ def compare_to_existing(csesses, proc_type, parameter_matrix): assessors = [[] for _ in range(len(parameter_matrix))] + existing_assessors = [] + + # Get of list assessors that have already been + # created on xnat for this processor/proctype for casr in csess.assessors(): + try: + proc_type_matches = (casr.type() == proc_type) + if proc_type_matches: + existing_assessors.append(casr) + except: + LOGGER.error(f'Failed to check type of {casr.label()}') + continue + + # Check for any missing inputs fields in the existing assessors + for casr in existing_assessors: # Check for empty inputs. If ANY of the assessors on this session # have an empty inputs, then we cannot determine which input sets # need to be built. We refuse to do anything by returning # an empty list. inputs = casr.get_inputs() if inputs is None: - LOGGER.warn('assessor with empty inputs field, cannot build processor for session' + casr.label()) + LOGGER.warn('assessor with empty inputs field, cannot build processor for session:' + casr.label()) return list() - try: - proc_type_matches = (casr.type() == proc_type) - except: - LOGGER.error(f'Failed to check type of {casr.label()}') - continue - - if proc_type_matches: - for pi, p in enumerate(parameter_matrix): - if inputs == p: - # BDB 6/5/21 do we ever have more than one assessor - # with the same set of inputs? - assessors[pi].append(casr) + # Compare existing to the "to build" assessors in parameter_matrix + for casr in existing_assessors: + for pi, p in enumerate(parameter_matrix): + if inputs == p: + # BDB 6/5/21 do we ever have more than one assessor + # with the same set of inputs? + assessors[pi].append(casr) return list(zip(copy.deepcopy(parameter_matrix), assessors)) diff --git a/dax/processors_v3.py b/dax/processors_v3.py index a389743a..f5a44a4b 100644 --- a/dax/processors_v3.py +++ b/dax/processors_v3.py @@ -1235,11 +1235,23 @@ def _generate_parameter_matrix(self, artefacts, artefacts_by_input): return final_matrix def _compare_to_existing(self, csess, parameter_matrix): - proc_type = self.proctype - assessors = [[] for _ in range(len(parameter_matrix))] + # Get of list assessors that have already been + # created on xnat for this processor/proctype + existing_assessors = [] for casr in csess.assessors(): + # Check that proc type matches this processor + try: + proc_type_matches = (casr.type() == self.proctype) + if proc_type_matches: + existing_assessors.append(casr) + except: + LOGGER.warning(f'Unable to check match of {casr.label()} - ignoring') + continue + + # Check for any missing inputs fields in the existing assessors + for casr in existing_assessors: # Check for empty inputs. If ANY of the assessors on this session # have an empty inputs, then we cannot determine which input sets # need to be built. We refuse to do anything by returning @@ -1249,18 +1261,13 @@ def _compare_to_existing(self, csess, parameter_matrix): LOGGER.warn('assessor with empty inputs field, cannot build processor for session' + casr.label()) return list() - try: - proc_type_matches = (casr.type() == proc_type) - except: - LOGGER.warning(f'Unable to check match of {casr.label()} - ignoring') - continue - - if proc_type_matches: - for pi, p in enumerate(parameter_matrix): - if inputs == p: - # BDB 6/5/21 do we ever have more than one assessor - # with the same set of inputs? - assessors[pi].append(casr) + # Compare existing to the "to build" assessors in parameter_matrix + for casr in existing_assessors: + for pi, p in enumerate(parameter_matrix): + if inputs == p: + # BDB 6/5/21 do we ever have more than one assessor + # with the same set of inputs? + assessors[pi].append(casr) return list(zip(copy.deepcopy(parameter_matrix), assessors))