Maggio33 commited on
Commit
5c776db
·
verified ·
1 Parent(s): aaab260

Upload eval_push.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. eval_push.py +43 -0
eval_push.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Push offline board-evals (Hart's glint_parity numbers) to an EXISTING fabryka run as
3
+ clean board/* metrics (not eval_-prefixed). Attaches by FABRYKA_RUN_ID.
4
+
5
+ Usage: FABRYKA_API_KEY=... python eval_push.py RUN_ID RUN_NAME STEP 'JSON_METRICS'
6
+ e.g. eval_push.py 538058fc-394b-4cb4-9057-b190685dbf2a GoLLeM-v5-64M-forkB-arcmix-edu \
7
+ 340000 '{"board/arc_easy":46.42,"board/blimp":77.53}'
8
+ """
9
+ import json
10
+ import os
11
+ import sys
12
+
13
+ run_id = sys.argv[1]
14
+ name = sys.argv[2]
15
+ step = int(sys.argv[3])
16
+ metrics = json.loads(sys.argv[4])
17
+ os.environ["FABRYKA_RUN_ID"] = run_id # must be set BEFORE RunClient reads it
18
+
19
+
20
+ def _patch():
21
+ """Make installed SDK honor FABRYKA_RUN_ID (idempotent; pusher may have done it already)."""
22
+ try:
23
+ import fabryka
24
+ p = os.path.join(os.path.dirname(fabryka.__file__), "client.py")
25
+ s = open(p, encoding="utf-8").read()
26
+ if "FABRYKA_RUN_ID" not in s:
27
+ s = s.replace("self.run_id = str(uuid.uuid4())",
28
+ 'self.run_id = os.getenv("FABRYKA_RUN_ID") or str(uuid.uuid4())')
29
+ open(p, "w", encoding="utf-8").write(s)
30
+ for mod in [m for m in sys.modules if m == "fabryka" or m.startswith("fabryka.")]:
31
+ del sys.modules[mod]
32
+ except Exception as e:
33
+ print(f"[eval_push] patch skipped: {e}", flush=True)
34
+
35
+
36
+ _patch()
37
+ from fabryka import RunClient
38
+
39
+ client = RunClient(api_url=os.environ.get("FABRYKA_API_URL", "https://track.fabryka.ai"),
40
+ api_key=os.environ["FABRYKA_API_KEY"])
41
+ client.init(project="gollem-v5", name=name)
42
+ client.log({k: float(v) for k, v in metrics.items()}, step=step)
43
+ print(f"[eval_push] pushed {metrics} @ step {step} -> run {run_id}", flush=True)