Skip to content

Commit 412f1e4

Browse files
author
Rayce Rossum
committed
Add python script and branch_test image end-to-end from hackathon day 1
1 parent ddb83de commit 412f1e4

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*ipynb_checkpoints*
22
*DS_Store*
33
*Rhistory*
4+
*.json

imgs/.gitignore

Whitespace-only changes.

imgs/branch_test.png

14.6 KB
Loading

src/big_cloud_scratch.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import pandas_gbq
2+
import networkx as nx
3+
import matplotlib.pyplot as plt
4+
5+
def query_ght(queryString):
6+
# https://bigquery.cloud.google.com/dataset/ghtorrent-bq:ght
7+
query_result_df = pandas_gbq.read_gbq(queryString)
8+
9+
return query_result_df
10+
11+
def plot_commits(commits):
12+
source_target_commits = commits[["cp_parent_id", "c_id"]].dropna().astype("int64")
13+
source_target_commits.columns = ["source", "target"]
14+
15+
g = nx.from_pandas_edgelist(source_target_commits)
16+
nx.draw_kamada_kawai(g, alpha=0.5, node_color='blue', node_size = 2)
17+
18+
if __name__ == '__main__':
19+
commitQuery = """
20+
select
21+
c.id as c_id,
22+
p.id as p_id,
23+
cp.commit_id as cp_commit_id,
24+
cp.parent_id as cp_parent_id
25+
from `ghtorrent-bq.ght.commits` c
26+
left join `ghtorrent-bq.ght.projects` p on (p.id = c.project_id)
27+
left join `ghtorrent-bq.ght.commit_parents` cp on (cp.commit_id = c.id)
28+
where (p.id = 12873840)
29+
limit 10000
30+
"""
31+
32+
commits = query_ght(commitQuery)
33+
branchPlot = plot_commits(commits)
34+
plt.savefig("./imgs/branch_test")

0 commit comments

Comments
 (0)