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

TMSS-215: added _populate_scheduling_unit_observation_strategry_schema, and...

TMSS-215: added _populate_scheduling_unit_observation_strategry_schema, and adapted populate code for scheduling unit for new schema
parent 6981c145
No related branches found
No related tags found
1 merge request!197Resolve TMSS-215
...@@ -47,6 +47,8 @@ def populate_settings(apps, schema_editor): ...@@ -47,6 +47,8 @@ def populate_settings(apps, schema_editor):
def populate_lofar_json_schemas(apps, schema_editor): def populate_lofar_json_schemas(apps, schema_editor):
_populate_scheduling_unit_schema() _populate_scheduling_unit_schema()
_populate_scheduling_unit_observation_strategry_schema()
# populate task schema's # populate task schema's
_populate_preprocessing_schema() _populate_preprocessing_schema()
_populate_observation_with_stations_schema() _populate_observation_with_stations_schema()
...@@ -78,59 +80,59 @@ def populate_test_data(): ...@@ -78,59 +80,59 @@ def populate_test_data():
# create a Test Scheduling Set UC1 under project TMSS-Commissioning # 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")
for set_nr in range(3): for set_nr in range(1):
scheduling_set_data = SchedulingSet_test_data(name="Test Scheduling Set UC1 example %s" % (set_nr,), project=tmss_project) scheduling_set_data = SchedulingSet_test_data(name="Test Scheduling Set UC1 example %s" % (set_nr,), project=tmss_project)
scheduling_set = models.SchedulingSet.objects.create(**scheduling_set_data) scheduling_set = models.SchedulingSet.objects.create(**scheduling_set_data)
scheduling_set.tags = ["TEST"] scheduling_set.tags = ["TEST"]
scheduling_set.save() scheduling_set.save()
for unit_nr in range(3): for unit_nr in range(1):
# construct a scheduling_unit_doc, i.e.: a specification of interrelated tasks which conforms the scheduling unit schema # 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 # 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_template = models.SchedulingUnitTemplate.objects.get(name="scheduling unit schema")
scheduling_unit_doc = get_default_json_object_for_schema(scheduling_unit_template.schema) scheduling_unit_doc = get_default_json_object_for_schema(scheduling_unit_template.schema)
# create and add a calibrator task spec # create and add a calibrator task spec
scheduling_unit_doc['tasks'].append({"name": "Calibrator Observation 1", scheduling_unit_doc['tasks']["Calibrator Observation 1"] = {
"description": "Calibrator Observation for UC1 HBA scheduling unit", "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_doc": get_default_json_object_for_schema(models.TaskTemplate.objects.get(name="calibrator schema").schema),
"specifications_template": "calibrator schema"}) "specifications_template": "calibrator schema"}
# create and add a calibrator preprocessing spec # create and add a calibrator preprocessing spec
scheduling_unit_doc['tasks'].append({"name": "Pipeline Calibrator1", scheduling_unit_doc['tasks']["Pipeline Calibrator1"] = {
"description": "Preprocessing Pipeline for Calibrator Observation 1", "description": "Preprocessing Pipeline for Calibrator Observation 1",
"specifications_doc": get_default_json_object_for_schema(models.TaskTemplate.objects.get(name="preprocessing schema").schema), "specifications_doc": get_default_json_object_for_schema(models.TaskTemplate.objects.get(name="preprocessing schema").schema),
"specifications_template": "preprocessing schema"}) "specifications_template": "preprocessing schema"}
# create and add a target obs spec # create and add a target obs spec
scheduling_unit_doc['tasks'].append({"name": "Target Observation", scheduling_unit_doc['tasks']["Target Observation"] = {
"description": "Target Observation for UC1 HBA scheduling unit", "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_doc": get_default_json_object_for_schema(models.TaskTemplate.objects.get(name="observation schema").schema),
"specifications_template": "observation schema"}) "specifications_template": "observation schema"}
# create and add a target pipeline spec for sap0 # create and add a target pipeline spec for sap0
scheduling_unit_doc['tasks'].append({"name": "Preprocessing Pipeline SAP0", scheduling_unit_doc['tasks']["Preprocessing Pipeline SAP0"] = {
"description": "Preprocessing Pipeline for Target Observation 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_doc": get_default_json_object_for_schema(models.TaskTemplate.objects.get(name="preprocessing schema").schema),
"specifications_template": "preprocessing schema"}) "specifications_template": "preprocessing schema"}
# create and add a target pipeline spec for sap1 # create and add a target pipeline spec for sap1
scheduling_unit_doc['tasks'].append({"name": "Preprocessing Pipeline SAP1", scheduling_unit_doc['tasks']["Preprocessing Pipeline SAP1"] = {
"description": "Preprocessing Pipeline for Target Observation 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_doc": get_default_json_object_for_schema(models.TaskTemplate.objects.get(name="preprocessing schema").schema),
"specifications_template": "preprocessing schema"}) "specifications_template": "preprocessing schema"}
# create and add a calibrator task spec # create and add a calibrator task spec
scheduling_unit_doc['tasks'].append({"name": "Calibrator Observation 2", scheduling_unit_doc['tasks']["Calibrator Observation 2"] = {
"description": "Calibrator Observation for UC1 HBA scheduling unit", "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_doc": get_default_json_object_for_schema(models.TaskTemplate.objects.get(name="calibrator schema").schema),
"specifications_template": "calibrator schema"}) "specifications_template": "calibrator schema"}
# create and add a calibrator preprocessing spec # create and add a calibrator preprocessing spec
scheduling_unit_doc['tasks'].append({"name": "Pipeline Calibrator2", scheduling_unit_doc['tasks']["Pipeline Calibrator2"] = {
"description": "Preprocessing Pipeline for Calibrator Observation 2", "description": "Preprocessing Pipeline for Calibrator Observation 2",
"specifications_doc": get_default_json_object_for_schema(models.TaskTemplate.objects.get(name="preprocessing schema").schema), "specifications_doc": get_default_json_object_for_schema(models.TaskTemplate.objects.get(name="preprocessing schema").schema),
"specifications_template": "preprocessing schema"}) "specifications_template": "preprocessing schema"}
# ----- end of tasks # ----- end of tasks
...@@ -194,7 +196,7 @@ def populate_test_data(): ...@@ -194,7 +196,7 @@ def populate_test_data():
else: else:
create_task_blueprints_and_subtasks_from_scheduling_unit_draft(scheduling_unit_draft) create_task_blueprints_and_subtasks_from_scheduling_unit_draft(scheduling_unit_draft)
except TMSSException as e: except TMSSException as e:
logger.error(e) logger.exception(e)
except ImportError: except ImportError:
pass pass
...@@ -263,11 +265,22 @@ def _populate_scheduling_unit_schema(): ...@@ -263,11 +265,22 @@ def _populate_scheduling_unit_schema():
scheduling_unit_template_data = {"name": "scheduling unit schema", scheduling_unit_template_data = {"name": "scheduling unit schema",
"description": 'Schema for scheduling unit', "description": 'Schema for scheduling unit',
"version": '0.1', "version": '0.1',
"tags": ["UC1"], "tags": [],
"schema": json_data} "schema": json_data}
SchedulingUnitTemplate.objects.create(**scheduling_unit_template_data) SchedulingUnitTemplate.objects.create(**scheduling_unit_template_data)
def _populate_scheduling_unit_observation_strategry_schema():
with open(os.path.join(working_dir, "schemas/UC1-scheduling-unit-observation-strategy.json")) as json_file:
json_data = json.loads(json_file.read())
template_data = {"name": "UC1 observation strategy template",
"description": 'UC1 observation strategy template',
"version": '0.1',
"tags": ["UC1"],
"schema": json_data}
SchedulingUnitObservingStrategyTemplate.objects.create(**template_data)
def _populate_observation_with_stations_schema(): def _populate_observation_with_stations_schema():
with open(os.path.join(working_dir, "schemas/task-observation-with-stations.json")) as json_file: with open(os.path.join(working_dir, "schemas/task-observation-with-stations.json")) as json_file:
json_data = json.loads(json_file.read()) json_data = json.loads(json_file.read())
......
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