# Edge Utilities
# unmapped
A container for specifying that a task should not be mapped over when called with task.map.
Args:
value (Any): the task or value to mark as "unmapped"; if not a Task subclass, Prefect will attempt to convert it to one when the edge is created.
    from prefect import Flow, Task, unmapped
    class AddTask(Task):
        def run(self, x, y):
            return x + y
    class ListTask(Task):
        def run(self):
            return [1, 2, 3]
    with Flow("My Flow"):
        add = AddTask()
        ll = ListTask()
        result = add.map(x=ll, y=unmapped(5), upstream_tasks=[unmapped(Task())])
# mapped
A container for specifying that a task should be mapped over when supplied as the input to another task.
Args:
value (Any): the task or value to mark as "mapped"; if not a Task subclass, Prefect will attempt to convert it to one when the edge is created.
    from prefect import Flow, Task, mapped
    class AddTask(Task):
        def run(self, x, y):
            return x + y
    class ListTask(Task):
        def run(self):
            return [1, 2, 3]
    with Flow("My Flow"):
        add = AddTask()
        ll = ListTask()
        result = add(x=mapped(ll), y=5)
# flatten
A container for specifying that a task's output should be flattened before being passed to another task.
Args:
value (Any): the task or value to mark as "flattened"; if not a Task subclass, Prefect will attempt to convert it to one when the edge is created.
    from prefect import Flow, Task, flatten
    class Add(Task):
        def run(self, x):
            return x + 100
    class NestedListTask(Task):
        def run(self):
            return [[1], [2, 3]]
    with Flow("My Flow"):
        add = Add()
        ll = NestedListTask()
        result = add.map(x=flatten(ll))
    # result represents [101, 102, 103]
This documentation was auto-generated from commit bd9182e 
on July 31, 2024 at 18:02 UTC
← Diagnostics Executors →