From e32391633f3218cda02978ecbc5c1ba0dd7c91be Mon Sep 17 00:00:00 2001 From: Jorrit Schaap <schaap@astron.nl> Date: Mon, 6 Jul 2020 17:19:11 +0200 Subject: [PATCH] TMSS-189: stupid parset looses type info. So, return typed dicts for those who want it, return parsets for those who don't care about types --- SAS/TMSS/src/tmss/tmssapp/adapters/parset.py | 21 +++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/SAS/TMSS/src/tmss/tmssapp/adapters/parset.py b/SAS/TMSS/src/tmss/tmssapp/adapters/parset.py index 5ed5940cd2b..e1ace1d545a 100644 --- a/SAS/TMSS/src/tmss/tmssapp/adapters/parset.py +++ b/SAS/TMSS/src/tmss/tmssapp/adapters/parset.py @@ -24,7 +24,7 @@ from lofar.common.json_utils import add_defaults_to_json_object_for_schema from lofar.sas.tmss.tmss.exceptions import * from datetime import datetime -def _convert_to_parset_for_observationcontrol_schema(subtask: models.Subtask) -> parameterset: +def _convert_to_parset_dict_for_observationcontrol_schema(subtask: models.Subtask) -> dict: # make sure the spec is complete (including all non-filled in properties with default) spec = add_defaults_to_json_object_for_schema(subtask.specifications_doc, subtask.specifications_template.schema) @@ -43,6 +43,7 @@ def _convert_to_parset_for_observationcontrol_schema(subtask: models.Subtask) -> parset["Observation.ObsID"] = subtask.pk parset["Observation.momID"] = 0 # Needed by MACScheduler parset["Observation.otdbID"] = 0 # Needed by MACScheduler; should/can this be the same as subtask.pk? + parset["Observation.tmssID"] = subtask.pk parset["Observation.processType"] = subtask.specifications_template.type.value.capitalize() parset["Observation.processSubtype"] = "Beam Observation" # TODO: where to derive the processSubtype from? parset["Observation.Campaign.name"] = subtask.task_blueprint.scheduling_unit_blueprint.draft.scheduling_set.project.name @@ -133,13 +134,10 @@ def _convert_to_parset_for_observationcontrol_schema(subtask: models.Subtask) -> parset[prefix+"ObservationControl.StationControl.aartfaacPiggybackAllowed"] = False parset[prefix+"ObservationControl.StationControl.tbbPiggybackAllowed"] = False - - # convert dict to real parameterset, and return it - parset = parameterset(parset) return parset -def _convert_to_parset_for_pipelinecontrol_schema(subtask: models.Subtask) -> parameterset: +def _convert_to_parset_dict_for_pipelinecontrol_schema(subtask: models.Subtask) -> dict: # see https://support.astron.nl/confluence/pages/viewpage.action?spaceKey=TMSS&title=UC1+JSON # make sure the spec is complete (including all non-filled in properties with default) @@ -298,14 +296,12 @@ def _convert_to_parset_for_pipelinecontrol_schema(subtask: models.Subtask) -> pa parset["ObsSW.Observation.ObservationControl.PythonControl.DPPP.showtimings"] = "F" parset["ObsSW.Observation.ObservationControl.PythonControl.DPPP.uselogger"] = "T" - # convert dict to real parameterset, and return it - parset = parameterset(parset) return parset # dict to store conversion methods based on subtask.specifications_template.name -_convertors = {'observationcontrol schema': _convert_to_parset_for_observationcontrol_schema, - 'pipelinecontrol schema': _convert_to_parset_for_pipelinecontrol_schema } +_convertors = {'observationcontrol schema': _convert_to_parset_dict_for_observationcontrol_schema, + 'pipelinecontrol schema': _convert_to_parset_dict_for_pipelinecontrol_schema } def convert_to_parset(subtask: models.Subtask) -> parameterset: @@ -313,6 +309,13 @@ def convert_to_parset(subtask: models.Subtask) -> parameterset: Convert the specifications in the subtask to a LOFAR parset for MAC/COBALT :raises ConversionException if no proper conversion is available. ''' + return parameterset(convert_to_parset_dict(subtask)) + +def convert_to_parset_dict(subtask: models.Subtask) -> dict: + ''' + Convert the specifications in the subtask to a LOFAR parset dict with typed values for MAC/COBALT + :raises ConversionException if no proper conversion is available. + ''' try: convertor = _convertors[subtask.specifications_template.name] except KeyError: -- GitLab