Skip to content

Instantly share code, notes, and snippets.

@drewbanin
Created July 11, 2017 15:22
Show Gist options
  • Save drewbanin/58e8ecfae93c930624f17517799821f2 to your computer and use it in GitHub Desktop.
Save drewbanin/58e8ecfae93c930624f17517799821f2 to your computer and use it in GitHub Desktop.
This script shows the ancestors for each node in a dbt graph
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