Spaces:
Running
Running
Download code/land_fetch.py from ArthurZ/transformers-triage: direct link, hf CLI and curl.
- Browser
- Download file 1.18 kB
-
https://huggingface.co/spaces/ArthurZ/transformers-triage/resolve/main/code/land_fetch.py
- Command line
-
hf download hf://spaces/ArthurZ/transformers-triage/code/land_fetch.py
-
curl -L -o land_fetch.py https://huggingface.co/spaces/ArthurZ/transformers-triage/resolve/main/code/land_fetch.py
1.18 kB
| 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') | |