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

Python utils.make_many函数代码示例

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

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



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

示例1: test_run_iterations_suspended_failure

    def test_run_iterations_suspended_failure(self):
        flow = lf.Flow("root")
        sad_tasks = test_utils.make_many(
            1, task_cls=test_utils.NastyFailingTask)
        flow.add(*sad_tasks)
        happy_tasks = test_utils.make_many(
            1, task_cls=test_utils.TaskNoRequiresNoReturns, offset=1)
        flow.add(*happy_tasks)

        runtime, machine, memory, machine_runner = self._make_machine(
            flow, initial_state=st.RUNNING)

        transitions = []
        for prior_state, new_state in machine_runner.run_iter(builder.START):
            transitions.append((new_state, memory.failures))
            if new_state == st.ANALYZING:
                runtime.storage.set_flow_state(st.SUSPENDED)
        state, failures = transitions[-1]
        self.assertEqual(st.SUSPENDED, state)
        self.assertEqual([], failures)

        self.assertEqual(st.PENDING,
                         runtime.storage.get_atom_state(happy_tasks[0].name))
        self.assertEqual(st.FAILURE,
                         runtime.storage.get_atom_state(sad_tasks[0].name))
开发者ID:FedericoCeratto,项目名称:taskflow,代码行数:25,代码来源:test_builder.py


示例2: test_run_iterations_suspended_failure

    def test_run_iterations_suspended_failure(self):
        flow = lf.Flow("root")
        sad_tasks = test_utils.make_many(
            1, task_cls=test_utils.NastyFailingTask)
        flow.add(*sad_tasks)
        happy_tasks = test_utils.make_many(
            1, task_cls=test_utils.TaskNoRequiresNoReturns, offset=1)
        flow.add(*happy_tasks)

        rt = self._make_runtime(flow, initial_state=st.RUNNING)
        self.assertTrue(rt.runner.runnable())

        transitions = []
        for state, failures in rt.runner.run_iter():
            transitions.append((state, failures))
            if state == st.ANALYZING:
                rt.storage.set_flow_state(st.SUSPENDED)
        state, failures = transitions[-1]
        self.assertEqual(st.SUSPENDED, state)
        self.assertEqual([], failures)

        self.assertEqual(st.PENDING,
                         rt.storage.get_atom_state(happy_tasks[0].name))
        self.assertEqual(st.FAILURE,
                         rt.storage.get_atom_state(sad_tasks[0].name))
开发者ID:LiuZhiyan,项目名称:taskflow,代码行数:25,代码来源:test_runner.py


示例3: test_retries_hierarchy

    def test_retries_hierarchy(self):
        c1 = retry.AlwaysRevert("c1")
        c2 = retry.AlwaysRevert("c2")
        a, b, c, d = test_utils.make_many(4)
        inner_flo = lf.Flow("test2", c2).add(b, c)
        flo = lf.Flow("test", c1).add(a, inner_flo, d)

        g = _replicate_graph_with_names(
            compiler.PatternCompiler(flo).compile())
        self.assertEqual(10, len(g))
        self.assertItemsEqual(g.edges(data=True), [
            ('test', 'c1', {'invariant': True}),
            ('c1', 'a', {'invariant': True, 'retry': True}),
            ('a', 'test2', {'invariant': True}),
            ('test2', 'c2', {'invariant': True}),
            ('c2', 'b', {'invariant': True, 'retry': True}),
            ('b', 'c', {'invariant': True}),
            ('c', 'test2[$]', {'invariant': True}),
            ('test2[$]', 'd', {'invariant': True}),
            ('d', 'test[$]', {'invariant': True}),
        ])
        self.assertIs(c1, g.node['a']['retry'])
        self.assertIs(c1, g.node['d']['retry'])
        self.assertIs(c2, g.node['b']['retry'])
        self.assertIs(c2, g.node['c']['retry'])
        self.assertIs(c1, g.node['c2']['retry'])
        self.assertIs(None, g.node['c1'].get('retry'))
开发者ID:FedericoCeratto,项目名称:taskflow,代码行数:27,代码来源:test_compile.py


示例4: test_graph_nested_graph

    def test_graph_nested_graph(self):
        a, b, c, d, e, f, g = test_utils.make_many(7)
        flo = gf.Flow("test")
        flo.add(a, b, c, d)

        flo2 = gf.Flow('test2')
        flo2.add(e, f, g)
        flo.add(flo2)

        g = _replicate_graph_with_names(
            compiler.PatternCompiler(flo).compile())
        self.assertEqual(11, len(g))
        self.assertItemsEqual(g.edges(), [
            ('test', 'a'),
            ('test', 'b'),
            ('test', 'c'),
            ('test', 'd'),
            ('test', 'test2'),

            ('test2', 'e'),
            ('test2', 'f'),
            ('test2', 'g'),

            ('e', 'test2[$]'),
            ('f', 'test2[$]'),
            ('g', 'test2[$]'),

            ('test2[$]', 'test[$]'),
            ('a', 'test[$]'),
            ('b', 'test[$]'),
            ('c', 'test[$]'),
            ('d', 'test[$]'),
        ])
开发者ID:FedericoCeratto,项目名称:taskflow,代码行数:33,代码来源:test_compile.py


示例5: test_graph

 def test_graph(self):
     a, b, c, d = test_utils.make_many(4)
     flo = gf.Flow("test")
     flo.add(a, b, c, d)
     compilation = compiler.PatternCompiler(flo).compile()
     self.assertEqual(6, len(compilation.execution_graph))
     self.assertEqual(8, compilation.execution_graph.number_of_edges())
开发者ID:FedericoCeratto,项目名称:taskflow,代码行数:7,代码来源:test_compile.py


示例6: test_run_iterations

    def test_run_iterations(self):
        flow = lf.Flow("root")
        tasks = test_utils.make_many(
            1, task_cls=test_utils.TaskNoRequiresNoReturns)
        flow.add(*tasks)

        rt = self._make_runtime(flow, initial_state=st.RUNNING)
        self.assertTrue(rt.runner.runnable())

        it = rt.runner.run_iter()
        state, failures = six.next(it)
        self.assertEqual(st.RESUMING, state)
        self.assertEqual(0, len(failures))

        state, failures = six.next(it)
        self.assertEqual(st.SCHEDULING, state)
        self.assertEqual(0, len(failures))

        state, failures = six.next(it)
        self.assertEqual(st.WAITING, state)
        self.assertEqual(0, len(failures))

        state, failures = six.next(it)
        self.assertEqual(st.ANALYZING, state)
        self.assertEqual(0, len(failures))

        state, failures = six.next(it)
        self.assertEqual(st.SUCCESS, state)
        self.assertEqual(0, len(failures))

        self.assertRaises(StopIteration, six.next, it)
开发者ID:LiuZhiyan,项目名称:taskflow,代码行数:31,代码来源:test_runner.py


示例7: test_retries_hierarchy

    def test_retries_hierarchy(self):
        c1 = retry.AlwaysRevert("cp1")
        c2 = retry.AlwaysRevert("cp2")
        a, b, c, d = test_utils.make_many(4)
        flo = lf.Flow("test", c1).add(
            a,
            lf.Flow("test", c2).add(b, c),
            d)
        compilation = compiler.PatternCompiler(flo).compile()
        g = compilation.execution_graph

        self.assertEqual(6, len(g))
        self.assertItemsEqual(g.edges(data=True), [
            (c1, a, {'retry': True}),
            (a, c2, {'invariant': True}),
            (c2, b, {'retry': True}),
            (b, c, {'invariant': True}),
            (c, d, {'invariant': True}),
        ])
        self.assertIs(c1, g.node[a]['retry'])
        self.assertIs(c1, g.node[d]['retry'])
        self.assertIs(c2, g.node[b]['retry'])
        self.assertIs(c2, g.node[c]['retry'])
        self.assertIs(c1, g.node[c2]['retry'])
        self.assertIs(None, g.node[c1].get('retry'))
开发者ID:TheSriram,项目名称:taskflow,代码行数:25,代码来源:test_compile.py


示例8: test_invalid

 def test_invalid(self):
     a, b, c = test_utils.make_many(3)
     flo = lf.Flow("test")
     flo.add(a, b, c)
     flo.add(flo)
     self.assertRaises(ValueError,
                       compiler.PatternCompiler(flo).compile)
开发者ID:TheSriram,项目名称:taskflow,代码行数:7,代码来源:test_compile.py


示例9: test_run_iterations

    def test_run_iterations(self):
        flow = lf.Flow("root")
        tasks = test_utils.make_many(
            1, task_cls=test_utils.TaskNoRequiresNoReturns)
        flow.add(*tasks)

        runtime, machine, memory, machine_runner = self._make_machine(
            flow, initial_state=st.RUNNING)

        it = machine_runner.run_iter(builder.START)
        prior_state, new_state = six.next(it)
        self.assertEqual(st.RESUMING, new_state)
        self.assertEqual(0, len(memory.failures))

        prior_state, new_state = six.next(it)
        self.assertEqual(st.SCHEDULING, new_state)
        self.assertEqual(0, len(memory.failures))

        prior_state, new_state = six.next(it)
        self.assertEqual(st.WAITING, new_state)
        self.assertEqual(0, len(memory.failures))

        prior_state, new_state = six.next(it)
        self.assertEqual(st.ANALYZING, new_state)
        self.assertEqual(0, len(memory.failures))

        prior_state, new_state = six.next(it)
        self.assertEqual(builder.GAME_OVER, new_state)
        self.assertEqual(0, len(memory.failures))
        prior_state, new_state = six.next(it)
        self.assertEqual(st.SUCCESS, new_state)
        self.assertEqual(0, len(memory.failures))

        self.assertRaises(StopIteration, six.next, it)
开发者ID:FedericoCeratto,项目名称:taskflow,代码行数:34,代码来源:test_builder.py


示例10: test_running

    def test_running(self):
        flow = lf.Flow("root")
        flow.add(*test_utils.make_many(1))

        rt = self._make_runtime(flow, initial_state=st.RUNNING)
        self.assertTrue(rt.runner.runnable())

        rt = self._make_runtime(flow, initial_state=st.SUSPENDED)
        self.assertFalse(rt.runner.runnable())
开发者ID:LiuZhiyan,项目名称:taskflow,代码行数:9,代码来源:test_runner.py


示例11: test_builder_automatic_process_reverted

    def test_builder_automatic_process_reverted(self):
        flow = lf.Flow("root")
        tasks = test_utils.make_many(1, task_cls=test_utils.TaskWithFailure)
        flow.add(*tasks)

        runtime, machine, memory, machine_runner = self._make_machine(flow, initial_state=st.RUNNING)

        transitions = list(machine_runner.run_iter(builder.START))
        self.assertEqual((builder.GAME_OVER, st.REVERTED), transitions[-1])
        self.assertEqual(st.REVERTED, runtime.storage.get_atom_state(tasks[0].name))
开发者ID:junneyang,项目名称:taskflow,代码行数:10,代码来源:test_builder.py


示例12: test_builder_automatic_process_failure

    def test_builder_automatic_process_failure(self):
        flow = lf.Flow("root")
        tasks = test_utils.make_many(1, task_cls=test_utils.NastyFailingTask)
        flow.add(*tasks)

        runtime, machine, memory, machine_runner = self._make_machine(flow, initial_state=st.RUNNING)

        transitions = list(machine_runner.run_iter(builder.START))
        self.assertEqual((builder.GAME_OVER, st.FAILURE), transitions[-1])
        self.assertEqual(1, len(memory.failures))
开发者ID:junneyang,项目名称:taskflow,代码行数:10,代码来源:test_builder.py


示例13: test_builder_automatic_process

    def test_builder_automatic_process(self):
        flow = lf.Flow("root")
        tasks = test_utils.make_many(1, task_cls=test_utils.TaskNoRequiresNoReturns)
        flow.add(*tasks)

        runtime, machine, memory, machine_runner = self._make_machine(flow, initial_state=st.RUNNING)

        transitions = list(machine_runner.run_iter(builder.START))
        self.assertEqual((builder.UNDEFINED, st.RESUMING), transitions[0])
        self.assertEqual((builder.GAME_OVER, st.SUCCESS), transitions[-1])
        self.assertEqual(st.SUCCESS, runtime.storage.get_atom_state(tasks[0].name))
开发者ID:junneyang,项目名称:taskflow,代码行数:11,代码来源:test_builder.py


示例14: test_run_iterations_reverted

    def test_run_iterations_reverted(self):
        flow = lf.Flow("root")
        tasks = test_utils.make_many(1, task_cls=test_utils.TaskWithFailure)
        flow.add(*tasks)

        runtime, machine, memory, machine_runner = self._make_machine(flow, initial_state=st.RUNNING)

        transitions = list(machine_runner.run_iter(builder.START))
        prior_state, new_state = transitions[-1]
        self.assertEqual(st.REVERTED, new_state)
        self.assertEqual([], memory.failures)
        self.assertEqual(st.REVERTED, runtime.storage.get_atom_state(tasks[0].name))
开发者ID:junneyang,项目名称:taskflow,代码行数:12,代码来源:test_builder.py


示例15: test_unordered

 def test_unordered(self):
     a, b, c, d = test_utils.make_many(4)
     flo = uf.Flow("test")
     flo.add(a, b, c, d)
     compilation = compiler.PatternCompiler(flo).compile()
     g = compilation.execution_graph
     self.assertEqual(4, len(g))
     self.assertEqual(0, g.number_of_edges())
     self.assertEqual(set([a, b, c, d]),
                      set(g.no_successors_iter()))
     self.assertEqual(set([a, b, c, d]),
                      set(g.no_predecessors_iter()))
开发者ID:TheSriram,项目名称:taskflow,代码行数:12,代码来源:test_compile.py


示例16: test_builder_automatic_process_reverted

    def test_builder_automatic_process_reverted(self):
        flow = lf.Flow("root")
        tasks = test_utils.make_many(1, task_cls=test_utils.TaskWithFailure)
        flow.add(*tasks)

        rt = self._make_runtime(flow, initial_state=st.RUNNING)
        machine, machine_runner, memory = rt.runner.build()
        self.assertTrue(rt.runner.runnable())

        transitions = list(machine_runner.run_iter('start'))
        self.assertEqual((runner._GAME_OVER, st.REVERTED), transitions[-1])
        self.assertEqual(st.REVERTED, rt.storage.get_atom_state(tasks[0].name))
开发者ID:LiuZhiyan,项目名称:taskflow,代码行数:12,代码来源:test_runner.py


示例17: test_builder_automatic_process_failure

    def test_builder_automatic_process_failure(self):
        flow = lf.Flow("root")
        tasks = test_utils.make_many(1, task_cls=test_utils.NastyFailingTask)
        flow.add(*tasks)

        rt = self._make_runtime(flow, initial_state=st.RUNNING)
        machine, machine_runner, memory = rt.runner.build()
        self.assertTrue(rt.runner.runnable())

        transitions = list(machine_runner.run_iter('start'))
        self.assertEqual((runner._GAME_OVER, st.FAILURE), transitions[-1])
        self.assertEqual(1, len(memory.failures))
开发者ID:LiuZhiyan,项目名称:taskflow,代码行数:12,代码来源:test_runner.py


示例18: test_graph_nested_graph

    def test_graph_nested_graph(self):
        a, b, c, d, e, f, g = test_utils.make_many(7)
        flo = gf.Flow("test")
        flo.add(a, b, c, d)

        flo2 = gf.Flow('test2')
        flo2.add(e, f, g)
        flo.add(flo2)

        compilation = compiler.PatternCompiler(flo).compile()
        g = compilation.execution_graph
        self.assertEqual(7, len(g))
        self.assertEqual(0, g.number_of_edges())
开发者ID:TheSriram,项目名称:taskflow,代码行数:13,代码来源:test_compile.py


示例19: test_builder_automatic_process

    def test_builder_automatic_process(self):
        flow = lf.Flow("root")
        tasks = test_utils.make_many(1, task_cls=test_utils.TaskNoRequiresNoReturns)
        flow.add(*tasks)

        rt = self._make_runtime(flow, initial_state=st.RUNNING)
        machine, memory = rt.runner.build()
        self.assertTrue(rt.runner.runnable())

        transitions = list(machine.run_iter("start"))
        self.assertEqual((runner._UNDEFINED, st.RESUMING), transitions[0])
        self.assertEqual((runner._GAME_OVER, st.SUCCESS), transitions[-1])
        self.assertEqual(st.SUCCESS, rt.storage.get_atom_state(tasks[0].name))
开发者ID:zasimov,项目名称:taskflow,代码行数:13,代码来源:test_runner.py


示例20: test_run_iterations_failure

    def test_run_iterations_failure(self):
        flow = lf.Flow("root")
        tasks = test_utils.make_many(1, task_cls=test_utils.NastyFailingTask)
        flow.add(*tasks)

        runtime, machine, memory, machine_runner = self._make_machine(flow, initial_state=st.RUNNING)

        transitions = list(machine_runner.run_iter(builder.START))
        prior_state, new_state = transitions[-1]
        self.assertEqual(st.FAILURE, new_state)
        self.assertEqual(1, len(memory.failures))
        failure = memory.failures[0]
        self.assertTrue(failure.check(RuntimeError))
        self.assertEqual(st.REVERT_FAILURE, runtime.storage.get_atom_state(tasks[0].name))
开发者ID:junneyang,项目名称:taskflow,代码行数:14,代码来源:test_builder.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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