# Edge Utilities


# unmapped

class

prefect.utilities.edges.unmapped

(value)[source]

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.
Example:

    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

class

prefect.utilities.edges.mapped

(value)[source]

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.
Example:

    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

class

prefect.utilities.edges.flatten

(value)[source]

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.
Example:

    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 n/a
on February 23, 2022 at 19:26 UTC