# Edge
# Edge
class
prefect.core.edge.Edge
(upstream_task, downstream_task, key=None, mapped=None, flattened=None, flow=None)[source]Edges represent connections between Tasks.
At a minimum, an edge links an upstream_task
and a downstream_task
indicating that the downstream task shouldn't attempt to run until the upstream task is complete.
In addition, edges can specify a key that describe how upstream results are passed to the downstream task.
Args:
upstream_task (Any)
: the task that must run before thedownstream_task
. It will be converted to as task withprefect.utilities.tasks.as_task()
downstream_task (Any)
: the task that will be run after theupstream_task
. The upstream task state is passed to the downstream task's trigger function to determine whether the downstream task should run. It will be converted to as task withprefect.utilities.tasks.as_task()
key (str, optional)
: Passing a key indicates that the upstream result should be passed to the downstream task as a keyword argument given bykey
.mapped (bool, optional)
: boolean indicating whether this edge represents a downstream mapped task; defaults toFalse
flattened (bool, optional)
: boolean indicating whether this edge represents an upstream flattened task; defaults toFalse </li><li class="args">
flow (prefect.Flow, optional): a flow object that will be used if either the
upstream_taskor
downstream_task` is a collection that needs to be bound to a flow. If not provided, the context flow will be used instead.
In general, Edges are created and handled in the background by the Flow class and will not be directly instantiated by users.
Example:
from prefect import *
from prefect.core import Edge
class Add(Task):
def run(self, x):
return x + 1
class Number(Task):
def run(self):
return 2
# passes the result of the Number() task to Add() as 'x'
edge = Edge(Number(), Add(), key='x')
methods: |
---|
prefect.core.edge.Edge.serialize ()[source] |
Represents the Edge as a dict. |
This documentation was auto-generated from commit bd9182e
on July 31, 2024 at 18:02 UTC