-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove upstream dependencies that have no outputs (#107)
* remove upstream dependencies that have no outputs * add regression test for Graph dependencies
- Loading branch information
1 parent
99ce749
commit 1354dcf
Showing
2 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from merlin.dag import Graph, Node | ||
from merlin.dag.selector import ColumnSelector | ||
from merlin.schema.schema import ColumnSchema, Schema | ||
|
||
|
||
def test_remove_dependencies(): | ||
# Construct a simple graph with a structure like: | ||
# ["y"] ----> ["x", "y"] ---\ | ||
# --- > ["o"] | ||
# ["z"] --------------------/ | ||
|
||
# When removing "y", we should see all of the dependencies | ||
# and parents removed from the list of leaf nodes. | ||
|
||
dep_node = Node(selector=ColumnSelector(["y"])) | ||
dep_node.input_schema = Schema([ColumnSchema("y")]) | ||
dep_node.output_schema = Schema([ColumnSchema("y")]) | ||
|
||
node_xy = Node(selector=ColumnSelector(["x", "y"])) | ||
node_xy.input_schema = Schema([ColumnSchema("x"), ColumnSchema("y")]) | ||
node_xy.output_schema = Schema([ColumnSchema("z")]) | ||
|
||
plus_node = Node(selector=ColumnSelector(["z", "y"])) | ||
plus_node.input_schema = Schema([ColumnSchema("y"), ColumnSchema("z")]) | ||
plus_node.output_schema = Schema([ColumnSchema("o")]) | ||
plus_node.add_parent(dep_node) | ||
plus_node.add_parent(node_xy) | ||
plus_node.add_dependency(dep_node) | ||
|
||
graph_with_dependency = Graph(plus_node) | ||
assert len(graph_with_dependency.leaf_nodes) == 2 | ||
graph_with_dependency.remove_inputs(["y"]) | ||
assert len(graph_with_dependency.leaf_nodes) == 1 |