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

Python api.get_execution函数代码示例

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

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



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

示例1: test_stop_workflow_fail

    def test_stop_workflow_fail(self):
        # Start workflow.
        wf_ex = self.engine.start_workflow(
            'wb.wf', {'param1': 'Hey', 'param2': 'Hi'}, task_name="task2")
        # Re-read execution to access related tasks.
        wf_ex = db_api.get_execution(wf_ex.id)

        self.engine.stop_workflow(wf_ex.id, 'ERROR', "Stop this!")

        # Re-read from DB again
        wf_ex = db_api.get_execution(wf_ex.id)

        self.assertEqual('ERROR', wf_ex.state)
        self.assertEqual("Stop this!", wf_ex.state_info)
开发者ID:dennybaa,项目名称:mistral,代码行数:14,代码来源:test_default_engine.py


示例2: test_stop_workflow_succeed

    def test_stop_workflow_succeed(self):
        # Start workflow.
        wf_ex = self.engine.start_workflow(
            'wb.wf', {'param1': 'Hey', 'param2': 'Hi'}, task_name="task2")
        # Re-read execution to access related tasks.
        wf_ex = db_api.get_execution(wf_ex.id)

        self.engine.stop_workflow(wf_ex.id, 'SUCCESS', "Like this, done")

        # Re-read from DB again
        wf_ex = db_api.get_execution(wf_ex.id)

        self.assertEqual('SUCCESS', wf_ex.state)
        self.assertEqual("Like this, done", wf_ex.state_info)
开发者ID:dennybaa,项目名称:mistral,代码行数:14,代码来源:test_default_engine.py


示例3: test_delayed_task_and_correct_finish_workflow

    def test_delayed_task_and_correct_finish_workflow(self):
        wf_delayed_state = """---
        version: "2.0"
        wf:
          type: direct
          tasks:

            task1:
              action: std.noop
              wait-before: 1

            task2:
              action: std.noop
        """
        wf_service.create_workflows(wf_delayed_state)

        # Start workflow.
        wf_ex = self.engine.start_workflow('wf', {})

        self._await(lambda: self.is_execution_success(wf_ex.id))

        # Note: We need to reread execution to access related tasks.
        wf_ex = db_api.get_execution(wf_ex.id)

        self.assertEqual(2, len(wf_ex.task_executions))
开发者ID:cibingeorge,项目名称:mistral,代码行数:25,代码来源:test_policies.py


示例4: test_stop_succeeded

    def test_stop_succeeded(self):
        self.engine.stop_workflow(self.exec_id, states.ERROR, "Failure")

        self._await(lambda: self.is_execution_error(self.exec_id))
        wf_ex = db_api.get_execution(self.exec_id)
        self.assertEqual(states.ERROR, wf_ex.state)
        self.assertEqual("Failure", wf_ex.state_info)
开发者ID:ainkov,项目名称:mistral,代码行数:7,代码来源:test_workflow_stop.py


示例5: test_stop_failed

    def test_stop_failed(self):
        self.engine.stop_workflow(self.exec_id, states.SUCCESS, "Force stop")

        self._await(lambda: self.is_execution_success(self.exec_id))
        wf_ex = db_api.get_execution(self.exec_id)
        self.assertEqual(states.SUCCESS, wf_ex.state)
        self.assertEqual("Force stop", wf_ex.state_info)
开发者ID:ainkov,项目名称:mistral,代码行数:7,代码来源:test_workflow_stop.py


示例6: test_with_items_concurrency_gt_list_length

    def test_with_items_concurrency_gt_list_length(self):
        workflow_definition = """---
        version: "2.0"

        concurrency_test:
          type: direct

          input:
           - names: ["John", "Ivan"]

          tasks:
            task1:
              with-items: name in <% $.names %>
              action: std.echo output=<% $.name %>
              concurrency: 3
        """

        wf_service.create_workflows(workflow_definition)

        # Start workflow.
        wf_ex = self.engine.start_workflow('concurrency_test', {})

        self._await(
            lambda: self.is_execution_success(wf_ex.id),
        )

        wf_ex = db_api.get_execution(wf_ex.id)
        task_ex = self._assert_single_item(wf_ex.task_executions, name='task1')
        result = data_flow.get_task_execution_result(task_ex)

        self.assertEqual(states.SUCCESS, task_ex.state)
        self.assertIsInstance(result, list)
        self.assertIn('John', result)
        self.assertIn('Ivan', result)
开发者ID:cibingeorge,项目名称:mistral,代码行数:34,代码来源:test_with_items.py


示例7: stop_workflow

    def stop_workflow(self, execution_id, state, message=None):
        with db_api.transaction():
            # Must be before loading the object itself (see method doc).
            self._lock_workflow_execution(execution_id)

            wf_ex = db_api.get_execution(execution_id)

            return self._stop_workflow(wf_ex, state, message)
开发者ID:dennybaa,项目名称:mistral,代码行数:8,代码来源:default_engine.py


示例8: test_stop_workflow_bad_status

    def test_stop_workflow_bad_status(self):
        wf_ex = self.engine.start_workflow(
            'wb.wf', {'param1': 'Hey', 'param2': 'Hi'}, task_name="task2")
        # Re-read execution to access related tasks.
        wf_ex = db_api.get_execution(wf_ex.id)

        self.assertNotEqual(
            'PAUSE',
            self.engine.stop_workflow(wf_ex.id, 'PAUSE')
        )
开发者ID:dennybaa,项目名称:mistral,代码行数:10,代码来源:test_default_engine.py


示例9: test_full_join_parallel_published_vars_complex

    def test_full_join_parallel_published_vars_complex(self):
        wfs_tasks_join_complex = """---
        version: "2.0"

        main:
          type: direct
          output:
            var_a: <% $.var_a %>
            var_b: <% $.var_b %>
            var_c: <% $.var_c %>
            var_d: <% $.var_d %>
          tasks:
            init:
              publish:
                var_a: 0
                var_b: 0
                var_c: 0
              on-success:
                - branch1_0
                - branch2_0

            branch1_0:
              publish:
                var_c: 1
              on-success:
                - branch1_1

            branch2_0:
              publish:
                var_a: 1
              on-success:
                - done

            branch1_1:
              publish:
                var_b: 1
              on-success:
                - done

            done:
              join: all
              publish:
                var_d: 1
        """
        wf_service.create_workflows(wfs_tasks_join_complex)

        # Start workflow.
        exec_db = self.engine.start_workflow("main", {})

        self._await(lambda: self.is_execution_success(exec_db.id))

        # Note: We need to reread execution to access related tasks.
        exec_db = db_api.get_execution(exec_db.id)

        self.assertDictEqual({"var_a": 1, "var_b": 1, "var_c": 1, "var_d": 1}, exec_db.output)
开发者ID:kantorv,项目名称:mistral,代码行数:55,代码来源:test_join.py


示例10: test_with_items_subflow_concurrency_gt_list_length

    def test_with_items_subflow_concurrency_gt_list_length(self):
        wb_text = """---
        version: "2.0"
        name: wb1

        workflows:
          main:
            type: direct

            input:
             - names

            tasks:
              task1:
                with-items: name in <% $.names %>
                workflow: subflow1 name=<% $.name %>
                concurrency: 3

          subflow1:
            type: direct

            input:
                - name
            output:
              result: <% task(task1).result %>

            tasks:
              task1:
                action: std.echo output=<% $.name %>
        """

        wb_service.create_workbook_v2(wb_text)

        # Start workflow.
        names = ["Peter", "Susan", "Edmund", "Lucy", "Aslan", "Caspian"]
        wf_ex = self.engine.start_workflow('wb1.main', {'names': names})

        self.await_execution_success(wf_ex.id)

        wf_ex = db_api.get_execution(wf_ex.id)

        task_ex = self._assert_single_item(
            wf_ex.task_executions,
            name='task1',
            state=states.SUCCESS
        )

        result = [
            item['result']
            for item in data_flow.get_task_execution_result(task_ex)
        ]

        self.assertListEqual(sorted(result), sorted(names))
开发者ID:ISCAS-VDI,项目名称:mistral-base,代码行数:53,代码来源:test_with_items.py


示例11: test_wait_before_policy_from_var

    def test_wait_before_policy_from_var(self):
        wb_service.create_workbook_v2(WAIT_BEFORE_FROM_VAR)

        # Start workflow.
        exec_db = self.engine.start_workflow('wb.wf1', {'wait_before': 1})

        # Note: We need to reread execution to access related tasks.
        exec_db = db_api.get_execution(exec_db.id)
        task_db = exec_db.task_executions[0]

        self.assertEqual(states.RUNNING_DELAYED, task_db.state)

        self._await(lambda: self.is_execution_success(exec_db.id))
开发者ID:cibingeorge,项目名称:mistral,代码行数:13,代码来源:test_policies.py


示例12: test_expiration_policy_for_executions

    def test_expiration_policy_for_executions(self):
        # Delete execution uses a secured filtering and we need
        # to verify that admin able to do that for other projects.
        cfg.CONF.set_default('auth_enable', True, group='pecan')

        # Since we are removing other projects execution,
        # we want to load the executions with other project_id.
        _switch_context('non_admin_project', False)

        _load_executions()

        now = datetime.datetime.now()

        # This execution has a parent wf and testing that we are
        # querying only for parent wfs.
        exec_child = db_api.get_execution('654')

        self.assertEqual('789', exec_child.task_execution_id)

        # Call for all expired wfs execs.
        execs = db_api.get_expired_executions(now)

        # Should be only 3, the RUNNING execution shouldn't return,
        # so the child wf (that has parent task id).
        self.assertEqual(3, len(execs))

        # Switch context to Admin since expiration policy running as Admin.
        _switch_context(None, True)

        # TODO(m4dcoder): The expiration policy is changed here to expire
        # executions older than 30 minutes. It was originally 10 minutes.
        # The unit test below expects 1 execution to remain after the policy
        # is applied. However, the unit test fail frequently because the
        # process that deletes the expired executions seem to run late and
        # all executions are deleted. The unit tests seems to run better if
        # the config is changed to 30 minutes. Troubleshoot the expiration
        # policy to identify cause of the delay.
        _set_expiration_policy_config(1, 30)
        expiration_policy.run_execution_expiration_policy(self, ctx)

        # Only non_expired available (update_at < older_than).
        execs = db_api.get_expired_executions(now)

        self.assertEqual(1, len(execs))
        self.assertEqual('987', execs[0].id)

        _set_expiration_policy_config(1, 5)
        expiration_policy.run_execution_expiration_policy(self, ctx)
        execs = db_api.get_expired_executions(now)

        self.assertEqual(0, len(execs))
开发者ID:adarshkoyya,项目名称:mistral,代码行数:51,代码来源:test_expired_executions_policy.py


示例13: test_with_items_concurrency_2_fail

    def test_with_items_concurrency_2_fail(self):
        workflow_with_concurrency_2_fail = """---
        version: "2.0"

        concurrency_test_fail:
          type: direct

          tasks:
            task1:
              with-items: i in [1, 2, 3, 4]
              action: std.fail
              concurrency: 2
              on-error: task2

            task2:
              action: std.echo output="With-items failed"

        """
        wf_service.create_workflows(workflow_with_concurrency_2_fail)

        # Start workflow.
        wf_ex = self.engine.start_workflow('concurrency_test_fail', {})

        self._await(
            lambda: self.is_execution_success(wf_ex.id),
        )
        wf_ex = db_api.get_execution(wf_ex.id)

        task_exs = wf_ex.task_executions

        self.assertEqual(2, len(task_exs))

        task_2 = self._assert_single_item(task_exs, name='task2')

        self.assertEqual(
            "With-items failed",
            data_flow.get_task_execution_result(task_2)
        )
开发者ID:dennybaa,项目名称:mistral,代码行数:38,代码来源:test_with_items.py


示例14: test_with_items_concurrency_3

    def test_with_items_concurrency_3(self):
        workflow_with_concurrency_3 = """---
        version: "2.0"

        concurrency_test:
          type: direct

          input:
           - names: ["John", "Ivan", "Mistral"]

          tasks:
            task1:
              action: std.async_noop
              with-items: name in <% $.names %>
              concurrency: 3

        """
        wf_service.create_workflows(workflow_with_concurrency_3)

        # Start workflow.
        wf_ex = self.engine.start_workflow('concurrency_test', {})
        wf_ex = db_api.get_execution(wf_ex.id)
        task_ex = wf_ex.task_executions[0]

        self.assert_capacity(0, task_ex)
        self.assertEqual(3, self.get_running_action_exs_number(task_ex))

        # 1st iteration complete.
        self.engine.on_action_complete(
            self.get_incomplete_action_ex(task_ex).id,
            wf_utils.Result("John")
        )

        task_ex = db_api.get_task_execution(task_ex.id)
        self.assert_capacity(1, task_ex)

        # 2nd iteration complete.
        self.engine.on_action_complete(
            self.get_incomplete_action_ex(task_ex).id,
            wf_utils.Result("Ivan")
        )

        task_ex = db_api.get_task_execution(task_ex.id)
        self.assert_capacity(2, task_ex)

        # 3rd iteration complete.
        self.engine.on_action_complete(
            self.get_incomplete_action_ex(task_ex).id,
            wf_utils.Result("Mistral")
        )

        task_ex = db_api.get_task_execution(task_ex.id)
        self.assert_capacity(3, task_ex)

        self._await(
            lambda: self.is_execution_success(wf_ex.id),
        )

        task_ex = db_api.get_task_execution(task_ex.id)
        # Since we know that we can receive results in random order,
        # check is not depend on order of items.
        result = data_flow.get_task_execution_result(task_ex)
        self.assertTrue(isinstance(result, list))

        self.assertIn('John', result)
        self.assertIn('Ivan', result)
        self.assertIn('Mistral', result)

        self.assertEqual(states.SUCCESS, task_ex.state)
开发者ID:dennybaa,项目名称:mistral,代码行数:69,代码来源:test_with_items.py


示例15: is_execution_in_state

 def is_execution_in_state(self, ex_id, state):
     return db_api.get_execution(ex_id).state == state
开发者ID:PrinceKatiyar,项目名称:mistral,代码行数:2,代码来源:base.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python api.get_task_execution函数代码示例发布时间:2022-05-27
下一篇:
Python api.get_action_executions函数代码示例发布时间: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