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

TMSS-60: hacked the create and schedule qa file/plots subtasks into populate....

TMSS-60: hacked the create and schedule qa file/plots subtasks into populate. This is only a code placeholder for now. In TMSS-171 these create- (and schedule-??) methods will be called in the Task expansion
parent eb131650
No related branches found
No related tags found
1 merge request!154Resolve TMSS-60 and TMSS-171 and TMSS-198
...@@ -18,9 +18,9 @@ import logging ...@@ -18,9 +18,9 @@ import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
import json import json
from lofar.sas.tmss.tmss.tmssapp.models.specification import Role, Datatype, Dataformat, CopyReason, TaskTemplate, ResourceType, ResourceUnit from lofar.sas.tmss.tmss.tmssapp.subtasks import *
from lofar.sas.tmss.tmss.tmssapp.models.scheduling import SubtaskState, SubtaskType, SubtaskTemplate, Subtask, \ from lofar.sas.tmss.tmss.tmssapp.models.specification import *
StationType, Algorithm, ScheduleMethod, Cluster, Filesystem, SubtaskInputSelectionTemplate from lofar.sas.tmss.tmss.tmssapp.models.scheduling import *
from lofar.common.json_utils import * from lofar.common.json_utils import *
from lofar.common import isTestEnvironment, isDevelopmentEnvironment from lofar.common import isTestEnvironment, isDevelopmentEnvironment
...@@ -186,11 +186,10 @@ def _populate_example_data(): ...@@ -186,11 +186,10 @@ def _populate_example_data():
from datetime import datetime from datetime import datetime
from lofar.sas.tmss.tmss.tmssapp import models 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.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") 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_template = models.TaskTemplate.objects.get(name='correlator schema')
task_draft_data = TaskDraft_test_data(name="my test obs", specifications_template=task_template) task_draft_data = TaskDraft_test_data(name="my test obs", specifications_template=task_template)
task_draft = models.TaskDraft.objects.create(**task_draft_data) task_draft = models.TaskDraft.objects.create(**task_draft_data)
...@@ -220,6 +219,8 @@ def _populate_example_data(): ...@@ -220,6 +219,8 @@ def _populate_example_data():
subtask_data = Subtask_test_data(task_blueprint=task_blueprint, subtask_template=subtask_template, subtask_data = Subtask_test_data(task_blueprint=task_blueprint, subtask_template=subtask_template,
specifications_doc=specifications_doc, cluster=cluster) specifications_doc=specifications_doc, cluster=cluster)
subtask = models.Subtask.objects.create(**subtask_data) 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)) subtask_output = models.SubtaskOutput.objects.create(**SubtaskOutput_test_data(subtask=subtask))
for sb_nr in specifications_doc['stations']['digital_pointings'][0]['subbands']: for sb_nr in specifications_doc['stations']['digital_pointings'][0]['subbands']:
...@@ -237,9 +238,35 @@ def _populate_example_data(): ...@@ -237,9 +238,35 @@ def _populate_example_data():
connect_observation_subtask_to_preprocessing_subtask(subtask, pipe_subtask) connect_observation_subtask_to_preprocessing_subtask(subtask, pipe_subtask)
try: 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) 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) 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: except Exception as e:
logger.exception(e) logger.exception(e)
except ImportError: except ImportError:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment