You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ariatosca.apache.org by mxmrlv <gi...@git.apache.org> on 2017/06/21 09:55:14 UTC

[GitHub] incubator-ariatosca pull request #159: wip

GitHub user mxmrlv opened a pull request:

    https://github.com/apache/incubator-ariatosca/pull/159

    wip

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/apache/incubator-ariatosca ARIA-284-Cleanup-and-optimize-the-task-execution

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-ariatosca/pull/159.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #159
    
----
commit 814306ba0be3f478f2a1d135e2e26dfd6586a620
Author: max-orlov <ma...@gigaspaces.com>
Date:   2017-06-21T09:41:33Z

    wip

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #159: ARIA-284 Cleanup and optimize the tas...

Posted by mxmrlv <gi...@git.apache.org>.
Github user mxmrlv commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/159#discussion_r123895803
  
    --- Diff: aria/orchestrator/workflows/core/engine.py ---
    @@ -129,16 +103,70 @@ def _handle_executable_task(self, ctx, task, executing_tasks):
                 name=task.name
             )
     
    -        executing_tasks.append(task)
    -
             if not task._stub_type:
                 events.sent_task_signal.send(op_ctx)
             task_executor.execute(op_ctx)
     
         @staticmethod
    -    def _handle_ended_tasks(ctx, task, executing_tasks):
    -        executing_tasks.remove(task)
    +    def _handle_ended_tasks(task):
             if task.status == models.Task.FAILED and not task.ignore_failure:
                 raise exceptions.ExecutorException('Workflow failed')
    -        else:
    -            ctx._graph.remove_node(task)
    +
    +
    +class _TasksTracker(object):
    +    def __init__(self, ctx):
    +        self._ctx = ctx
    +        self._tasks = ctx.execution.tasks
    +        self._executed_tasks = [task for task in self._tasks if task.has_ended()]
    +        self._executable_tasks = list(set(self._tasks) - set(self._executed_tasks))
    +        self._executing_tasks = []
    +
    +    @property
    +    def all_tasks_consumed(self):
    +        return len(self._executed_tasks) == len(self._tasks) and len(self._executing_tasks) == 0
    +
    +    def executing_(self, task):
    +        # Task executing could be retrying (thus removed and added earlier)
    +        if task not in self._executing_tasks:
    +            self._executable_tasks.remove(task)
    +            self._executing_tasks.append(task)
    +
    +    def finished_(self, task):
    +        self._executing_tasks.remove(task)
    +        self._executed_tasks.append(task)
    +
    +    @property
    +    def ended_tasks(self):
    +        for task in self.executing_tasks:
    +            if task.has_ended():
    +                yield task
    +
    +    @property
    +    def executable_tasks(self):
    +        now = datetime.utcnow()
    +        # we need both list since retrying task are in the executing task list.
    --- End diff --
    
    lists


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #159: ARIA-284 Cleanup and optimize the tas...

Posted by mxmrlv <gi...@git.apache.org>.
Github user mxmrlv commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/159#discussion_r123895688
  
    --- Diff: aria/orchestrator/workflows/core/compile.py ---
    @@ -18,99 +18,105 @@
     from .. import executor, api
     
     
    -def create_execution_tasks(ctx, task_graph, default_executor):
    -    execution = ctx.execution
    -    _construct_execution_tasks(execution, task_graph, default_executor)
    -    ctx.model.execution.update(execution)
    -    return execution.tasks
    -
    -
    -def _construct_execution_tasks(execution,
    -                               task_graph,
    -                               default_executor,
    -                               stub_executor=executor.base.StubTaskExecutor,
    -                               start_stub_type=models.Task.START_WORKFLOW,
    -                               end_stub_type=models.Task.END_WORKFLOW,
    -                               depends_on=()):
    -    """
    -    Translates the user graph to the execution graph
    -    :param task_graph: The user's graph
    -    :param start_stub_type: internal use
    -    :param end_stub_type: internal use
    -    :param depends_on: internal use
    -    """
    -    depends_on = list(depends_on)
    -
    -    # Insert start marker
    -    start_task = models.Task(execution=execution,
    -                             dependencies=depends_on,
    -                             _api_id=_start_graph_suffix(task_graph.id),
    -                             _stub_type=start_stub_type,
    -                             _executor=stub_executor)
    -
    -    for task in task_graph.topological_order(reverse=True):
    -        operation_dependencies = _get_tasks_from_dependencies(
    -            execution, task_graph.get_dependencies(task), [start_task])
    -
    -        if isinstance(task, api.task.OperationTask):
    -            models.Task.from_api_task(api_task=task,
    -                                      executor=default_executor,
    -                                      dependencies=operation_dependencies)
    -
    -        elif isinstance(task, api.task.WorkflowTask):
    -            # Build the graph recursively while adding start and end markers
    -            _construct_execution_tasks(
    -                execution=execution,
    -                task_graph=task,
    -                default_executor=default_executor,
    -                stub_executor=stub_executor,
    -                start_stub_type=models.Task.START_SUBWROFKLOW,
    -                end_stub_type=models.Task.END_SUBWORKFLOW,
    -                depends_on=operation_dependencies
    -            )
    -        elif isinstance(task, api.task.StubTask):
    -            models.Task(execution=execution,
    -                        dependencies=operation_dependencies,
    -                        _api_id=task.id,
    -                        _executor=stub_executor,
    -                        _stub_type=models.Task.STUB,
    -                       )
    -        else:
    -            raise RuntimeError('Undefined state')
    -
    -    # Insert end marker
    -    models.Task(dependencies=_get_non_dependent_tasks(execution) or [start_task],
    -                execution=execution,
    -                _api_id=_end_graph_suffix(task_graph.id),
    -                _executor=stub_executor,
    -                _stub_type=end_stub_type)
    -
    -
    -def _start_graph_suffix(api_id):
    -    return '{0}-Start'.format(api_id)
    -
    -
    -def _end_graph_suffix(api_id):
    -    return '{0}-End'.format(api_id)
    -
    -
    -def _get_non_dependent_tasks(execution):
    -    tasks_with_dependencies = set()
    -    for task in execution.tasks:
    -        tasks_with_dependencies.update(task.dependencies)
    -    return list(set(execution.tasks) - set(tasks_with_dependencies))
    -
    -
    -def _get_tasks_from_dependencies(execution, dependencies, default=()):
    -    """
    -    Returns task list from dependencies.
    -    """
    -    tasks = []
    -    for dependency in dependencies:
    -        if getattr(dependency, 'actor', False):
    -            # This is
    -            dependency_name = dependency.id
    -        else:
    -            dependency_name = _end_graph_suffix(dependency.id)
    -        tasks.extend(task for task in execution.tasks if task._api_id == dependency_name)
    -    return tasks or default
    +# TODO: is class really needed?
    --- End diff --
    
    remove


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #159: ARIA-284 Cleanup and optimize the tas...

Posted by mxmrlv <gi...@git.apache.org>.
Github user mxmrlv commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/159#discussion_r123895663
  
    --- Diff: aria/orchestrator/workflow_runner.py ---
    @@ -96,8 +96,9 @@ def __init__(self, model_storage, resource_storage, plugin_manager,
     
             if not self._is_resume:
                 workflow_fn = self._get_workflow_fn()
    -            tasks_graph = workflow_fn(ctx=self._workflow_context, **execution_inputs_dict)
    -            compile.create_execution_tasks(self._workflow_context, tasks_graph, executor.__class__)
    +            self._tasks_graph = workflow_fn(ctx=self._workflow_context, **execution_inputs_dict)
    +            compile.GraphCompiler(self._workflow_context, executor.__class__).compile(
    --- End diff --
    
    graph_compiler


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #159: ARIA-284 Cleanup and optimize the tas...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-ariatosca/pull/159


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #159: ARIA-284 Cleanup and optimize the tas...

Posted by mxmrlv <gi...@git.apache.org>.
Github user mxmrlv commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/159#discussion_r123895735
  
    --- Diff: aria/orchestrator/workflows/core/engine.py ---
    @@ -45,22 +45,23 @@ def execute(self, ctx, resuming=False):
             """
             execute the workflow
             """
    -        executing_tasks = []
    -
             if resuming:
                 events.on_resume_workflow_signal.send(ctx)
     
    +        task_tracker = _TasksTracker(ctx)
             try:
                 events.start_workflow_signal.send(ctx)
                 while True:
                     cancel = self._is_cancel(ctx)
                     if cancel:
                         break
    -                for task in self._ended_tasks(ctx, executing_tasks):
    -                    self._handle_ended_tasks(ctx, task, executing_tasks)
    -                for task in self._executable_tasks(ctx):
    -                    self._handle_executable_task(ctx, task, executing_tasks)
    -                if self._all_tasks_consumed(ctx):
    +                for task in task_tracker.ended_tasks:
    +                    self._handle_ended_tasks(task)
    +                    task_tracker.finished_(task)
    --- End diff --
    
    remove _


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca issue #159: wip

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit commented on the issue:

    https://github.com/apache/incubator-ariatosca/pull/159
  
    Can one of the admins verify this patch?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---