• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python api.execution_get函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mistral.db.api.execution_get函数的典型用法代码示例。如果您正苦于以下问题:Python execution_get函数的具体用法?Python execution_get怎么用?Python execution_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了execution_get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_engine_tasks_on_success_finish

    def test_engine_tasks_on_success_finish(self):
        # Start workflow.
        execution = self.engine.start_workflow_execution(WB_NAME,
                                                         "test_subsequent",
                                                         CONTEXT)
        tasks = db_api.tasks_get(WB_NAME, execution['id'])

        self.assertEqual(len(tasks), 1)

        execution = db_api.execution_get(WB_NAME, execution['id'])

        task = self._assert_single_item(tasks, name='test_subsequent')

        # Make 'test_subsequent' task successful.
        self.engine.convey_task_result(WB_NAME, execution['id'],
                                       task['id'],
                                       states.SUCCESS, None)

        tasks = db_api.tasks_get(WB_NAME, execution['id'])

        self.assertEqual(len(tasks), 4)

        self._assert_single_item(tasks,
                                 name='test_subsequent',
                                 state=states.SUCCESS)
        self._assert_single_item(tasks,
                                 name='attach-volumes',
                                 state=states.IDLE)

        tasks2 = self._assert_multiple_items(tasks, 2,
                                             name='create-vms',
                                             state=states.RUNNING)

        # Make 2 'create-vms' tasks successful.
        self.engine.convey_task_result(WB_NAME, execution['id'],
                                       tasks2[0]['id'],
                                       states.SUCCESS, None)
        self.engine.convey_task_result(WB_NAME, execution['id'],
                                       tasks2[1]['id'],
                                       states.SUCCESS, None)

        tasks = db_api.tasks_get(WB_NAME, execution['id'])

        self._assert_multiple_items(tasks, 2,
                                    name='create-vms',
                                    state=states.SUCCESS)
        task = self._assert_single_item(tasks,
                                        name='attach-volumes',
                                        state=states.RUNNING)

        # Make 'attach-volumes' task successful.
        self.engine.convey_task_result(WB_NAME, execution['id'],
                                       task['id'],
                                       states.SUCCESS, None)

        execution = db_api.execution_get(WB_NAME, execution['id'])
        tasks = db_api.tasks_get(WB_NAME, execution['id'])

        self.assertEqual(execution['state'], states.SUCCESS)
        self._assert_multiple_items(tasks, 4, state=states.SUCCESS)
开发者ID:dmitryilyin,项目名称:mistral,代码行数:60,代码来源:test_engine.py


示例2: handle_task

    def handle_task(self, cntx, **kwargs):
        """Handle the execution of the workbook task.

        :param cntx: a request context dict
        :type cntx: dict
        :param kwargs: a dict of method arguments
        :type kwargs: dict
        """
        try:
            task = kwargs.get('task', None)
            if not task:
                raise Exception('No task is provided to the executor.')
            LOG.info("Received a task: %s" % task)

            db_task = db_api.task_get(task['workbook_name'],
                                      task['execution_id'],
                                      task['id'])
            db_exec = db_api.execution_get(task['workbook_name'],
                                           task['execution_id'])

            if not db_exec or not db_task:
                return

            if db_exec['state'] != states.RUNNING or \
                    db_task['state'] != states.IDLE:
                return

            self._do_task_action(db_task)
            db_api.task_update(task['workbook_name'],
                               task['execution_id'],
                               task['id'],
                               {'state': states.RUNNING})
        except Exception as exc:
            LOG.exception(exc)
            self._handle_task_error(task, exc)
开发者ID:dzimine,项目名称:mistral,代码行数:35,代码来源:server.py


示例3: test_require_flow

    def test_require_flow(self):
        execution = self.engine.start_workflow_execution(WB_NAME, "greet",
                                                         CONTEXT)

        tasks = db_api.tasks_get(workbook_name=WB_NAME,
                                 execution_id=execution['id'])

        self.engine.convey_task_result(tasks[0]['id'],
                                       states.SUCCESS, None)

        tasks = db_api.tasks_get(workbook_name=WB_NAME,
                                 execution_id=execution['id'])

        self.assertIsNotNone(tasks)
        self.assertEqual(2, len(tasks))
        self.assertEqual(tasks[0]['state'], states.SUCCESS)

        self.assertEqual(tasks[1]['state'], states.RUNNING)
        self.assertEqual(states.RUNNING,
                         self.engine.get_workflow_execution_state(
                             WB_NAME, execution['id']))

        self.engine.convey_task_result(tasks[1]['id'],
                                       states.SUCCESS, None)

        tasks = db_api.tasks_get(workbook_name=WB_NAME,
                                 execution_id=execution['id'])
        execution = db_api.execution_get(execution['id'])

        self.assertEqual(execution['state'], states.SUCCESS)
        self.assertEqual(tasks[0]['state'], states.SUCCESS)
        self.assertEqual(tasks[1]['state'], states.SUCCESS)
        self.assertEqual(states.SUCCESS,
                         self.engine.get_workflow_execution_state(
                             WB_NAME, execution['id']))
开发者ID:dshulyak,项目名称:mistral,代码行数:35,代码来源:test_engine.py


示例4: test_engine_one_task

    def test_engine_one_task(self):
        # Start workflow.
        execution = ENGINE.start_workflow_execution(WB_NAME, "create-vms",
                                                    CONTEXT)

        tasks = db_api.tasks_get(WB_NAME, execution['id'])

        self.assertEqual(1, len(tasks))
        self._assert_single_item(tasks,
                                 name='create-vms',
                                 state=states.RUNNING)

        # Make 'create-vms' task successful.
        ENGINE.convey_task_result(WB_NAME, execution['id'], tasks[0]['id'],
                                  states.SUCCESS, None)

        execution = db_api.execution_get(WB_NAME, execution['id'])

        self.assertEqual(execution['state'], states.SUCCESS)

        tasks = db_api.tasks_get(WB_NAME, execution['id'])

        self.assertEqual(1, len(tasks))
        self._assert_single_item(tasks,
                                 name='create-vms',
                                 state=states.SUCCESS)
开发者ID:dzimine,项目名称:mistral,代码行数:26,代码来源:test_engine.py


示例5: run_delayed_task

        def run_delayed_task(context):
            """Runs the delayed task. Performs all the steps required to setup
            a task to run which are not already done. This is mostly code
            copied over from convey_task_result.

            :param context Mistral authentication context inherited from a
                caller thread.
            """
            auth_context.set_ctx(context)

            db_api.start_tx()

            try:
                execution_id = task['execution_id']
                execution = db_api.execution_get(execution_id)

                # Change state from DELAYED to RUNNING.

                WORKFLOW_TRACE.info("Task '%s' [%s -> %s]"
                                    % (task['name'],
                                       task['state'], states.RUNNING))
                executables = data_flow.prepare_tasks([task],
                                                      outbound_context,
                                                      workbook)
                db_api.commit_tx()
            finally:
                db_api.end_tx()

            if states.is_stopped_or_finished(execution['state']):
                return

            for task_id, action_name, action_params in executables:
                self._run_task(task_id, action_name, action_params)
开发者ID:dshulyak,项目名称:mistral,代码行数:33,代码来源:__init__.py


示例6: test_with_one_task

    def test_with_one_task(self):
        execution = self.engine.start_workflow_execution(WB_NAME, "build_name",
                                                         CONTEXT)

        task = db_api.tasks_get(workbook_name=WB_NAME,
                                execution_id=execution['id'])[0]

        executor.ExecutorClient.handle_task\
            .assert_called_once_with(auth_context.ctx(),
                                     params={'output': 'Stormin Stanley'},
                                     task_id=task['id'],
                                     action_name='std.echo')

        self.engine.convey_task_result(task['id'],
                                       states.SUCCESS,
                                       {'output': 'Stormin Stanley'})

        task = db_api.tasks_get(workbook_name=WB_NAME,
                                execution_id=execution['id'])[0]
        execution = db_api.execution_get(execution['id'])

        self.assertEqual(execution['state'], states.SUCCESS)
        self.assertEqual(task['state'], states.SUCCESS)
        self.assertEqual(
            task['output'],
            {'task': {'build_name': {'string': 'Stormin Stanley'}}})
开发者ID:dshulyak,项目名称:mistral,代码行数:26,代码来源:test_engine.py


示例7: test_add_token_to_context

    def test_add_token_to_context(self):
        task_name = "create-vms"

        cfg.CONF.pecan.auth_enable = True
        try:
            workbook = create_workbook("test_rest.yaml")
            db_api.workbook_update(workbook['name'], {'trust_id': '123'})

            execution = self.engine.start_workflow_execution(workbook['name'],
                                                             task_name, {})
            tasks = db_api.tasks_get(workbook_name=workbook['name'],
                                     execution_id=execution['id'])

            task = self._assert_single_item(tasks, name=task_name)

            openstack_context = task['in_context']['openstack']

            self.assertIn("auth_token", openstack_context)
            self.assertEqual(TOKEN, openstack_context['auth_token'])
            self.assertEqual(USER_ID, openstack_context["user_id"])

            self.engine.convey_task_result(task['id'], states.SUCCESS, {})

            execution = db_api.execution_get(execution['id'])

            self.assertEqual(states.SUCCESS, execution['state'])
        finally:
            cfg.CONF.pecan.auth_enable = False
开发者ID:lcostantino,项目名称:mistral,代码行数:28,代码来源:test_data_flow.py


示例8: run_delayed_task

        def run_delayed_task():
            """
            Runs the delayed task. Performs all the steps required to setup
            a task to run which are not already done. This is mostly code
            copied over from convey_task_result.
            """
            db_api.start_tx()
            try:
                workbook_name = task['workbook_name']
                execution_id = task['execution_id']
                execution = db_api.execution_get(workbook_name, execution_id)

                # Change state from DELAYED to IDLE to unblock processing.

                WORKFLOW_TRACE.info("Task '%s' [%s -> %s]"
                                    % (task['name'],
                                       task['state'], states.IDLE))

                db_task = db_api.task_update(workbook_name,
                                             execution_id,
                                             task['id'],
                                             {"state": states.IDLE})
                task_to_start = [db_task]
                data_flow.prepare_tasks(task_to_start, outbound_context)
                db_api.commit_tx()
            finally:
                db_api.end_tx()

            if not states.is_stopped_or_finished(execution["state"]):
                cls._run_tasks(task_to_start)
开发者ID:TimurNurlygayanov,项目名称:mistral,代码行数:30,代码来源:abstract_engine.py


示例9: get_workflow_execution_state

    def get_workflow_execution_state(cls, workbook_name, execution_id):
        execution = db_api.execution_get(workbook_name, execution_id)

        if not execution:
            raise exc.EngineException("Workflow execution not found "
                                      "[workbook_name=%s, execution_id=%s]"
                                      % (workbook_name, execution_id))

        return execution["state"]
开发者ID:TimurNurlygayanov,项目名称:mistral,代码行数:9,代码来源:abstract_engine.py


示例10: test_engine_sync_task

    def test_engine_sync_task(self):
        execution = ENGINE.start_workflow_execution(WB_NAME, "create-vm-nova",
                                                    CONTEXT)

        task = db_api.tasks_get(WB_NAME, execution['id'])[0]
        execution = db_api.execution_get(WB_NAME, execution['id'])

        self.assertEqual(execution['state'], states.SUCCESS)
        self.assertEqual(task['state'], states.SUCCESS)
开发者ID:dzimine,项目名称:mistral,代码行数:9,代码来源:test_engine.py


示例11: test_with_one_sync_task

    def test_with_one_sync_task(self):
        execution = self.engine.start_workflow_execution(WB_NAME, "build_name",
                                                         CONTEXT)

        task = db_api.tasks_get(workbook_name=WB_NAME,
                                execution_id=execution['id'])[0]
        execution = db_api.execution_get(execution['id'])

        self.assertEqual(execution['state'], states.SUCCESS)
        self.assertEqual(task['state'], states.SUCCESS)
开发者ID:dshulyak,项目名称:mistral,代码行数:10,代码来源:test_engine.py


示例12: get

    def get(self, workbook_name, id):
        LOG.debug("Fetch execution [workbook_name=%s, id=%s]" %
                  (workbook_name, id))

        values = db_api.execution_get(workbook_name, id)

        if not values:
            abort(404)
        else:
            return Execution.from_dict(values)
开发者ID:TimurNurlygayanov,项目名称:mistral,代码行数:10,代码来源:execution.py


示例13: test_engine_task_std_action_with_namespaces

    def test_engine_task_std_action_with_namespaces(self):
        execution = self.engine.start_workflow_execution(WB_NAME,
                                                         "std_http_task", {})

        tasks = db_api.tasks_get(workbook_name=WB_NAME,
                                 execution_id=execution['id'])
        execution = db_api.execution_get(execution['id'])

        self.assertEqual(1, len(tasks))
        self.assertEqual(states.SUCCESS, tasks[0]['state'])
        self.assertEqual(states.SUCCESS, execution['state'])
开发者ID:lcostantino,项目名称:mistral,代码行数:11,代码来源:test_engine.py


示例14: test_engine_with_no_namespaces

    def test_engine_with_no_namespaces(self):
        execution = self.engine.start_workflow_execution(WB_NAME, "task1", {})

        tasks = db_api.tasks_get(workbook_name=WB_NAME,
                                 execution_id=execution['id'])
        execution = db_api.execution_get(execution['id'])

        self.assertIsNotNone(tasks)
        self.assertEqual(1, len(tasks))
        self.assertEqual(tasks[0]['state'], states.SUCCESS)
        self.assertEqual(execution['state'], states.SUCCESS)
开发者ID:lcostantino,项目名称:mistral,代码行数:11,代码来源:test_engine.py


示例15: test_direct_flow_on_success_finish

    def test_direct_flow_on_success_finish(self):
        # Start workflow.
        execution = self.engine.start_workflow_execution(WB_NAME,
                                                         "start-task",
                                                         CONTEXT)
        # Only the first task is RUNNING
        tasks = db_api.tasks_get(workbook_name=WB_NAME,
                                 execution_id=execution['id'])
        self.assertEqual(len(tasks), 1)
        task = self._assert_single_item(tasks,
                                        name='start-task',
                                        state=states.RUNNING)

        # Make 'start-task' successful.
        self.engine.convey_task_result(task['id'],
                                       states.SUCCESS, None)

        tasks = db_api.tasks_get(workbook_name=WB_NAME,
                                 execution_id=execution['id'])
        self.assertEqual(len(tasks), 3)
        self._assert_single_item(tasks,
                                 name='start-task',
                                 state=states.SUCCESS)
        task1 = self._assert_single_item(tasks,
                                         name='task-one',
                                         state=states.RUNNING)
        self._assert_single_item(tasks,
                                 name='task-two',
                                 state=states.RUNNING)

        # Make 'task-one' tasks successful.
        self.engine.convey_task_result(task1['id'],
                                       states.SUCCESS, None)

        tasks = db_api.tasks_get(workbook_name=WB_NAME,
                                 execution_id=execution['id'])

        tasks_2 = self._assert_multiple_items(tasks, 2,
                                              name='task-two',
                                              state=states.RUNNING)

        # Make both 'task-two' task successful.
        self.engine.convey_task_result(tasks_2[0]['id'],
                                       states.SUCCESS, None)
        self.engine.convey_task_result(tasks_2[1]['id'],
                                       states.SUCCESS, None)

        tasks = db_api.tasks_get(workbook_name=WB_NAME,
                                 execution_id=execution['id'])
        execution = db_api.execution_get(execution['id'])

        self._assert_multiple_items(tasks, 4, state=states.SUCCESS)
        self.assertEqual(execution['state'], states.SUCCESS)
开发者ID:lcostantino,项目名称:mistral,代码行数:53,代码来源:test_engine.py


示例16: convey_task_result

    def convey_task_result(cls, workbook_name, execution_id,
                           task_id, state, result):
        db_api.start_tx()

        workbook = cls._get_workbook(workbook_name)
        try:
            #TODO(rakhmerov): validate state transition
            task = db_api.task_get(workbook_name, execution_id, task_id)

            task_output = data_flow.get_task_output(task, result)

            # Update task state.
            task = db_api.task_update(workbook_name, execution_id, task_id,
                                      {"state": state, "output": task_output})

            execution = db_api.execution_get(workbook_name, execution_id)

            # Calculate task outbound context.
            outbound_context = data_flow.get_outbound_context(task)

            cls._create_next_tasks(task, workbook)

            # Determine what tasks need to be started.
            tasks = db_api.tasks_get(workbook_name, execution_id)

            new_exec_state = cls._determine_execution_state(execution, tasks)

            if execution['state'] != new_exec_state:
                execution = \
                    db_api.execution_update(workbook_name, execution_id, {
                        "state": new_exec_state
                    })

                LOG.info("Changed execution state: %s" % execution)

            tasks_to_start = workflow.find_resolved_tasks(tasks)

            data_flow.prepare_tasks(tasks_to_start, outbound_context)

            db_api.commit_tx()
        except Exception as e:
            raise exc.EngineException("Failed to create necessary DB objects:"
                                      " %s" % e)
        finally:
            db_api.end_tx()

        if states.is_stopped_or_finished(execution["state"]):
            return task

        if tasks_to_start:
            cls._run_tasks(tasks_to_start)

        return task
开发者ID:dzimine,项目名称:mistral,代码行数:53,代码来源:abstract_engine.py


示例17: test_engine_one_task

    def test_engine_one_task(self):
        execution = self.engine.start_workflow_execution(WB_NAME, "create-vms",
                                                         CONTEXT)

        task = db_api.tasks_get(WB_NAME, execution['id'])[0]

        self.engine.convey_task_result(WB_NAME, execution['id'], task['id'],
                                       states.SUCCESS, None)

        task = db_api.tasks_get(WB_NAME, execution['id'])[0]
        execution = db_api.execution_get(WB_NAME, execution['id'])

        self.assertEqual(execution['state'], states.SUCCESS)
        self.assertEqual(task['state'], states.SUCCESS)
开发者ID:dmitryilyin,项目名称:mistral,代码行数:14,代码来源:test_engine.py


示例18: test_direct_flow_on_error_finish

    def test_direct_flow_on_error_finish(self):
        # Start workflow.
        execution = self.engine.start_workflow_execution(WB_NAME,
                                                         "start-task",
                                                         CONTEXT)
        tasks = db_api.tasks_get(workbook_name=WB_NAME,
                                 execution_id=execution['id'])

        self.assertEqual(execution['state'], states.RUNNING)
        start_task = self._assert_single_item(tasks,
                                              name='start-task',
                                              state=states.RUNNING)

        # Make 'start-task' task fail.
        self.engine.convey_task_result(start_task['id'],
                                       states.ERROR, CONTEXT)
        tasks = db_api.tasks_get(workbook_name=WB_NAME,
                                 execution_id=execution['id'])

        self.assertEqual(len(tasks), 4)
        task3 = self._assert_single_item(tasks,
                                         name='task-three',
                                         state=states.RUNNING)
        task2 = self._assert_single_item(tasks,
                                         name='task-two',
                                         state=states.RUNNING)
        task4 = self._assert_single_item(tasks,
                                         name='task-four',
                                         state=states.RUNNING)

        # Make all running tasks successful.
        self.engine.convey_task_result(task2['id'],
                                       states.SUCCESS, None)
        self.engine.convey_task_result(task3['id'],
                                       states.SUCCESS, None)
        self.engine.convey_task_result(task4['id'],
                                       states.SUCCESS, None)

        tasks = db_api.tasks_get(workbook_name=WB_NAME,
                                 execution_id=execution['id'])
        execution = db_api.execution_get(execution['id'])

        self._assert_multiple_items(tasks, 3, state=states.SUCCESS)
        self._assert_single_item(tasks, state=states.ERROR)
        self.assertEqual(execution['state'], states.SUCCESS)
开发者ID:lcostantino,项目名称:mistral,代码行数:45,代码来源:test_engine.py


示例19: handle_task

    def handle_task(self, cntx, **kwargs):
        """Handle the execution of the workbook task.

        :param cntx: a request context dict
        :type cntx: dict
        :param kwargs: a dict of method arguments
        :type kwargs: dict
        """
        try:
            task = kwargs.get('task', None)
            if not task:
                raise Exception('No task is provided to the executor.')

            LOG.info("Received a task: %s" % task)

            db_task = db_api.task_get(task['workbook_name'],
                                      task['execution_id'],
                                      task['id'])
            db_exec = db_api.execution_get(task['workbook_name'],
                                           task['execution_id'])

            if not db_exec or not db_task:
                return

            if db_exec['state'] != states.RUNNING or \
                    db_task['state'] != states.IDLE:
                return

            # Update the state to running before performing action. The
            # do_task_action assigns state to the task which is the appropriate
            # value to preserve.

            WORKFLOW_TRACE.info("Task '%s' [%s -> %s]" % (db_task['name'],
                                                          db_task['state'],
                                                          states.RUNNING))

            db_api.task_update(task['workbook_name'],
                               task['execution_id'],
                               task['id'],
                               {'state': states.RUNNING})

            self._do_task_action(db_task)
        except Exception as e:
            LOG.exception(e)
            self._handle_task_error(task, e)
开发者ID:dmitryilyin,项目名称:mistral,代码行数:45,代码来源:executor.py


示例20: get_workflow_execution_state

    def get_workflow_execution_state(self, cntx, **kwargs):
        """Gets the workflow execution state.

        :param cntx: a request context dict
        :type cntx: dict
        :param kwargs: a dict of method arguments
        :type kwargs: dict
        :return: Current workflow state.
        """
        workbook_name = kwargs.get('workbook_name')
        execution_id = kwargs.get('execution_id')

        execution = db_api.execution_get(execution_id)

        if not execution:
            raise exc.EngineException("Workflow execution not found "
                                      "[workbook_name=%s, execution_id=%s]"
                                      % (workbook_name, execution_id))

        return execution["state"]
开发者ID:dshulyak,项目名称:mistral,代码行数:20,代码来源:__init__.py



注:本文中的mistral.db.api.execution_get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python api.tasks_get函数代码示例发布时间:2022-05-27
下一篇:
Python context.set_ctx函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap