diff --git a/SAS/TMSS/src/tmss/tmssapp/subtasks.py b/SAS/TMSS/src/tmss/tmssapp/subtasks.py index 192b5e0e1c69b05cf3a2de3dfb50db408ac664ba..d2913bf0ffd4478427fdc19f4e46eee6e25a691b 100644 --- a/SAS/TMSS/src/tmss/tmssapp/subtasks.py +++ b/SAS/TMSS/src/tmss/tmssapp/subtasks.py @@ -335,14 +335,16 @@ def schedule_qafile_subtask(qafile_subtask: Subtask): raise SubtaskSchedulingException("Cannot schedule subtask id=%d type=%s but type should be %s" % (qafile_subtask.pk, qafile_subtask.specifications_template.type, SubtaskType.Choices.QA_FILES.value)) + if len(qafile_subtask.inputs.all()) != 1: + raise SubtaskSchedulingException("QA subtask id=%s should have 1 input, but it has %s" % (qafile_subtask.id, len(qafile_subtask.inputs))) # step 1: set state to SCHEDULING qafile_subtask.state = SubtaskState.objects.get(value=SubtaskState.Choices.SCHEDULING.value) qafile_subtask.save() # step 2: link input dataproducts - for input in qafile_subtask.inputs.all(): - input.dataproducts.set(input.producer.dataproducts.all()) + qa_input = qafile_subtask.inputs.first() + qa_input.dataproducts.set(qa_input.producer.dataproducts.all()) # step 3: resource assigner # is a no-op for QA @@ -350,7 +352,7 @@ def schedule_qafile_subtask(qafile_subtask: Subtask): # step 4: create output dataproducts, and link these to the output # TODO: Should the output and/or dataproduct be determined by the specification in task_relation_blueprint? if qafile_subtask.outputs.first(): - qafile_subtask_dataproduct = Dataproduct.objects.create(filename="L%d_QA.h5" % (qafile_subtask.id,), + qafile_subtask_dataproduct = Dataproduct.objects.create(filename="L%s_%s_QA.h5" % (qa_input.producer.subtask_id, qafile_subtask.id), directory="/data/qa/qa_files", dataformat=Dataformat.objects.get(value=Dataformat.Choices.QA_HDF5.value), producer=qafile_subtask.outputs.first(), @@ -382,21 +384,26 @@ def schedule_qaplots_subtask(qaplots_subtask: Subtask): qaplots_subtask.specifications_template.type, SubtaskType.Choices.QA_PLOTS.value)) + if len(qaplots_subtask.inputs.all()) != 1: + raise SubtaskSchedulingException("QA subtask id=%s should have 1 input, but it has %s" % (qaplots_subtask.id, len(qaplots_subtask.inputs))) + # step 1: set state to SCHEDULING qaplots_subtask.state = SubtaskState.objects.get(value=SubtaskState.Choices.SCHEDULING.value) qaplots_subtask.save() # step 2: link input dataproducts # this should typically be a single input with a single dataproduct (the qa h5 file) - for input in qaplots_subtask.inputs.all(): - input.dataproducts.set(input.producer.dataproducts.all()) + qa_input = qaplots_subtask.inputs.first() + qa_input.dataproducts.set(qa_input.producer.dataproducts.all()) # step 3: resource assigner # is a no-op for QA # step 4: create output dataproducts, and link these to the output # TODO: Should the output and/or dataproduct be determined by the specification in task_relation_blueprint? - qaplots_subtask_dataproduct = Dataproduct.objects.create(directory="/data/qa/plots/L%d" % (qaplots_subtask.id,), + qafile_subtask = qaplots_subtask.predecessors.first() + obs_subtask = qafile_subtask.predecessors.first() + qaplots_subtask_dataproduct = Dataproduct.objects.create(directory="/data/qa/plots/L%s_%s" % (obs_subtask.id, qaplots_subtask.id), dataformat=Dataformat.objects.get(value=Dataformat.Choices.QA_PLOTS.value), producer=qaplots_subtask.outputs.first(), specifications_doc="",