Spaces:
Running
Running
Download code/rq_fetch.py from ArthurZ/transformers-triage: direct link, hf CLI and curl.
- Browser
- Download file 1.48 kB
-
https://huggingface.co/spaces/ArthurZ/transformers-triage/resolve/main/code/rq_fetch.py
- Command line
-
hf download hf://spaces/ArthurZ/transformers-triage/code/rq_fetch.py
-
curl -L -o rq_fetch.py https://huggingface.co/spaces/ArthurZ/transformers-triage/resolve/main/code/rq_fetch.py
1.48 kB
| import json, subprocess, time | |
| rows = [r for r in json.load(open('land_rows.json')) if r['k'] == 'PR' and r['status'] != 'draft'] | |
| nums = [r['n'] for r in rows]; out = {}; t0 = time.time() | |
| F = '''number title createdAt updatedAt isDraft mergeable reviewDecision author{login} authorAssociation baseRefName | |
| files(first:40){nodes{path}} | |
| commits(last:1){nodes{commit{committedDate statusCheckRollup{state}}}} | |
| reviews(last:20){nodes{author{login} authorAssociation state submittedAt}} | |
| reviewRequests(first:5){nodes{requestedReviewer{... on User{login} ... on Team{name}}}} | |
| comments(last:6){nodes{author{login} authorAssociation createdAt}} | |
| timelineItems(last:15,itemTypes:[REVIEW_REQUESTED_EVENT,READY_FOR_REVIEW_EVENT]){nodes{__typename ... on ReviewRequestedEvent{createdAt requestedReviewer{... on User{login}}} ... on ReadyForReviewEvent{createdAt}}}''' | |
| for i in range(0, len(nums), 15): | |
| part = nums[i:i+15] | |
| q = '{repository(owner:"huggingface",name:"transformers"){' + ' '.join(f'n{n}: pullRequest(number:{n}){{{F}}}' for n in part) + '}}' | |
| for _ in range(5): | |
| r = subprocess.run(['gh', 'api', 'graphql', '-f', 'query=' + q], capture_output=True, text=True, timeout=120) | |
| if r.returncode == 0: break | |
| time.sleep(10) | |
| d = json.loads(r.stdout)['data']['repository'] | |
| for n in part: out[n] = d[f'n{n}'] | |
| print(f'[{len(out)}/{len(nums)}] | elapsed {time.time()-t0:.0f}s', flush=True) | |
| json.dump(out, open('rq.json', 'w')); print('done') | |