rogermt commited on
Commit
c62479e
·
verified ·
1 Parent(s): 78bc953

Create entrypoint.py

Browse files
Files changed (1) hide show
  1. scripts/entrypoint.py +83 -0
scripts/entrypoint.py ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Headless entrypoint for running a single experiment or a sweep.
3
+
4
+ Usage:
5
+ python scripts/entrypoint.py --task example1 --out_dir experiments
6
+ python scripts/entrypoint.py --task example1 --out_dir experiments --use_wandb
7
+
8
+ By default Weights & Biases logging is disabled. Use --use_wandb to enable it.
9
+ """
10
+ import argparse
11
+ import json
12
+ import os
13
+ import importlib
14
+
15
+ def main():
16
+ parser = argparse.ArgumentParser(description="Run ARC-AGI experiment (headless).")
17
+ parser.add_argument("--task", type=str, required=True, help="Task name or path to task JSON")
18
+ parser.add_argument("--out_dir", type=str, default="experiments", help="Output directory")
19
+ parser.add_argument("--use_wandb", action="store_true", help="Enable Weights & Biases logging (default: off)")
20
+ parser.add_argument("--params", type=str, default=None, help="Optional JSON string of params")
21
+ args = parser.parse_args()
22
+
23
+ os.makedirs(args.out_dir, exist_ok=True)
24
+
25
+ # lazy imports to avoid heavy startup cost
26
+ import itt_solver.experiment_driver as ed
27
+ import itt_solver.solver_core as sc
28
+
29
+ # load task: if args.task is a JSON file path, load it; otherwise expect a built-in name
30
+ if os.path.exists(args.task):
31
+ with open(args.task) as fh:
32
+ task = json.load(fh)
33
+ else:
34
+ # minimal built-in example if user passed 'example1'
35
+ if args.task == "example1":
36
+ task = {
37
+ 'name': 'example1',
38
+ 'input': [[0,7,7],[7,7,7],[0,7,7]],
39
+ 'target': [
40
+ [0,0,0,0,7,7,0,7,7],
41
+ [0,0,0,7,7,7,7,7,7],
42
+ [0,0,0,0,7,7,0,7,7],
43
+ [0,7,7,0,7,7,0,7,7],
44
+ [7,7,7,7,7,7,7,7,7],
45
+ [0,7,7,0,7,7,0,7,7],
46
+ [0,0,0,0,7,7,0,7,7],
47
+ [0,7,7,0,7,7,0,7,7],
48
+ [0,0,0,0,7,7,0,7,7],
49
+ ],
50
+ 'target_shape': (9,9)
51
+ }
52
+ else:
53
+ raise SystemExit(f"Unknown task identifier: {args.task}")
54
+
55
+ # parse params if provided
56
+ params = {}
57
+ if args.params:
58
+ try:
59
+ params = json.loads(args.params)
60
+ except Exception:
61
+ print("Warning: could not parse --params JSON; ignoring.")
62
+
63
+ # build atomic library using default factory
64
+ atomic_library = ed.default_atomic_factory(params, task)
65
+
66
+ # run single experiment
67
+ result = ed.run_single(task, atomic_library, params, out_dir=args.out_dir)
68
+
69
+ # optionally run W&B logging externally (only if requested)
70
+ if args.use_wandb:
71
+ try:
72
+ from itt_solver.wandb_runner import run_and_log_wandb
73
+ run_and_log_wandb(task, atomic_library, params, out_dir=args.out_dir,
74
+ wandb_project=params.get('wandb_project','itt_solver'),
75
+ wandb_entity=None, resume="allow")
76
+ except Exception as e:
77
+ print("W&B logging failed or not configured:", e)
78
+
79
+ print("Run finished. Result summary:")
80
+ print(json.dumps(result, indent=2))
81
+
82
+ if __name__ == "__main__":
83
+ main()