dvilasuero commited on
Commit
2556245
·
verified ·
1 Parent(s): 256dc63

Upload runner.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. runner.py +29 -15
runner.py CHANGED
@@ -8,6 +8,7 @@
8
  # "transformers",
9
  # "accelerate",
10
  # "huggingface_hub",
 
11
  # ]
12
  # ///
13
  """Runner that downloads an eval script and executes it using inspect CLI."""
@@ -58,27 +59,40 @@ def bundle_and_upload_to_space(log_dir: str, hf_space_id: str, hf_token: str):
58
 
59
  if __name__ == "__main__":
60
  if len(sys.argv) < 4:
61
- print("Usage: eval_runner.py <eval_url> <model> <space_id> [log_dir] [extra_args...]")
62
  sys.exit(1)
63
 
64
- eval_script_url = sys.argv[1]
65
  model = sys.argv[2]
66
  hf_space_id = sys.argv[3]
67
- log_dir = sys.argv[4] if len(sys.argv) > 4 else "./logs"
68
- extra_args = sys.argv[5:] if len(sys.argv) > 5 else []
69
-
70
- print(f"Downloading eval from {eval_script_url}...")
71
- with urllib.request.urlopen(eval_script_url) as response:
72
- eval_code = response.read().decode('utf-8')
73
-
74
- eval_filename = "downloaded_eval.py"
75
- with open(eval_filename, 'w') as f:
76
- f.write(eval_code)
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
  try:
79
  print(f"Running inspect eval with model {model}...")
80
  cmd = [
81
- "inspect", "eval", eval_filename,
82
  "--model", model,
83
  "--log-dir", log_dir,
84
  ]
@@ -95,5 +109,5 @@ if __name__ == "__main__":
95
  bundle_and_upload_to_space(log_dir, hf_space_id, hf_token)
96
 
97
  finally:
98
- if os.path.exists(eval_filename):
99
- os.unlink(eval_filename)
 
8
  # "transformers",
9
  # "accelerate",
10
  # "huggingface_hub",
11
+ # "inspect_evals",
12
  # ]
13
  # ///
14
  """Runner that downloads an eval script and executes it using inspect CLI."""
 
59
 
60
  if __name__ == "__main__":
61
  if len(sys.argv) < 4:
62
+ print("Usage: eval_runner.py <eval_ref> <model> <space_id> [log_dir] [--inspect-evals] [extra_args...]")
63
  sys.exit(1)
64
 
65
+ eval_ref = sys.argv[1]
66
  model = sys.argv[2]
67
  hf_space_id = sys.argv[3]
68
+ log_dir = sys.argv[4] if len(sys.argv) > 4 and not sys.argv[4].startswith("--") else "./logs"
69
+
70
+ # Check if this is an inspect_evals path
71
+ is_inspect_evals = "--inspect-evals" in sys.argv
72
+ extra_args = [arg for arg in sys.argv[5:] if arg != "--inspect-evals"]
73
+
74
+ if is_inspect_evals:
75
+ # Use inspect_evals path directly
76
+ print(f"Using inspect_evals: {eval_ref}")
77
+ eval_target = eval_ref
78
+ cleanup_file = None
79
+ else:
80
+ # Download custom eval script
81
+ print(f"Downloading eval from {eval_ref}...")
82
+ with urllib.request.urlopen(eval_ref) as response:
83
+ eval_code = response.read().decode('utf-8')
84
+
85
+ eval_filename = "downloaded_eval.py"
86
+ with open(eval_filename, 'w') as f:
87
+ f.write(eval_code)
88
+
89
+ eval_target = eval_filename
90
+ cleanup_file = eval_filename
91
 
92
  try:
93
  print(f"Running inspect eval with model {model}...")
94
  cmd = [
95
+ "inspect", "eval", eval_target,
96
  "--model", model,
97
  "--log-dir", log_dir,
98
  ]
 
109
  bundle_and_upload_to_space(log_dir, hf_space_id, hf_token)
110
 
111
  finally:
112
+ if cleanup_file and os.path.exists(cleanup_file):
113
+ os.unlink(cleanup_file)