Spaces:
Running
Running
Download code/sweep2.py from ArthurZ/transformers-triage: direct link, hf CLI and curl.
- Browser
- Download file 1.28 kB
-
https://huggingface.co/spaces/ArthurZ/transformers-triage/resolve/main/code/sweep2.py
- Command line
-
hf download hf://spaces/ArthurZ/transformers-triage/code/sweep2.py
-
curl -L -o sweep2.py https://huggingface.co/spaces/ArthurZ/transformers-triage/resolve/main/code/sweep2.py
1.28 kB
| import json, subprocess, sys, time | |
| Q = """ | |
| query($cursor:String){repository(owner:"huggingface",name:"transformers"){ | |
| pullRequests(states:OPEN, first:30, after:$cursor){ totalCount pageInfo{hasNextPage endCursor} | |
| nodes{ number title createdAt updatedAt isDraft baseRefName mergeable reviewDecision additions deletions | |
| author{login} authorAssociation labels(first:10){nodes{name}} | |
| commits(last:1){nodes{commit{committedDate}}} | |
| files(first:100){totalCount nodes{path}} | |
| comments(last:3){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"]["pullRequests"] | |
| items += d["nodes"]; el = time.time() - t0 | |
| print(f"[{len(items)}/{d['totalCount']}] | elapsed {el:.0f}s | eta ~{el/len(items)*(d['totalCount']-len(items)):.0f}s", flush=True) | |
| if not d["pageInfo"]["hasNextPage"]: break | |
| cursor = d["pageInfo"]["endCursor"] | |
| json.dump(items, open(sys.argv[1], "w")) | |
| print("done", flush=True) | |