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