def test_evaluation_propagated_upstream(): visited = [] def func(txt): visited.append(txt) return txt pg = PortGraph() n = FuncNode(func) pg.add_actor(n, 0) pg.add_actor(n, 1) pg.connect(pg.out_port(0, 'txt'), pg.in_port(1, 'txt')) algo = BruteEvaluation(pg) ws = WorkflowState(pg) env = EvaluationEnvironment() ws.store_param(pg.in_port(0, 'txt'), "txt", 0) algo.eval(env, ws, 0) assert len(visited) == 1 algo.eval(env, ws, 1) assert len(visited) == 2 env.new_execution() algo.eval(env, ws, 1) assert len(visited) == 4
def test_env_clear_free_ids(): env = EvaluationEnvironment() eid0 = env.current_execution() env.new_execution() env.clear() assert env.current_execution() == eid0
def test_evaluation_do_not_reevaluate_same_node(): visited = [] def func(): visited.append("yes") pg = PortGraph() n = FuncNode(func) pg.add_actor(n, 0) pg.add_actor(n, 1) env = EvaluationEnvironment() algo = BruteEvaluation(pg) ws = WorkflowState(pg) algo.eval(env, ws, 0) assert len(visited) == 1 algo.eval(env, ws, 1) assert len(visited) == 2 algo.eval(env, ws, 0) assert len(visited) == 2 env.new_execution() algo.eval(env, ws, 0) assert len(visited) == 3
def test_lazy_always_reevaluate_non_lazy_nodes(): evaluated = [] def func(txt): evaluated.append(txt) return txt pg = PortGraph() vid = pg.add_actor(FuncNode(func)) pg.actor(vid).set_lazy(False) algo = LazyEvaluation(pg) env = EvaluationEnvironment() ws = WorkflowState(pg) ws.store_param(pg.in_port(vid, 'txt'), 'toto', env.current_execution()) algo.eval(env, ws) assert len(evaluated) == 1 env.new_execution() algo.eval(env, ws) assert len(evaluated) == 2
def test_env_new_execution(): env = EvaluationEnvironment() eid0 = env.current_execution() env.new_execution() assert env.current_execution() != eid0