diff --git a/SAS/ResourceAssignment/ResourceAssigner/lib/assignment.py b/SAS/ResourceAssignment/ResourceAssigner/lib/assignment.py index 1ff0fc38c141b5bb640e0edf4529ea92fa9c4173..33be1e1f40d4c1c29c104ae3c90939a9c263affa 100755 --- a/SAS/ResourceAssignment/ResourceAssigner/lib/assignment.py +++ b/SAS/ResourceAssignment/ResourceAssigner/lib/assignment.py @@ -297,8 +297,7 @@ class ResourceAssigner(): self._sendStateChange(task, errStatus) return - self.applyMaxFillRatios(db_resource_list, db_rgp2rgp, db_resource_types, - db_resource_max_fill_ratios) + self.applyMaxFillRatios(db_resource_list, db_rgp2rgp, db_resource_types, db_resource_max_fill_ratios) # Assume estimates are (close enough to) accurate to determine resource claims for this task. # Try to get a set of non-conflicting claims from availability info in the RA DB. @@ -306,8 +305,8 @@ class ResourceAssigner(): # Also, inserted claims are still automatically validated, there can be a race. # If not enough resources are available after all, claims are put to conflict status. # If any claim is in conflict state, then the task is put to conflict status as well. - claims = self.getClaimsForTask(task, estimates, db_resource_list, db_rgp2rgp, - db_resource_types, db_resource_prop_types) + claims = self.getClaimsForTask(task, estimates, db_resource_list, db_rgp2rgp, db_resource_types, + db_resource_prop_types) if claims is None: self._sendStateChange(task, 'error') return @@ -474,8 +473,17 @@ class ResourceAssigner(): def getClaimsForTask(self, task, needed_resources_list, db_resource_list, db_rgp2rgp, db_resource_types, db_resource_prop_types): - """ Return claims that satisfy needed_resources_list within db_resource_list, or an empty - claim list if no non-conflicting claims could be found, or None on error. + """ Return claims that satisfy needed_resources_list within db_resource_list, or an empty claim list if no + non-conflicting claims could be found, or None on error. + + :param task: an instance of an RADB task object + :param needed_resources_list: a list of resources to be claimed + :param db_resource_list: all resources in RADB with availability information + :param db_rgp2rgp: all group->group relations from RADB + :param db_resource_types: all virtual instrument resource types (and their units) from RADB + :param db_resource_prop_types: all resource claim property types from RADB + + :returns claims """ # This function selects resources for a task (i.e. obs or pipeline). Keep it side-effect free! # Criteria: @@ -525,9 +533,6 @@ class ResourceAssigner(): input_files = needed_resources.get('input_files') output_files = needed_resources.get('output_files') - if output_files is None: - logger.error('getClaimsForTask: cannot generate claims & properties for no output_files') - return None properties = self.getProperties(db_resource_prop_types, input_files, 'input') properties.extend(self.getProperties(db_resource_prop_types, output_files, 'output')) @@ -586,8 +591,7 @@ class ResourceAssigner(): return None - def getSubtreeResourcesList(self, root_gid, needed_resources_by_type_id, - db_resource_list, db_rgp2rgp): + def getSubtreeResourcesList(self, root_gid, needed_resources_by_type_id, db_resource_list, db_rgp2rgp): """ Returns list of available resources of type id in needed_resources_by_type_id.keys() starting at group id root_gid in the format [{type_id: {<resource_dict>}, ...}, ...]. """ @@ -604,7 +608,7 @@ class ResourceAssigner(): for rid in res_group['resource_ids']: type_id = db_resource_list[rid]['type_id'] if type_id in needed_resources_by_type_id and db_resource_list[rid]['active'] and \ - db_resource_list[rid]['available_capacity'] > 0: + db_resource_list[rid]['available_capacity'] > 0: # <-- capacity not available for e.g. rcus resources[type_id] = db_resource_list[rid] type_ids_seen.add(type_id) @@ -670,8 +674,7 @@ class ResourceAssigner(): sap_dict['sap_nr'], io_type) properties.extend(props) else: - props = self.makeProperties(db_resource_prop_types, needed_prop_group, - None, io_type) + props = self.makeProperties(db_resource_prop_types, needed_prop_group, None, io_type) properties.extend(props) return properties