Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CT-3144 Fix test edges type filter on Graph #8696

Merged
merged 8 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20230922-223313.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Fixes test type edges filter
time: 2023-09-22T22:33:13.200662+02:00
custom:
Author: renanleme
Issue: "8692"
13 changes: 6 additions & 7 deletions core/dbt/graph/graph.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Set, Iterable, Iterator, Optional, NewType
from itertools import product
import networkx as nx # type: ignore
from functools import partial

from dbt.exceptions import DbtInternalError

Expand Down Expand Up @@ -42,16 +43,14 @@ def descendants(self, node: UniqueId, max_depth: Optional[int] = None) -> Set[Un
return {child for _, child in nx.bfs_edges(filtered_graph, node, depth_limit=max_depth)}

def exclude_edge_type(self, edge_type_to_exclude):
return nx.restricted_view(
return nx.subgraph_view(
self.graph,
nodes=[],
edges=(
(a, b)
for a, b in self.graph.edges
if self.graph[a][b].get("edge_type") == edge_type_to_exclude
),
filter_edge=partial(self.filter_edges_by_type, edge_type=edge_type_to_exclude),
)

def filter_edges_by_type(self, first_node, second_node, edge_type):
return self.graph.get_edge_data(first_node, second_node).get("edge_type") != edge_type

def select_childrens_parents(self, selected: Set[UniqueId]) -> Set[UniqueId]:
ancestors_for = self.select_children(selected) | selected
return self.select_parents(ancestors_for) | ancestors_for
Expand Down