Download scripts/r5_testpass2/tp2_make_jobs.py from treoa/turkic-ocr-code: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/treoa/turkic-ocr-code/resolve/main/scripts/r5_testpass2/tp2_make_jobs.py
- Command line
-
hf download hf://treoa/turkic-ocr-code/scripts/r5_testpass2/tp2_make_jobs.py
-
curl -L -o tp2_make_jobs.py https://huggingface.co/treoa/turkic-ocr-code/resolve/main/scripts/r5_testpass2/tp2_make_jobs.py
1.25 kB
| """Builds records/R5/TESTPASS2/jobs.json from a sacct dump (sacct -P -n -X -o JobID,JobName,State,Start,End,Elapsed,NodeList,ExitCode). | |
| sacct prints cluster local time (GMT+5); UTC = local - 5 h. Notes per job id come from a small JSON map. | |
| usage: tp2_make_jobs.py SACCT_TXT NOTES_JSON OUT_JSON | |
| """ | |
| import json | |
| import sys | |
| from datetime import datetime, timedelta | |
| rows = [] | |
| notes = json.load(open(sys.argv[2], encoding="utf-8")) | |
| def utc(s): | |
| try: | |
| return (datetime.strptime(s, "%Y-%m-%dT%H:%M:%S") - timedelta(hours=5)).strftime("%Y-%m-%dT%H:%M:%SZ") | |
| except ValueError: | |
| return s | |
| for ln in open(sys.argv[1], encoding="utf-8"): | |
| p = ln.rstrip("\n").split("|") | |
| if len(p) < 8: | |
| continue | |
| jid, name, state, st, en, el, node, ec = p[:8] | |
| base = jid.split("_")[0] | |
| rows.append({"job_id": jid, "name": name, "state": state, "start_utc": utc(st), "end_utc": utc(en), "start_gmt5": st, "end_gmt5": en, | |
| "elapsed": el, "node": node, "exit_code": ec, "note": notes.get(jid) or notes.get(base, "")}) | |
| json.dump({"time_note": "sacct prints GMT+5; *_utc = GMT+5 minus 5 h", "jobs": rows}, open(sys.argv[3], "w", encoding="utf-8"), indent=1, | |
| ensure_ascii=False) | |
| print("jobs", len(rows)) | |