diff --git a/SAS/TMSS/src/tmss/tmssapp/populate.py b/SAS/TMSS/src/tmss/tmssapp/populate.py index b90395259f27118a24479bbb146c2e4a6768fedb..c95fff73ae7fbf05eb91fa319e60084a6ddf3dec 100644 --- a/SAS/TMSS/src/tmss/tmssapp/populate.py +++ b/SAS/TMSS/src/tmss/tmssapp/populate.py @@ -18,9 +18,9 @@ import logging logger = logging.getLogger(__name__) import json -from lofar.sas.tmss.tmss.tmssapp.models.specification import Role, Datatype, Dataformat, CopyReason, TaskTemplate, ResourceType, ResourceUnit -from lofar.sas.tmss.tmss.tmssapp.models.scheduling import SubtaskState, SubtaskType, SubtaskTemplate, Subtask, \ - StationType, Algorithm, ScheduleMethod, Cluster, Filesystem, SubtaskInputSelectionTemplate +from lofar.sas.tmss.tmss.tmssapp.subtasks import * +from lofar.sas.tmss.tmss.tmssapp.models.specification import * +from lofar.sas.tmss.tmss.tmssapp.models.scheduling import * from lofar.common.json_utils import * from lofar.common import isTestEnvironment, isDevelopmentEnvironment @@ -186,11 +186,10 @@ def _populate_example_data(): from datetime import datetime from lofar.sas.tmss.tmss.tmssapp import models from lofar.sas.tmss.test.tmss_test_data_django_models import TaskDraft_test_data, TaskBlueprint_test_data, SubtaskOutput_test_data, Dataproduct_test_data, Subtask_test_data - from lofar.sas.tmss.tmss.tmssapp.subtasks import create_observation_to_qafile_subtask, create_qafile_to_qaplots_subtask, connect_observation_subtask_to_preprocessing_subtask cluster = Cluster.objects.get(name="CEP4") - for i in range(10 if isTestEnvironment() else 2 if isDevelopmentEnvironment() else 0): + for i in range(10 if isTestEnvironment() else 1 if isDevelopmentEnvironment() else 0): task_template = models.TaskTemplate.objects.get(name='correlator schema') task_draft_data = TaskDraft_test_data(name="my test obs", specifications_template=task_template) task_draft = models.TaskDraft.objects.create(**task_draft_data) @@ -220,6 +219,8 @@ def _populate_example_data(): subtask_data = Subtask_test_data(task_blueprint=task_blueprint, subtask_template=subtask_template, specifications_doc=specifications_doc, cluster=cluster) subtask = models.Subtask.objects.create(**subtask_data) + subtask.state = SubtaskState.objects.get(value=SubtaskState.Choices.DEFINED.value) + subtask.save() subtask_output = models.SubtaskOutput.objects.create(**SubtaskOutput_test_data(subtask=subtask)) for sb_nr in specifications_doc['stations']['digital_pointings'][0]['subbands']: @@ -237,9 +238,35 @@ def _populate_example_data(): connect_observation_subtask_to_preprocessing_subtask(subtask, pipe_subtask) try: - # automatically append an qafile and qaplots conversion subtask to it. + # automatically append an qafile conversion subtask to it. + # TODO: this call to create_observation_to_qafile_subtask should happen in the Task to Subtasks expansion qafile_subtask = create_observation_to_qafile_subtask(subtask) + + # TODO: this call to schedule_qafile_subtask should happen in a onSubTaskFinished method + # before we can mimic scheduling the qafile_subtask, the observation has to be finished... + # let's fake/force that here.... (HACK) + subtask.state = SubtaskState.objects.get(value=SubtaskState.Choices.FINISHED.value) + subtask.save() + # ...scheduling... + qafile_subtask = schedule_qafile_subtask(qafile_subtask) + # ... and put the obs back to defined (HACK) + subtask.state = SubtaskState.objects.get(value=SubtaskState.Choices.DEFINED.value) + subtask.save() + + # automatically append a qaplots conversion subtask to it. + # TODO: this call to create_observation_to_qafile_subtask should happen in the Task to Subtasks expansion qaplots_subtask = create_qafile_to_qaplots_subtask(qafile_subtask) + + # TODO: this call to schedule_qaplots_subtask should happen in a onSubTaskFinished method + # before we can mimic scheduling the qafile_subtask, the qafile_subtask has to be finished... + # let's fake/force that here.... (HACK) + qafile_subtask.state = SubtaskState.objects.get(value=SubtaskState.Choices.FINISHED.value) + qafile_subtask.save() + # ...scheduling... + schedule_qaplots_subtask(qaplots_subtask) + # ... and put the qafile_subtask back to defined (HACK) + qafile_subtask.state = SubtaskState.objects.get(value=SubtaskState.Choices.SCHEDULED.value) + qafile_subtask.save() except Exception as e: logger.exception(e) except ImportError: