diff --git a/SAS/TMSS/backend/services/workflow_service/lib/workflow_service.py b/SAS/TMSS/backend/services/workflow_service/lib/workflow_service.py index 9b62dfa8a65d35a239ca3fadcafc8ba7faa8cd73..eec9d50281beeddf8de009374d8576247df419b6 100644 --- a/SAS/TMSS/backend/services/workflow_service/lib/workflow_service.py +++ b/SAS/TMSS/backend/services/workflow_service/lib/workflow_service.py @@ -32,7 +32,7 @@ class SchedulingUnitEventMessageHandler(TMSSEventMessageHandler): def onSchedulingUnitBlueprintStatusChanged(self, id: int, status: str): try: # import here and not at top of module because we need the django.setup() to be run first, either from this module's main, or from the TMSSTestEnvironment - from lofar.sas.tmss.tmss.workflowapp.signals import scheduling_unit_blueprint_schedulable_signal, scheduling_unit_blueprint_scheduled_signal, scheduling_unit_blueprint_observing_signal, scheduling_unit_blueprint_observed_signal, scheduling_unit_blueprint_ingested_signal, scheduling_unit_blueprint_finished_signal + from lofar.sas.tmss.tmss.workflowapp.signals import scheduling_unit_blueprint_schedulable_signal, scheduling_unit_blueprint_scheduled_signal, scheduling_unit_blueprint_observing_signal, scheduling_unit_blueprint_observed_signal, scheduling_unit_blueprint_ingested_signal, scheduling_unit_blueprint_done_signal from lofar.sas.tmss.tmss.workflowapp.models import SchedulingUnitTask from lofar.sas.tmss.tmss.tmssapp.models import SchedulingUnitBlueprint, SchedulingUnitStatus, TaskType, SubtaskType @@ -53,9 +53,9 @@ class SchedulingUnitEventMessageHandler(TMSSEventMessageHandler): elif status == SchedulingUnitStatus.Choices.INGESTED.value: logger.info("workflow scheduling_unit_blueprint id=%s is fully ingested, signalling workflow...", id) scheduling_unit_blueprint_ingested_signal.send(sender=self.__class__, scheduling_unit_blueprint=scheduling_unit_blueprint) - elif status == SchedulingUnitStatus.Choices.FINISHED.value: - logger.info("workflow scheduling_unit_blueprint id=%s is fully finished, signalling workflow...", id) - scheduling_unit_blueprint_finished_signal.send(sender=self.__class__, scheduling_unit_blueprint=scheduling_unit_blueprint) + elif status in SchedulingUnitStatus.DONE_STATUS_VALUES: + logger.info("workflow scheduling_unit_blueprint id=%s is fully done, signalling workflow...", id) + scheduling_unit_blueprint_done_signal.send(sender=self.__class__, scheduling_unit_blueprint=scheduling_unit_blueprint) except Exception as e: logger.exception("Exception in workflow onSchedulingUnitBlueprintStatusChanged: %s" % (str(e),)) diff --git a/SAS/TMSS/backend/src/tmss/workflowapp/flows/schedulingunitflow.py b/SAS/TMSS/backend/src/tmss/workflowapp/flows/schedulingunitflow.py index e51e1d8180dccf0aa2caa30cb3ce2ec0762fceac..e3973a04ce18ddf6ed405838fc2d810b13d502ed 100644 --- a/SAS/TMSS/backend/src/tmss/workflowapp/flows/schedulingunitflow.py +++ b/SAS/TMSS/backend/src/tmss/workflowapp/flows/schedulingunitflow.py @@ -262,7 +262,7 @@ class SchedulingUnitFlow(Flow): wait_finished = ( Conditional( this.is_SUB_finished_state_or_beyond, - scheduling_unit_blueprint_finished_signal, + scheduling_unit_blueprint_done_signal, task_loader=this.get_scheduling_unit_task ) .Next(this.end) @@ -356,6 +356,8 @@ class SchedulingUnitFlow(Flow): condition = scheduling_unit.status.value in SchedulingUnitStatus.ACTIVE_OR_FINISHED_STATUS_VALUES elif expected_status == SchedulingUnitStatus.Choices.SCHEDULABLE.value: condition = scheduling_unit.status.value in SchedulingUnitStatus.SCHEDULABLE_ACTIVE_OR_FINISHED_STATUS_VALUES + elif expected_status == SchedulingUnitStatus.Choices.FINISHED.value: + condition = scheduling_unit.status.value in SchedulingUnitStatus.DONE_STATUS_VALUES return condition diff --git a/SAS/TMSS/backend/src/tmss/workflowapp/signals/__init__.py b/SAS/TMSS/backend/src/tmss/workflowapp/signals/__init__.py index 5e9ac2c06c7c1e275964fef648eed6b8a1563ca5..ac09eb418ff4e0613e6374346891b61f4f825858 100644 --- a/SAS/TMSS/backend/src/tmss/workflowapp/signals/__init__.py +++ b/SAS/TMSS/backend/src/tmss/workflowapp/signals/__init__.py @@ -5,6 +5,6 @@ scheduling_unit_blueprint_scheduled_signal = django.dispatch.Signal() scheduling_unit_blueprint_observing_signal = django.dispatch.Signal() scheduling_unit_blueprint_observed_signal = django.dispatch.Signal() scheduling_unit_blueprint_ingested_signal = django.dispatch.Signal() -scheduling_unit_blueprint_finished_signal = django.dispatch.Signal() +scheduling_unit_blueprint_done_signal = django.dispatch.Signal()