Skip to content

DAG edge adder and other DAG operations #8

Description

@thorwhalen

DAG.__getitem__ covers the functionality of removing nodes since it extracts sub-graphs.

Maybe there's a need, still of having a remove_node (func or var) interface to the same functionality?

But what about other useful DAG operations. Adding/merging DAGs, compressing sub-DAGs into one node (maybe only useful for display?), etc.

Perhaps the add_edge one is a good reusable one.
For example, when making a pipeline (function composition), were' really just saying "add edges between every element of this list of functions, binding the previous function's output to the the first argument of the next function.

def add_edge_from(dag, func, from_node, to_param=None, ...):
    """Adds an edge sources the to_param argument from the from_node (var_node or func_node)"""

The ... suggest that we'll probably want some other defaulted control arguments (such as a connection_policy one).

The function would return a (new) dag where a new func node was added which binds the data of from_node to the to_param input of func.
to_param is optional, and some connection_policy could determine how to figure it out.
For example, when making pipelines (function composition) that policy would say "just take the first argument" -- but we
could envision some utility for binding to a parameter based on the annotations of that parameter and the return_annotation of the function producing the from_node data.

Note: The language we'll use here is "by reference", but the implementation is, at this point, "by value" (e.g. dag[slice] RETURNs a transformed dag but doesn't transform the dag itself).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions