From 81beba2ad73cb09816af46f19b7a278a1a612c63 Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Wed, 24 Mar 2021 11:51:54 +0100
Subject: [PATCH] TMSS-690: Do not read settings from parent task when parsing
 subtask.

---
 SAS/TMSS/backend/src/tmss/tmssapp/adapters/sip.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/adapters/sip.py b/SAS/TMSS/backend/src/tmss/tmssapp/adapters/sip.py
index 76e057c9745..30a2d402976 100644
--- a/SAS/TMSS/backend/src/tmss/tmssapp/adapters/sip.py
+++ b/SAS/TMSS/backend/src/tmss/tmssapp/adapters/sip.py
@@ -2,6 +2,7 @@ from lofar.sas.tmss.tmss.exceptions import *
 from lofar.sas.tmss.tmss.tmssapp.models.scheduling import Dataproduct, SubtaskType, Subtask, SubtaskOutput, SIPidentifier, Algorithm
 from lofar.sas.tmss.tmss.tmssapp.models.specification import Datatype, Dataformat
 from lofar.lta.sip import siplib, ltasip, validator, constants
+from lofar.common.json_utils import add_defaults_to_json_object_for_schema
 
 import uuid
 import logging
@@ -182,13 +183,14 @@ def create_sip_representation_for_subtask(subtask: Subtask):
                 process_map=process_map)
 
         if subtask.specifications_template.name == "pipeline control":  #  todo: re-evaluate this because schema name might change
+            spec = add_defaults_to_json_object_for_schema(subtask.specifications_doc, subtask.specifications_template.schema)
             pipeline = siplib.AveragingPipeline(  # <-- this is what we need for UC1
                 pipeline_map,
                 numberofcorrelateddataproducts=get_number_of_dataproducts_of_type(subtask, Dataformat.Choices.MEASUREMENTSET.value),
-                frequencyintegrationstep=subtask.specifications_doc.get('demixer',{}).get('frequency_steps', 0),
-                timeintegrationstep=subtask.specifications_doc.get('demixer',{}).get('time_step', 0),
-                flagautocorrelations=subtask.task_blueprint.specifications_doc["flag"]["autocorrelations"],
-                demixing=True if 'demix' in subtask.task_blueprint.specifications_doc else False
+                frequencyintegrationstep=spec['demixer']['frequency_steps'] if spec['demixer']['enabled'] else 1,
+                timeintegrationstep=spec['demixer']['time_steps'] if spec['demixer']['enabled'] else 1,
+                flagautocorrelations=spec['preflagger1']['enabled'] and spec['preflagger1']['corrtype'] == 'auto',
+                demixing=spec['demixer']['enabled'] and (spec['demixer']['demix_always'] or spec['demixer']['demix_if_needed'])
             )
         # todo: distinguish and create other pipeline types. Probably most of these can be filled in over time as needed,
         #  but they are not required for UC1. Here are stubs to start from for the other types the LTA supports:
-- 
GitLab