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

TMSS-215: adaptations to handle new schemas

parent b23d14b0
No related branches found
No related tags found
1 merge request!197Resolve TMSS-215
...@@ -678,15 +678,16 @@ def schedule_observation_subtask(observation_subtask: Subtask): ...@@ -678,15 +678,16 @@ def schedule_observation_subtask(observation_subtask: Subtask):
directory = "/data/%s/%s/L%s/uv" % ("projects" if isProductionEnvironment() else "test-projects", directory = "/data/%s/%s/L%s/uv" % ("projects" if isProductionEnvironment() else "test-projects",
observation_subtask.task_blueprint.scheduling_unit_blueprint.draft.scheduling_set.project.name, observation_subtask.task_blueprint.scheduling_unit_blueprint.draft.scheduling_set.project.name,
observation_subtask.id) observation_subtask.id)
for sb_nr in specifications_doc['stations']['digital_pointings'][0]['subbands']: for sap_nr, pointing in enumerate(specifications_doc['stations']['digital_pointings']):
Dataproduct.objects.create(filename="L%d_SB%03d_uv.MS" % (observation_subtask.id, sb_nr), for sb_nr in pointing['subbands']:
directory=directory, Dataproduct.objects.create(filename="L%d_SAP%03d_SB%03d_uv.MS" % (observation_subtask.id, sap_nr, sb_nr),
dataformat=Dataformat.objects.get(value="MeasurementSet"), directory=directory,
producer=subtask_output, dataformat=Dataformat.objects.get(value="MeasurementSet"),
specifications_doc={"sap": [0]}, # todo: set correct value. This will be provided by the RA somehow producer=subtask_output,
specifications_template=dataproduct_specifications_template, specifications_doc={"sap": [sap_nr]}, # todo: set correct value. This will be provided by the RA somehow
feedback_doc="", specifications_template=dataproduct_specifications_template,
feedback_template=dataproduct_feedback_template) feedback_doc="",
feedback_template=dataproduct_feedback_template)
# step 4: resource assigner (if possible) # step 4: resource assigner (if possible)
_assign_resources(observation_subtask) _assign_resources(observation_subtask)
......
...@@ -6,6 +6,7 @@ from lofar.sas.tmss.tmss.tmssapp.models.specification import TaskBlueprint, Sche ...@@ -6,6 +6,7 @@ from lofar.sas.tmss.tmss.tmssapp.models.specification import TaskBlueprint, Sche
from lofar.sas.tmss.tmss.tmssapp.subtasks import create_and_schedule_subtasks_from_task_blueprint, \ from lofar.sas.tmss.tmss.tmssapp.subtasks import create_and_schedule_subtasks_from_task_blueprint, \
create_subtasks_from_task_blueprint, schedule_independent_subtasks_in_task_blueprint create_subtasks_from_task_blueprint, schedule_independent_subtasks_in_task_blueprint
from functools import cmp_to_key from functools import cmp_to_key
from lofar.common.json_utils import add_defaults_to_json_object_for_schema
import logging import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -38,20 +39,20 @@ def create_task_drafts_from_scheduling_unit_draft(scheduling_unit_draft: models. ...@@ -38,20 +39,20 @@ def create_task_drafts_from_scheduling_unit_draft(scheduling_unit_draft: models.
""" """
logger.debug("create_task_drafts_from_scheduling_unit_draft(scheduling_unit_draft.id=%s, name='%s') ...", scheduling_unit_draft.pk, scheduling_unit_draft.name) logger.debug("create_task_drafts_from_scheduling_unit_draft(scheduling_unit_draft.id=%s, name='%s') ...", scheduling_unit_draft.pk, scheduling_unit_draft.name)
if len(scheduling_unit_draft.requirements_doc.get("tasks",[])) == 0: if len(scheduling_unit_draft.requirements_doc.get("tasks", {})) == 0:
raise BlueprintCreationException("create_task_drafts_from_scheduling_unit_draft: scheduling_unit_draft.id=%s has no tasks defined in its requirements_doc" % (scheduling_unit_draft.pk,)) raise BlueprintCreationException("create_task_drafts_from_scheduling_unit_draft: scheduling_unit_draft.id=%s has no tasks defined in its requirements_doc" % (scheduling_unit_draft.pk,))
for task_definition in scheduling_unit_draft.requirements_doc["tasks"]: for task_name, task_definition in scheduling_unit_draft.requirements_doc["tasks"].items():
task_template_name = task_definition["specifications_template"] task_template_name = task_definition["specifications_template"]
task_template = models.TaskTemplate.objects.get(name=task_template_name) task_template = models.TaskTemplate.objects.get(name=task_template_name)
if scheduling_unit_draft.task_drafts.filter(name=task_definition["name"], specifications_template=task_template).count() > 0: if scheduling_unit_draft.task_drafts.filter(name=task_template_name, specifications_template=task_template).count() > 0:
logger.debug("skipping creation of task draft because it is already in the scheduling_unit... task_name='%s', task_template_name='%s'", task_definition["name"], task_template_name) logger.debug("skipping creation of task draft because it is already in the scheduling_unit... task_name='%s', task_template_name='%s'", task_template_name, task_template_name)
continue continue
logger.debug("creating task draft... task_name='%s', task_template_name='%s'", task_definition["name"], task_template_name) logger.debug("creating task draft... task_name='%s', task_template_name='%s'", task_template_name, task_template_name)
task_draft = models.TaskDraft.objects.create(name=task_definition["name"], task_draft = models.TaskDraft.objects.create(name=task_name,
description=task_definition.get("description",""), description=task_definition.get("description",""),
tags=task_definition.get("tags",[]), tags=task_definition.get("tags",[]),
specifications_doc=task_definition["specifications_doc"], specifications_doc=task_definition["specifications_doc"],
...@@ -60,7 +61,7 @@ def create_task_drafts_from_scheduling_unit_draft(scheduling_unit_draft: models. ...@@ -60,7 +61,7 @@ def create_task_drafts_from_scheduling_unit_draft(scheduling_unit_draft: models.
scheduling_unit_draft=scheduling_unit_draft, scheduling_unit_draft=scheduling_unit_draft,
specifications_template=task_template) specifications_template=task_template)
logger.info("created task draft id=%s task_name='%s', task_template_name='%s'", task_draft.pk, task_definition["name"], task_template_name) logger.info("created task draft id=%s task_name='%s', task_template_name='%s'", task_draft.pk, task_template_name, task_template_name)
# Now create task relations # Now create task relations
for task_relation_definition in scheduling_unit_draft.requirements_doc["task_relations"]: for task_relation_definition in scheduling_unit_draft.requirements_doc["task_relations"]:
......
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