def test_multiple_annotations_applied(self): with Flow("test") as flow: z = add(x=edges.mapped(edges.flatten([[1], [2, 3]])), y=edges.unmapped(100)) state = flow.run() assert state.result[z].result == [101, 102, 103]
def test_map_can_handle_nonkeyed_nonmapped_upstreams_and_mapped_args_2(executor): # identical to test_map_can_handle_nonkeyed_nonmapped_upstreams_and_mapped_args # but uses the `mapped()` annotation instead of calling .map() ii = IdTask() ll = ListTask() with Flow(name="test") as f: res = ll(start=mapped(ll()), upstream_tasks=[ii(5)]) s = f.run(executor=executor) m = s.result[res] assert s.is_successful() assert isinstance(m.map_states, list) assert len(m.result) == 3 assert m.result == [[1 + i, 2 + i, 3 + i] for i in range(3)]
def test_mapped_applied(self): with Flow("test") as flow: z = add(x=edges.mapped([1, 2, 3]), y=100) state = flow.run() assert state.result[z].result == [101, 102, 103]
def test_multiple_annotations(self): ea = edges.mapped(edges.flatten(edges.unmapped(edges.mapped(Task())))) assert ea.annotations == {"flattened": True, "mapped": True}
def test_mapped(self): ea = edges.mapped(Task()) assert ea.annotations == {"mapped": True}
def test_nested_annotation(self): e = Edge(edges.flatten(edges.mapped(Task())), Task()) assert e.flattened is True assert e.mapped is True
def test_mapped_annotation_takes_precedance_over_kwarg(self): e = Edge(edges.mapped(Task()), Task(), mapped=False) assert e.mapped is True
def test_mapped(self): e = Edge(edges.mapped(Task()), Task()) assert e.mapped is True