incubator-ariatosca git commit: task update wrapper [Forced Update!]

2017-06-14 Thread mxmrlv
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-278-Remove-core-tasks 8b6d7068d -> d1cfd261d (forced update)


task update wrapper


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/d1cfd261
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/d1cfd261
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/d1cfd261

Branch: refs/heads/ARIA-278-Remove-core-tasks
Commit: d1cfd261d73cbc448615f1ad3402a9b8dbd1
Parents: 600e54e
Author: max-orlov 
Authored: Wed Jun 14 19:08:14 2017 +0300
Committer: max-orlov 
Committed: Wed Jun 14 23:48:12 2017 +0300

--
 aria/orchestrator/workflows/executor/base.py | 26 ++---
 aria/orchestrator/workflows/executor/dry.py  | 34 +++
 2 files changed, 33 insertions(+), 27 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d1cfd261/aria/orchestrator/workflows/executor/base.py
--
diff --git a/aria/orchestrator/workflows/executor/base.py 
b/aria/orchestrator/workflows/executor/base.py
index 955b536..a727e5c 100644
--- a/aria/orchestrator/workflows/executor/base.py
+++ b/aria/orchestrator/workflows/executor/base.py
@@ -21,6 +21,15 @@ from aria import logger
 from aria.orchestrator import events
 
 
+def update_ctx(func):
+def _wrapper(self, ctx, *args, **kwargs):
+ctx.update_task()
+func(self, ctx, *args, **kwargs)
+ctx.update_task()
+
+return _wrapper
+
+
 class BaseExecutor(logger.LoggerMixin):
 """
 Base class for executors for running tasks
@@ -28,12 +37,12 @@ class BaseExecutor(logger.LoggerMixin):
 def _execute(self, task):
 raise NotImplementedError
 
+@update_ctx
 def execute(self, ctx):
 """
 Execute a task
 :param task: task to execute
 """
-ctx.update_task()
 if ctx.task.function:
 self._execute(ctx)
 else:
@@ -49,20 +58,17 @@ class BaseExecutor(logger.LoggerMixin):
 """
 pass
 
-@staticmethod
-def _task_started(ctx):
+@update_ctx
+def _task_started(self, ctx):
 events.start_task_signal.send(ctx)
-ctx.update_task()
 
-@staticmethod
-def _task_failed(ctx, exception, traceback=None):
+@update_ctx
+def _task_failed(self, ctx, exception, traceback=None):
 events.on_failure_task_signal.send(ctx, exception=exception, 
traceback=traceback)
-ctx.update_task()
 
-@staticmethod
-def _task_succeeded(ctx):
+@update_ctx
+def _task_succeeded(self, ctx):
 events.on_success_task_signal.send(ctx)
-ctx.update_task()
 
 
 class StubTaskExecutor(BaseExecutor):  
 # pylint: disable=abstract-method

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d1cfd261/aria/orchestrator/workflows/executor/dry.py
--
diff --git a/aria/orchestrator/workflows/executor/dry.py 
b/aria/orchestrator/workflows/executor/dry.py
index 72080b4..c12ba7c 100644
--- a/aria/orchestrator/workflows/executor/dry.py
+++ b/aria/orchestrator/workflows/executor/dry.py
@@ -18,37 +18,37 @@ Dry executor
 """
 from datetime import datetime
 
-from .base import BaseExecutor
+from . import base
 
 
-class DryExecutor(BaseExecutor):   
 # pylint: disable=abstract-method
+class DryExecutor(base.BaseExecutor):  
  # pylint: disable=abstract-method
 """
 Executor which dry runs tasks - prints task information without causing 
any side effects
 """
-def execute(self, task):
+@base.update_ctx
+def execute(self, ctx):
 # updating the task manually instead of calling 
self._task_started(task),
 # to avoid any side effects raising that event might cause
-with task._update():
-task.started_at = datetime.utcnow()
-task.status = task.STARTED
+ctx.task.started_at = datetime.utcnow()
+ctx.task.status = ctx.task.STARTED
 
 dry_msg = ' {name} {task.interface_name}.{task.operation_name} 
{suffix}'
-logger = task.context.logger.info if task.function else 
task.context.logger.debug
+logger = ctx.logger.info if ctx.task.function else ctx.logger.debug
 
-if hasattr(task.actor, 'source_node'):
+if hasattr(ctx.task.actor, 'source_node'):
 name = '{source_node.name}->{target_node.name}'.format(
-source_node=task.actor.source_node, 

incubator-ariatosca git commit: task update wrapper

2017-06-14 Thread mxmrlv
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-278-Remove-core-tasks 600e54e89 -> 8b6d7068d


task update wrapper


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/8b6d7068
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/8b6d7068
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/8b6d7068

Branch: refs/heads/ARIA-278-Remove-core-tasks
Commit: 8b6d7068de219a8826dbfeb4a75654b03f151842
Parents: 600e54e
Author: max-orlov 
Authored: Wed Jun 14 19:08:14 2017 +0300
Committer: max-orlov 
Committed: Wed Jun 14 19:08:14 2017 +0300

--
 aria/orchestrator/workflows/executor/base.py | 26 ++---
 aria/orchestrator/workflows/executor/dry.py  | 34 +++
 2 files changed, 33 insertions(+), 27 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8b6d7068/aria/orchestrator/workflows/executor/base.py
--
diff --git a/aria/orchestrator/workflows/executor/base.py 
b/aria/orchestrator/workflows/executor/base.py
index 955b536..a727e5c 100644
--- a/aria/orchestrator/workflows/executor/base.py
+++ b/aria/orchestrator/workflows/executor/base.py
@@ -21,6 +21,15 @@ from aria import logger
 from aria.orchestrator import events
 
 
+def update_ctx(func):
+def _wrapper(self, ctx, *args, **kwargs):
+ctx.update_task()
+func(self, ctx, *args, **kwargs)
+ctx.update_task()
+
+return _wrapper
+
+
 class BaseExecutor(logger.LoggerMixin):
 """
 Base class for executors for running tasks
@@ -28,12 +37,12 @@ class BaseExecutor(logger.LoggerMixin):
 def _execute(self, task):
 raise NotImplementedError
 
+@update_ctx
 def execute(self, ctx):
 """
 Execute a task
 :param task: task to execute
 """
-ctx.update_task()
 if ctx.task.function:
 self._execute(ctx)
 else:
@@ -49,20 +58,17 @@ class BaseExecutor(logger.LoggerMixin):
 """
 pass
 
-@staticmethod
-def _task_started(ctx):
+@update_ctx
+def _task_started(self, ctx):
 events.start_task_signal.send(ctx)
-ctx.update_task()
 
-@staticmethod
-def _task_failed(ctx, exception, traceback=None):
+@update_ctx
+def _task_failed(self, ctx, exception, traceback=None):
 events.on_failure_task_signal.send(ctx, exception=exception, 
traceback=traceback)
-ctx.update_task()
 
-@staticmethod
-def _task_succeeded(ctx):
+@update_ctx
+def _task_succeeded(self, ctx):
 events.on_success_task_signal.send(ctx)
-ctx.update_task()
 
 
 class StubTaskExecutor(BaseExecutor):  
 # pylint: disable=abstract-method

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8b6d7068/aria/orchestrator/workflows/executor/dry.py
--
diff --git a/aria/orchestrator/workflows/executor/dry.py 
b/aria/orchestrator/workflows/executor/dry.py
index 72080b4..c12ba7c 100644
--- a/aria/orchestrator/workflows/executor/dry.py
+++ b/aria/orchestrator/workflows/executor/dry.py
@@ -18,37 +18,37 @@ Dry executor
 """
 from datetime import datetime
 
-from .base import BaseExecutor
+from . import base
 
 
-class DryExecutor(BaseExecutor):   
 # pylint: disable=abstract-method
+class DryExecutor(base.BaseExecutor):  
  # pylint: disable=abstract-method
 """
 Executor which dry runs tasks - prints task information without causing 
any side effects
 """
-def execute(self, task):
+@base.update_ctx
+def execute(self, ctx):
 # updating the task manually instead of calling 
self._task_started(task),
 # to avoid any side effects raising that event might cause
-with task._update():
-task.started_at = datetime.utcnow()
-task.status = task.STARTED
+ctx.task.started_at = datetime.utcnow()
+ctx.task.status = ctx.task.STARTED
 
 dry_msg = ' {name} {task.interface_name}.{task.operation_name} 
{suffix}'
-logger = task.context.logger.info if task.function else 
task.context.logger.debug
+logger = ctx.logger.info if ctx.task.function else ctx.logger.debug
 
-if hasattr(task.actor, 'source_node'):
+if hasattr(ctx.task.actor, 'source_node'):
 name = '{source_node.name}->{target_node.name}'.format(
-source_node=task.actor.source_node, 
target_node=task.actor.target_node)