Skip to content

Commit a01cd20

Browse files
committed
fix: use eval-timeout instead of step-timeout
1 parent 9ce5ed5 commit a01cd20

File tree

3 files changed

+6
-48
lines changed

3 files changed

+6
-48
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ For more advanced examples, including [Triton](/examples/triton/README.md), [CUD
134134
| `-M, --model` | Model identifier for the LLM to use (e.g., `o4-mini`, `claude-sonnet-4-0`). | `o4-mini` when `OPENAI_API_KEY` is set; `claude-sonnet-4-0` when `ANTHROPIC_API_KEY` is set; `gemini-2.5-pro` when `GEMINI_API_KEY` is set. | `-M o4-mini` |
135135
| `-i, --additional-instructions`| Natural language description of specific instructions **or** path to a file containing detailed instructions to guide the LLM. | `None` | `-i instructions.md` or `-i "Optimize the model for faster inference"`|
136136
| `-l, --log-dir` | Path to the directory to log intermediate steps and final optimization result. | `.runs/` | `-l ./logs/` |
137-
| `--step-timeout` | Timeout in seconds for each optimization step. | `3600` | `--step-timeout 60` |
138-
| `--overall-timeout` | Overall timeout in seconds for the entire optimization run. | `None` | `--overall-timeout 3600` |
137+
| `--eval-timeout` | Timeout in seconds for each step in evaluation. | `3600` | `--eval-timeout 60` |
139138

140139
---
141140

weco/cli.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,7 @@ def configure_run_parser(run_parser: argparse.ArgumentParser) -> None:
6262
help="Description of additional instruction or path to a file containing additional instructions. Defaults to None.",
6363
)
6464
run_parser.add_argument(
65-
"--step-timeout", type=int, default=3600, help="Timeout in seconds for each optimization step. Defaults to 3600."
66-
)
67-
run_parser.add_argument(
68-
"--overall-timeout",
69-
type=int,
70-
default=None,
71-
help="Overall timeout in seconds for the entire optimization run. Defaults to None (no limit).",
65+
"--eval-timeout", type=int, default=3600, help="Timeout in seconds for each evaluation. Defaults to 3600."
7266
)
7367

7468

@@ -86,8 +80,7 @@ def execute_run_command(args: argparse.Namespace) -> None:
8680
log_dir=args.log_dir,
8781
additional_instructions=args.additional_instructions,
8882
console=console,
89-
step_timeout=args.step_timeout,
90-
overall_timeout=args.overall_timeout,
83+
eval_timeout=args.eval_timeout,
9184
)
9285
exit_code = 0 if success else 1
9386
sys.exit(exit_code)

weco/optimizer.py

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ def execute_optimization(
7878
log_dir: str = ".runs",
7979
additional_instructions: Optional[str] = None,
8080
console: Optional[Console] = None,
81-
step_timeout: int = 3600,
82-
overall_timeout: Optional[int] = None,
81+
eval_timeout: int = 3600,
8382
) -> bool:
8483
"""
8584
Execute the core optimization logic.
@@ -120,39 +119,10 @@ def signal_handler(signum, frame):
120119
# Exit gracefully
121120
sys.exit(0)
122121

123-
def timeout_handler():
124-
console.print(f"\n[bold yellow]Overall timeout of {overall_timeout} seconds reached. Shutting down...[/]")
125-
126-
# Stop heartbeat thread
127-
stop_heartbeat_event.set()
128-
if heartbeat_thread and heartbeat_thread.is_alive():
129-
heartbeat_thread.join(timeout=2)
130-
131-
# Report termination
132-
if current_run_id_for_heartbeat:
133-
report_termination(
134-
run_id=current_run_id_for_heartbeat,
135-
status_update="terminated",
136-
reason="timeout_reached",
137-
details=f"Overall optimization timeout of {overall_timeout} seconds reached.",
138-
auth_headers=current_auth_headers_for_heartbeat,
139-
timeout=3,
140-
)
141-
142-
# Exit gracefully
143-
sys.exit(0)
144-
145122
# Set up signal handlers for this run
146123
original_sigint_handler = signal.signal(signal.SIGINT, signal_handler)
147124
original_sigterm_handler = signal.signal(signal.SIGTERM, signal_handler)
148125

149-
# Set up the overall timeout if specified
150-
if overall_timeout is not None:
151-
overall_timeout_timer = threading.Timer(overall_timeout, timeout_handler)
152-
overall_timeout_timer.start()
153-
else:
154-
overall_timeout_timer = None
155-
156126
run_id = None
157127
optimization_completed_normally = False
158128
user_stop_requested_flag = False
@@ -279,7 +249,7 @@ def timeout_handler():
279249
)
280250

281251
# Run evaluation on the initial solution
282-
term_out = run_evaluation(eval_command=eval_command, timeout=step_timeout)
252+
term_out = run_evaluation(eval_command=eval_command, timeout=eval_timeout)
283253
# Update the evaluation output panel
284254
eval_output_panel.update(output=term_out)
285255
smooth_update(
@@ -378,7 +348,7 @@ def timeout_handler():
378348
],
379349
transition_delay=0.08, # Slightly longer delay for more noticeable transitions
380350
)
381-
term_out = run_evaluation(eval_command=eval_command, timeout=step_timeout)
351+
term_out = run_evaluation(eval_command=eval_command, timeout=eval_timeout)
382352
eval_output_panel.update(output=term_out)
383353
smooth_update(
384354
live=live,
@@ -478,10 +448,6 @@ def timeout_handler():
478448
# Ensure optimization_completed_normally is False
479449
optimization_completed_normally = False
480450
finally:
481-
# Cancel the overall timeout timer if it was set
482-
if overall_timeout_timer:
483-
overall_timeout_timer.cancel()
484-
485451
# Restore original signal handlers
486452
signal.signal(signal.SIGINT, original_sigint_handler)
487453
signal.signal(signal.SIGTERM, original_sigterm_handler)

0 commit comments

Comments
 (0)