Created
July 11, 2017 15:22
-
-
Save drewbanin/58e8ecfae93c930624f17517799821f2 to your computer and use it in GitHub Desktop.
This script shows the ancestors for each node in a dbt graph
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
import sys | |
import networkx as nx | |
if len(sys.argv) != 2: | |
print("Usage: {} [path/to/graph.gpickle]".format(sys.argv[0])) | |
sys.exit(1) | |
filename = sys.argv[1] | |
graph = nx.read_gpickle(sys.argv[1]) | |
for node in graph.node: | |
print("{}".format(node)) | |
for anc in nx.ancestors(graph, node): | |
print(" {}".format(anc)) | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment