Skip to content
Snippets Groups Projects
Commit 6788e0b6 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-189: create UC1 SchedulingUnit with a whole task grapsh specified in json...

TMSS-189: create UC1 SchedulingUnit with a whole task grapsh specified in json conform the scheduling-unit-schema (based on Roy's example data in the t_tasks test)
parent 3d8ea80d
No related branches found
No related tags found
1 merge request!182Resolve TMSS-189 (and TMSS-192)
...@@ -69,12 +69,116 @@ def populate_test_scheduling_set(apps, schema_editor): ...@@ -69,12 +69,116 @@ def populate_test_scheduling_set(apps, schema_editor):
:return: :return:
""" """
try: try:
from lofar.sas.tmss.test.tmss_test_data_django_models import SchedulingSet_test_data from lofar.sas.tmss.test.tmss_test_data_django_models import SchedulingSet_test_data, SchedulingUnitDraft_test_data
if isTestEnvironment() or isDevelopmentEnvironment(): if isTestEnvironment() or isDevelopmentEnvironment():
# create a Test Scheduling Set UC1 under project TMSS-Commissioning
tmss_project = models.Project.objects.get(name="TMSS-Commissioning") tmss_project = models.Project.objects.get(name="TMSS-Commissioning")
scheduling_set_data = SchedulingSet_test_data(name="Test Scheduling Set UC1", project=tmss_project) scheduling_set_data = SchedulingSet_test_data(name="Test Scheduling Set UC1", project=tmss_project)
models.SchedulingSet.objects.create(**scheduling_set_data) scheduling_set = models.SchedulingSet.objects.create(**scheduling_set_data)
# construct a scheduling_unit_doc, i.e.: a specification of interrelated tasks which conforms the scheduling unit schema
# by default, this scheduling_unit_doc holds no tasks, so lets setup the UC1 sequence of tasks here, and add it to the scheduling_unit_doc
scheduling_unit_template = models.SchedulingUnitTemplate.objects.get(name="scheduling unit schema")
scheduling_unit_doc = get_default_json_object_for_schema(scheduling_unit_template.schema)
# create and add a calibrator task spec
scheduling_unit_doc['tasks'].append({"name": "Calibrator Observation 1",
"description": "Calibrator Observation for UC1 HBA scheduling unit",
"specifications_doc": get_default_json_object_for_schema(models.TaskTemplate.objects.get(name="calibrator schema").schema),
"specifications_template": "calibrator schema"})
# create and add a calibrator preprocessing spec
scheduling_unit_doc['tasks'].append({"name": "Pipeline Calibrator1",
"description": "Preprocessing Pipeline for Calibrator Observation 1",
"specifications_doc": get_default_json_object_for_schema(models.TaskTemplate.objects.get(name="preprocessing schema").schema),
"specifications_template": "preprocessing schema"})
# create and add a target obs spec
scheduling_unit_doc['tasks'].append({"name": "Target Observation",
"description": "Target Observation for UC1 HBA scheduling unit",
"specifications_doc": get_default_json_object_for_schema(models.TaskTemplate.objects.get(name="observation schema").schema),
"specifications_template": "observation schema"})
# create and add a target pipeline spec for sap0
scheduling_unit_doc['tasks'].append({"name": "Preprocessing Pipeline SAP0",
"description": "Preprocessing Pipeline for Target Observation SAP0",
"specifications_doc": get_default_json_object_for_schema(models.TaskTemplate.objects.get(name="preprocessing schema").schema),
"specifications_template": "preprocessing schema"})
# create and add a target pipeline spec for sap1
scheduling_unit_doc['tasks'].append({"name": "Preprocessing Pipeline SAP1",
"description": "Preprocessing Pipeline for Target Observation SAP1",
"specifications_doc": get_default_json_object_for_schema(models.TaskTemplate.objects.get(name="preprocessing schema").schema),
"specifications_template": "preprocessing schema"})
# create and add a calibrator task spec
scheduling_unit_doc['tasks'].append({"name": "Calibrator Observation 2",
"description": "Calibrator Observation for UC1 HBA scheduling unit",
"specifications_doc": get_default_json_object_for_schema(models.TaskTemplate.objects.get(name="calibrator schema").schema),
"specifications_template": "calibrator schema"})
# create and add a calibrator preprocessing spec
scheduling_unit_doc['tasks'].append({"name": "Pipeline Calibrator2",
"description": "Preprocessing Pipeline for Calibrator Observation 2",
"specifications_doc": get_default_json_object_for_schema(models.TaskTemplate.objects.get(name="preprocessing schema").schema),
"specifications_template": "preprocessing schema"})
# ----- end of tasks
# setup task_scheduling_relations between Target and Calibrator observations
scheduling_unit_doc['task_scheduling_relations'].append({"first": "Calibrator Observation 1",
"second": "Target Observation",
"placement": "before",
"time_offset": 60 })
scheduling_unit_doc['task_scheduling_relations'].append({"first": "Calibrator Observation 2",
"second": "Target Observation",
"placement": "after",
"time_offset": 60 })
# ----- end of task_scheduling_relations
#TODO: check various input/output datatypes and roles for each task_relation
scheduling_unit_doc['task_relations'].append({"producer": "Calibrator Observation 1",
"consumer": "Pipeline Calibrator1",
"tags": [],
"input": { "role": "input", "datatype": "visibilities" },
"output": { "role": "correlator", "datatype": "visibilities" },
"dataformat": "MeasurementSet",
"selection_doc": {},
"selection_template": "All" })
scheduling_unit_doc['task_relations'].append({"producer": "Calibrator Observation 2",
"consumer": "Pipeline Calibrator2",
"tags": [],
"input": { "role": "input", "datatype": "visibilities" },
"output": { "role": "correlator", "datatype": "visibilities" },
"dataformat": "MeasurementSet",
"selection_doc": {},
"selection_template": "All" })
scheduling_unit_doc['task_relations'].append({"producer": "Target Observation",
"consumer": "Preprocessing Pipeline SAP0",
"tags": [],
"input": { "role": "input", "datatype": "visibilities" },
"output": { "role": "correlator", "datatype": "visibilities" },
"dataformat": "MeasurementSet",
"selection_doc": {"sap": [0]},
"selection_template": "SAP" })
scheduling_unit_doc['task_relations'].append({"producer": "Target Observation",
"consumer": "Preprocessing Pipeline SAP1",
"tags": [],
"input": { "role": "input", "datatype": "visibilities" },
"output": { "role": "correlator", "datatype": "visibilities" },
"dataformat": "MeasurementSet",
"selection_doc": {"sap": [1]},
"selection_template": "SAP" })
# finally... add the scheduling_unit_doc to a new SchedulingUnitDraft instance, and were ready to use it!
scheduling_unit_data = SchedulingUnitDraft_test_data(name="Test Scheduling Unit UC1", scheduling_set=scheduling_set,
template=scheduling_unit_template, requirements_doc=scheduling_unit_doc)
models.SchedulingUnitDraft.objects.create(**scheduling_unit_data)
except ImportError: except ImportError:
pass pass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment