set_logger

logger
logging.Logger
required

Sets a logger for this DAG. Throws error if not a valid logger.

is_node

node
Node
required

The node to check.

Returns boolean indicating whether the node is a Node.

add_node

node
Node
required

The node to set as the root. Adds to nodes if not added already. Throws error if not a valid node.

remove_node

node
Node
required

The node to remove. Throws errors if not a valid node or if the node is not in the graph.

get_node

node_id
str
required

The node id to get. Throws error if not a valid id or if node not in graph.

add_edge

from_node
Node
required

The node to add the edge from. Throws error if not a valid node or if node not in graph.

to_node
Node
required

The node to add the edge to. Throws error if not a valid node, if node not in graph, or if there’s a cycle.

fn
Callable[[dict[str:type]], dict[str:type]]

A function to transform the outputs of from_node for to_node. Defaults to lambda x: x.

remove_edge

from_node
Node
required

The node to add the edge from. Throws error if not a valid node or if node not in graph.

to_node
Node
required

The node to add the edge to. Throws error if not a valid node, if node not in graph, or if there’s a cycle.

execute

Topologically sorts the graph and runs it.

init_source_nodes
dict[str:type]
required

A dictionary of node_id keys -> its initial args and kwargs, which will be set to execute_args once the DAG runs.

    init_source_nodes = {
        node_1.get_id(): {
            "kwargs": {
                "limit": 1
            }
        },
        node_2.get_id(): {
            "kwargs": {
                "color": "red",
                "fill_in": False
            }
        },
    }