Skip to content
Snippets Groups Projects
Commit 0300ffca authored by Adriaan Renting's avatar Adriaan Renting
Browse files

Task #10557: Get mom_id from parset instead of MoM DB

parent 2f123a40
No related branches found
No related tags found
No related merge requests found
......@@ -142,24 +142,27 @@ class TaskPrescheduler(OTDBBusListener):
""" #TODO might work for all tasks in the future
try:
otdb_id = treeId
mom_ids = self.momquery.getMoMIdsForOTDBIds([otdb_id])
if mom_ids:
mom_id = mom_ids[0]
#Race condition when asking MoM as the mom-otdb-adapter might not have heard that the
#task is on approved and might still be on approved pending in MoM.
#mom_ids = self.momquery.getMoMIdsForOTDBIds([otdb_id])
#So we get the parset for all tasks we receive instead of just for the ones with
#a trigger.
parset = self.otdbrpc.taskGetSpecification( otdb_id=otdb_id )['specification']
specification = resourceIndicatorsFromParset(parset)
if specification["Observation.momID"]:
mom_id = specification["Observation.momID"]
logger.info('Found mom_id %s for otdb_id %s', (mom_id, otdb_id))
else:
mom_id = None
if len(mom_ids) > 1:
logger.warning('Found multiple mom_ids %s', mom_ids)
if mom_id:
response = self.momquery.get_trigger_id(mom_id)
if response['status'] == 'OK':
logger.info('Found a task mom_id=%s with a trigger_id=%s', mom_id, response['trigger_id'])
#TODO, check for stations and other resources, start/endtime, target position, then update specification
parset = self.otdbrpc.taskGetSpecification( otdb_id=otdb_id )['specification']
specification = resourceIndicatorsFromParset(parset)
cobalt_values = calculateCobaltSettings(specification)
logger.info('prescheduling otdb_id=%s because it was generated by trigger_id=%s', otdb_id, response['trigger_id'])
logger.info('prescheduling otdb_id=%s because it was generated by trigger_id=%s', (otdb_id, response['trigger_id']))
otdb_info = {}
otdb_info[OUTPUT_PREFIX + "Cobalt.Correlator.nrBlocksPerIntegration"] = cobalt_values["nrBlocks"]
otdb_info[OUTPUT_PREFIX + "Cobalt.Correlator.nrIntegrationsPerBlock"] = cobalt_values["nrSubblocks"]
......@@ -167,9 +170,9 @@ class TaskPrescheduler(OTDBBusListener):
otdb_info[OUTPUT_PREFIX + "Cobalt.Correlator.integrationTime"] = cobalt_values["integrationTime"]
self.setOTDBinfo(otdb_id, otdb_info, 'prescheduled')
else:
logger.info('Did not find a trigger for task mom_id=%s, because %s', mom_id, response['errors'])
logger.info('Did not find a trigger for task mom_id=%s, because %s', (mom_id, response['errors']))
else:
logger.info('Did not find a mom_id for task otdb_id=%s', otdb_id)
logger.info('Did not find a mom_id for task otdb_id=%s', (otdb_id,))
except Exception as e:
logger.error(e)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment