Spaces:
Running
Running
File size: 1,178 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, sys
def run(kind, extra):
Q = """query($c:String){repository(owner:"huggingface",name:"transformers"){%s(states:OPEN,first:40,after:$c){totalCount pageInfo{hasNextPage endCursor}
nodes{number title createdAt updatedAt author{login} authorAssociation labels(first:10){nodes{name}} reactions{totalCount} comments{totalCount} %s}}}}""" % (kind, extra)
out, c = [], None
while True:
a = ['gh','api','graphql','-f',f'query={Q}'] + (['-f',f'c={c}'] if c else [])
for _ in range(5):
r = subprocess.run(a, capture_output=True, text=True, timeout=120)
if r.returncode == 0: break
time.sleep(10)
d = json.loads(r.stdout)['data']['repository'][kind]; out += d['nodes']
print(f'[{kind} {len(out)}/{d["totalCount"]}]', flush=True)
if not d['pageInfo']['hasNextPage']: return out
c = d['pageInfo']['endCursor']
PR = 'isDraft mergeable reviewDecision additions deletions changedFiles files(first:60){nodes{path}} reviewRequests(first:5){totalCount}'
json.dump({'issues': run('issues', ''), 'prs': run('pullRequests', PR)}, open('land.json','w'))
print('done')
|