Spaces:
Running
Running
File size: 1,114 Bytes
cc857c8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import json, subprocess, time
Q = """query($cursor:String){repository(owner:"huggingface",name:"transformers"){
issues(states:OPEN, first:50, after:$cursor, filterBy:{since:"2000-01-01T00:00:00Z"}){ totalCount pageInfo{hasNextPage endCursor}
nodes{ number title createdAt updatedAt authorAssociation author{login} labels(first:10){nodes{name}}
reactions{totalCount} comments(last:2){totalCount nodes{author{login} authorAssociation createdAt body}} }}}}"""
items, cursor, t0 = [], None, time.time()
while True:
args = ["gh", "api", "graphql", "-f", f"query={Q}"] + (["-f", f"cursor={cursor}"] if cursor else [])
for _ in range(5):
r = subprocess.run(args, capture_output=True, text=True)
if r.returncode == 0: break
time.sleep(10)
d = json.loads(r.stdout)["data"]["repository"]["issues"]
items += d["nodes"]; el = time.time() - t0
print(f"[{len(items)}/{d['totalCount']}] | elapsed {el:.0f}s", flush=True)
if not d["pageInfo"]["hasNextPage"]: break
cursor = d["pageInfo"]["endCursor"]
json.dump(items, open("issues3.json", "w")); print("done", flush=True)
|