本文整理汇总了Python中doit.control.TaskDispatcher._gen_node方法的典型用法代码示例。如果您正苦于以下问题:Python TaskDispatcher._gen_node方法的具体用法?Python TaskDispatcher._gen_node怎么用?Python TaskDispatcher._gen_node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类doit.control.TaskDispatcher
的用法示例。
在下文中一共展示了TaskDispatcher._gen_node方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cyclic
# 需要导入模块: from doit.control import TaskDispatcher [as 别名]
# 或者: from doit.control.TaskDispatcher import _gen_node [as 别名]
def test_cyclic(self):
tasks = {'t1': Task('t1', None),
't2': Task('t2', None)
}
td = TaskDispatcher(tasks, [], None)
n1 = td._gen_node(None, 't1')
n2 = td._gen_node(n1, 't2')
pytest.raises(InvalidDodoFile, td._gen_node, n2, 't1')
示例2: test_already_created
# 需要导入模块: from doit.control import TaskDispatcher [as 别名]
# 或者: from doit.control.TaskDispatcher import _gen_node [as 别名]
def test_already_created(self):
tasks = {'t1': Task('t1', None),
't2': Task('t2', None)
}
td = TaskDispatcher(tasks, [], None)
n1 = td._gen_node(None, 't1')
td._gen_node(n1, 't2')
assert None == td._gen_node(None, 't1')
示例3: test_to_run_none
# 需要导入模块: from doit.control import TaskDispatcher [as 别名]
# 或者: from doit.control.TaskDispatcher import _gen_node [as 别名]
def test_to_run_none(self):
tasks = {'t1': Task('t1', None),
}
td = TaskDispatcher(tasks, [], None)
td._gen_node(None, 't1') # t1 was already created
to_run = ['t1']
assert None == td._get_next_node([], to_run)
assert [] == to_run
示例4: test_to_run
# 需要导入模块: from doit.control import TaskDispatcher [as 别名]
# 或者: from doit.control.TaskDispatcher import _gen_node [as 别名]
def test_to_run(self):
tasks = {'t1': Task('t1', None, task_dep=['t2']),
't2': Task('t2', None),
}
td = TaskDispatcher(tasks, [], None)
to_run = ['t2', 't1']
td._gen_node(None, 't1') # t1 was already created
got = td._get_next_node([], to_run)
assert isinstance(got, ExecNode)
assert 't2' == got.task.name
assert [] == to_run
示例5: test_delayed_creation_sub_task
# 需要导入模块: from doit.control import TaskDispatcher [as 别名]
# 或者: from doit.control.TaskDispatcher import _gen_node [as 别名]
def test_delayed_creation_sub_task(self):
# usually a repeated loader is replaced by the real task
# when it is first executed, the problem arises when the
# the expected task is not actually created
def creator():
yield Task('t1:foo', None)
yield Task('t1:bar', None)
delayed_loader = DelayedLoader(creator, executed='t2')
tasks = {
't1': Task('t1', None, loader=delayed_loader),
't2': Task('t2', None),}
# simulate a sub-task from delayed created added to task_list
tasks['t1:foo'] = Task('t1:foo', None, loader=delayed_loader)
tasks['t1:xxx'] = Task('t1:xxx', None, loader=delayed_loader)
delayed_loader.basename = 't1'
td = TaskDispatcher(tasks, [], None)
n1 = td._gen_node(None, 't1:foo')
gen = td._add_task(n1)
# first returned node is `t2` because it is an implicit task_dep
n1b = next(gen)
assert n1b.task.name == 't2'
# wait until t2 is finished
n1c = next(gen)
assert n1c == 'wait'
# after t2 is done, generator is reseted
n1b.run_status = 'successful'
td._update_waiting(n1b)
n1d = next(gen)
assert n1d == "reset generator"
assert 't1:foo' in td.tasks
assert 't1:bar' in td.tasks
# finish with t1:foo
gen2 = td._add_task(n1)
n1.reset_task(td.tasks[n1.task.name], gen2)
n2 = next(gen2)
assert n2.name == 't1:foo'
pytest.raises(StopIteration, next, gen2)
# try non-existent t1:xxx
n3 = td._gen_node(None, 't1:xxx')
gen3 = td._add_task(n3)
# ? should raise a runtime error?
assert next(gen3) == 'reset generator'
示例6: test_delayed_creation
# 需要导入模块: from doit.control import TaskDispatcher [as 别名]
# 或者: from doit.control.TaskDispatcher import _gen_node [as 别名]
def test_delayed_creation(self):
def creator():
yield Task('foo', None, loader=DelayedLoader(lambda : None))
delayed_loader = DelayedLoader(creator, executed='t2')
tasks = {'t1': Task('t1', None, loader=delayed_loader),
't2': Task('t2', None),
}
td = TaskDispatcher(tasks, [], None)
n1 = td._gen_node(None, 't1')
gen = td._add_task(n1)
# first returned node is `t2` because it is an implicit task_dep
n2 = next(gen)
assert n2.task.name == 't2'
# wait until t2 is finished
n3 = next(gen)
assert n3 == 'wait'
# after t2 is done, generator is reseted
td._update_waiting(n2)
n4 = next(gen)
assert n4 == "reset generator"
# recursive loader is preserved
assert isinstance(td.tasks['foo'].loader, DelayedLoader)
pytest.raises(AssertionError, next, gen)
示例7: test_calc_dep
# 需要导入模块: from doit.control import TaskDispatcher [as 别名]
# 或者: from doit.control.TaskDispatcher import _gen_node [as 别名]
def test_calc_dep(self):
def calc_intermediate():
return {'file_dep': ['intermediate']}
tasks = {'t1': Task('t1', None, calc_dep=['t2']),
't2': Task('t2', [calc_intermediate]),
't3': Task('t3', None, targets=['intermediate']),
}
td = TaskDispatcher(tasks, {'intermediate': 't3'}, None)
n1 = td._gen_node(None, 't1')
n2 = n1.step()
assert tasks['t2'] == n2.task
assert 'wait' == n1.step()
# execute t2 to process calc_dep
tasks['t2'].execute()
td.nodes['t2'].run_status = 'done'
td._update_waiting(n2)
n3 = n1.step()
assert tasks['t3'] == n3.task
assert 'intermediate' in tasks['t1'].file_dep
assert 't3' in tasks['t1'].task_dep
# t3 was added by calc dep
assert 'wait' == n1.step()
n3.run_status = 'done'
td._update_waiting(n3)
assert tasks['t1'] == n1.step()
示例8: test_regex_group_already_created
# 需要导入模块: from doit.control import TaskDispatcher [as 别名]
# 或者: from doit.control.TaskDispatcher import _gen_node [as 别名]
def test_regex_group_already_created(self):
# this is required to avoid loading more tasks than required, GH-#60
def creator1():
yield Task('foo1', None, targets=['tgt1'])
delayed_loader1 = DelayedLoader(creator1, target_regex='tgt.*')
def creator2(): # pragma: no cover
yield Task('foo2', None, targets=['tgt2'])
delayed_loader2 = DelayedLoader(creator2, target_regex='tgt.*')
t1 = Task('t1', None, loader=delayed_loader1)
t2 = Task('t2', None, loader=delayed_loader2)
tc = TaskControl([t1, t2])
selection = tc._filter_tasks(['tgt1'])
assert ['_regex_target_tgt1:t1', '_regex_target_tgt1:t2'] == selection
td = TaskDispatcher(tc.tasks, tc.targets, selection)
n1 = td._gen_node(None, '_regex_target_tgt1:t1')
gen = td._add_task(n1)
# delayed loader executed, so generator is reset
n1b = next(gen)
assert n1b == "reset generator"
# manually reset generator
n1.reset_task(td.tasks[n1.task.name], td._add_task(n1))
# get the delayed created task
gen1b = n1.generator # n1 generator was reset / replaced
# get t1 because of its target was a file_dep of _regex_target_tgt1
n1c = next(gen1b)
assert n1c.task.name == 'foo1'
# get internal created task
n1c.run_status = 'done'
td._update_waiting(n1c)
n1d = next(gen1b)
assert n1d.name == '_regex_target_tgt1:t1'
## go for second selected task
n2 = td._gen_node(None, '_regex_target_tgt1:t2')
gen2 = td._add_task(n2)
# loader is not executed because target t1 was already found
pytest.raises(StopIteration, next, gen2)
示例9: test_ready
# 需要导入模块: from doit.control import TaskDispatcher [as 别名]
# 或者: from doit.control.TaskDispatcher import _gen_node [as 别名]
def test_ready(self):
tasks = {'t1': Task('t1', None),
't2': Task('t2', None),
}
td = TaskDispatcher(tasks, [], None)
n1 = td._gen_node(None, 't1')
ready = deque([n1])
assert n1 == td._get_next_node(ready, ['t2'])
assert 0 == len(ready)
示例10: test_task_deps_no_wait
# 需要导入模块: from doit.control import TaskDispatcher [as 别名]
# 或者: from doit.control.TaskDispatcher import _gen_node [as 别名]
def test_task_deps_no_wait(self):
tasks = {'t1': Task('t1', None, task_dep=['t2']),
't2': Task('t2', None),
}
td = TaskDispatcher(tasks, [], None)
n1 = td._gen_node(None, 't1')
n2 = td._gen_node(None, 't2')
n2.run_status = 'done'
gen = td._add_task(n1)
assert tasks['t1'] == next(gen)
示例11: test_deps_not_ok
# 需要导入模块: from doit.control import TaskDispatcher [as 别名]
# 或者: from doit.control.TaskDispatcher import _gen_node [as 别名]
def test_deps_not_ok(self):
tasks = {'t1': Task('t1', None),
't2': Task('t2', None),
}
td = TaskDispatcher(tasks, [], None)
n1 = td._gen_node(None, 't1')
n2 = td._gen_node(None, 't2')
n2.run_status = 'failure'
td._node_add_wait_run(n1, ['t2'])
assert n1.bad_deps
示例12: test_none
# 需要导入模块: from doit.control import TaskDispatcher [as 别名]
# 或者: from doit.control.TaskDispatcher import _gen_node [as 别名]
def test_none(self):
tasks = {'t1': Task('t1', None),
't2': Task('t2', None),
}
td = TaskDispatcher(tasks, [], None)
n1 = td._gen_node(None, 't1')
n2 = td._gen_node(None, 't2')
n2.run_status = 'done'
td._node_add_wait_run(n1, ['t2'])
assert not n1.wait_run
示例13: test_task_deps_already_created
# 需要导入模块: from doit.control import TaskDispatcher [as 别名]
# 或者: from doit.control.TaskDispatcher import _gen_node [as 别名]
def test_task_deps_already_created(self):
tasks = {'t1': Task('t1', None, task_dep=['t2']),
't2': Task('t2', None),
}
td = TaskDispatcher(tasks, [], None)
n1 = td._gen_node(None, 't1')
n2 = td._gen_node(None, 't2')
assert 'wait' == n1.step()
assert 'wait' == n1.step()
#tasks['t2'].run_status = 'done'
td._update_waiting(n2)
assert tasks['t1'] == n1.step()
示例14: test_wait_select
# 需要导入模块: from doit.control import TaskDispatcher [as 别名]
# 或者: from doit.control.TaskDispatcher import _gen_node [as 别名]
def test_wait_select(self):
tasks = {'t1': Task('t1', None, task_dep=['t2']),
't2': Task('t2', None),
}
td = TaskDispatcher(tasks, [], None)
n2 = td._gen_node(None, 't2')
n2.wait_select = True
n2.run_status = 'run'
td.waiting.add(n2)
td._update_waiting(n2)
assert False == n2.wait_select
assert deque([n2]) == td.ready
示例15: test_setup_task__run
# 需要导入模块: from doit.control import TaskDispatcher [as 别名]
# 或者: from doit.control.TaskDispatcher import _gen_node [as 别名]
def test_setup_task__run(self):
tasks = {'t1': Task('t1', None, setup=['t2']),
't2': Task('t2', None),
}
td = TaskDispatcher(tasks, [], None)
n1 = td._gen_node(None, 't1')
gen = td._add_task(n1)
assert tasks['t1'] == next(gen) # first time (just select)
assert 'wait' == next(gen) # wait for select result
n1.run_status = 'run'
assert tasks['t2'] == next(gen).task # send setup task
assert 'wait' == next(gen)
assert tasks['t1'] == next(gen) # second time