-
Notifications
You must be signed in to change notification settings - Fork 1
/
submit_final.py
38 lines (27 loc) · 1.14 KB
/
submit_final.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import json
import glob
import time
import subprocess
import os
def find_best_submissions():
best_submissions = {}
for path in glob.glob("/home/takiba/Dropbox/ICFPC2022/runs/*.json"):
s = json.load(open(path))
pid = s["problem_id"]
if (s["problem_id"] not in best_submissions) or s["cost"] < best_submissions[pid][0]["cost"]:
best_submissions[pid] = (s, path)
return best_submissions
def main(force_submit_best=False, dryrun=False):
best_submissions = find_best_submissions()
for problem_id, (submission, path) in sorted(best_submissions.items()):
print(f"{problem_id:3d} {submission['cost']:8d} {path}") # {submission['id']:5d}
for problem_id, (submission, json_path) in sorted(best_submissions.items()):
isl_path = os.path.splitext(json_path)[0] + ".isl"
cmd = f'curl -X POST --data-urlencode isl@{isl_path} -d problem_id={problem_id} "https://icfpc.sx9.jp/scvzcaae/submit"'
print(cmd)
if not dryrun:
subprocess.run(cmd, shell=True)
time.sleep(3)
if __name__ == "__main__":
import fire # pip install fire
fire.Fire(main)