Skip to content
Snippets Groups Projects
Commit 127d56a1 authored by Ruud Beukema's avatar Ruud Beukema
Browse files

Task #10560: After discussion with Alexander removed checking on existence...

Task #10560: After discussion with Alexander removed checking on existence output_files, and added some docstrings
parent 6f6d342d
Branches
Tags
No related merge requests found
...@@ -297,8 +297,7 @@ class ResourceAssigner(): ...@@ -297,8 +297,7 @@ class ResourceAssigner():
self._sendStateChange(task, errStatus) self._sendStateChange(task, errStatus)
return return
self.applyMaxFillRatios(db_resource_list, db_rgp2rgp, db_resource_types, self.applyMaxFillRatios(db_resource_list, db_rgp2rgp, db_resource_types, db_resource_max_fill_ratios)
db_resource_max_fill_ratios)
# Assume estimates are (close enough to) accurate to determine resource claims for this task. # 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. # Try to get a set of non-conflicting claims from availability info in the RA DB.
...@@ -306,8 +305,8 @@ class ResourceAssigner(): ...@@ -306,8 +305,8 @@ class ResourceAssigner():
# Also, inserted claims are still automatically validated, there can be a race. # 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 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. # 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, claims = self.getClaimsForTask(task, estimates, db_resource_list, db_rgp2rgp, db_resource_types,
db_resource_types, db_resource_prop_types) db_resource_prop_types)
if claims is None: if claims is None:
self._sendStateChange(task, 'error') self._sendStateChange(task, 'error')
return return
...@@ -474,8 +473,17 @@ class ResourceAssigner(): ...@@ -474,8 +473,17 @@ class ResourceAssigner():
def getClaimsForTask(self, task, needed_resources_list, db_resource_list, def getClaimsForTask(self, task, needed_resources_list, db_resource_list,
db_rgp2rgp, db_resource_types, db_resource_prop_types): db_rgp2rgp, db_resource_types, db_resource_prop_types):
""" Return claims that satisfy needed_resources_list within db_resource_list, or an empty """ Return claims that satisfy needed_resources_list within db_resource_list, or an empty claim list if no
claim list if no non-conflicting claims could be found, or None on error. 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! # This function selects resources for a task (i.e. obs or pipeline). Keep it side-effect free!
# Criteria: # Criteria:
...@@ -525,9 +533,6 @@ class ResourceAssigner(): ...@@ -525,9 +533,6 @@ class ResourceAssigner():
input_files = needed_resources.get('input_files') input_files = needed_resources.get('input_files')
output_files = needed_resources.get('output_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 = self.getProperties(db_resource_prop_types, input_files, 'input')
properties.extend(self.getProperties(db_resource_prop_types, output_files, 'output')) properties.extend(self.getProperties(db_resource_prop_types, output_files, 'output'))
...@@ -586,8 +591,7 @@ class ResourceAssigner(): ...@@ -586,8 +591,7 @@ class ResourceAssigner():
return None return None
def getSubtreeResourcesList(self, root_gid, needed_resources_by_type_id, def getSubtreeResourcesList(self, root_gid, needed_resources_by_type_id, db_resource_list, db_rgp2rgp):
db_resource_list, db_rgp2rgp):
""" Returns list of available resources of type id in needed_resources_by_type_id.keys() """ 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>}, ...}, ...]. starting at group id root_gid in the format [{type_id: {<resource_dict>}, ...}, ...].
""" """
...@@ -604,7 +608,7 @@ class ResourceAssigner(): ...@@ -604,7 +608,7 @@ class ResourceAssigner():
for rid in res_group['resource_ids']: for rid in res_group['resource_ids']:
type_id = db_resource_list[rid]['type_id'] type_id = db_resource_list[rid]['type_id']
if type_id in needed_resources_by_type_id and db_resource_list[rid]['active'] and \ 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] resources[type_id] = db_resource_list[rid]
type_ids_seen.add(type_id) type_ids_seen.add(type_id)
...@@ -670,8 +674,7 @@ class ResourceAssigner(): ...@@ -670,8 +674,7 @@ class ResourceAssigner():
sap_dict['sap_nr'], io_type) sap_dict['sap_nr'], io_type)
properties.extend(props) properties.extend(props)
else: else:
props = self.makeProperties(db_resource_prop_types, needed_prop_group, props = self.makeProperties(db_resource_prop_types, needed_prop_group, None, io_type)
None, io_type)
properties.extend(props) properties.extend(props)
return properties return properties
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment