Github user mxmrlv commented on a diff in the pull request:
https://github.com/apache/incubator-ariatosca/pull/156#discussion_r122950583
--- Diff: aria/orchestrator/workflows/core/engine.py ---
@@ -38,84 +35,192 @@ class Engine(logger.LoggerMixin):
The workflow engine. Executes workflows
"""
- def __init__(self, executor, workflow_context, tasks_graph, **kwargs):
+ def __init__(self, default_executor, **kwargs):
super(Engine, self).__init__(**kwargs)
- self._workflow_context = workflow_context
- self._execution_graph = networkx.DiGraph()
- translation.build_execution_graph(task_graph=tasks_graph,
-
execution_graph=self._execution_graph,
- default_executor=executor)
+ self._executors = {default_executor.__class__: default_executor}
+ self._executing_tasks = []
- def execute(self):
+ def execute(self, ctx):
"""
execute the workflow
"""
try:
- events.start_workflow_signal.send(self._workflow_context)
+ events.start_workflow_signal.send(ctx)
while True:
- cancel = self._is_cancel()
+ cancel = self._is_cancel(ctx)
if cancel:
break
- for task in self._ended_tasks():
- self._handle_ended_tasks(task)
- for task in self._executable_tasks():
- self._handle_executable_task(task)
- if self._all_tasks_consumed():
+ for task in self._ended_tasks(ctx):
+ self._handle_ended_tasks(ctx, task)
+ for task in self._executable_tasks(ctx):
+ self._handle_executable_task(ctx, task)
+ if self._all_tasks_consumed(ctx):
break
else:
time.sleep(0.1)
if cancel:
-
events.on_cancelled_workflow_signal.send(self._workflow_context)
+ events.on_cancelled_workflow_signal.send(ctx)
else:
-
events.on_success_workflow_signal.send(self._workflow_context)
+ events.on_success_workflow_signal.send(ctx)
except BaseException as e:
- events.on_failure_workflow_signal.send(self._workflow_context,
exception=e)
+ events.on_failure_workflow_signal.send(ctx, exception=e)
raise
- def cancel_execution(self):
+ @staticmethod
+ def cancel_execution(ctx):
"""
Send a cancel request to the engine. If execution already started,
execution status
will be modified to 'cancelling' status. If execution is in
pending mode, execution status
will be modified to 'cancelled' directly.
"""
- events.on_cancelling_workflow_signal.send(self._workflow_context)
+ events.on_cancelling_workflow_signal.send(ctx)
- def _is_cancel(self):
- return self._workflow_context.execution.status in
(models.Execution.CANCELLING,
-
models.Execution.CANCELLED)
+ @staticmethod
+ def _is_cancel(ctx):
+ execution = ctx.model.execution.update(ctx.execution)
--- End diff --
refresh
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---