Skip to content

Commit 87ab675

Browse files
committed
Update pyproject.toml to version 0.2.18. Refactor heartbeat logic in cli.py to streamline error handling by removing redundant try-except blocks, enhancing code clarity and maintainability.
1 parent e6dd715 commit 87ab675

File tree

2 files changed

+22
-39
lines changed

2 files changed

+22
-39
lines changed

pyproject.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,18 @@ build-backend = "setuptools.build_meta"
55

66
[project]
77
name = "weco"
8-
authors = [
9-
{name = "Weco AI Team", email = "contact@weco.ai"},
10-
]
8+
authors = [{ name = "Weco AI Team", email = "contact@weco.ai" }]
119
description = "Documentation for `weco`, a CLI for using Weco AI's code optimizer."
1210
readme = "README.md"
13-
version = "0.2.17"
14-
license = {text = "MIT"}
11+
version = "0.2.18"
12+
license = { text = "MIT" }
1513
requires-python = ">=3.8"
1614
dependencies = ["requests", "rich"]
1715
keywords = ["AI", "Code Optimization", "Code Generation"]
1816
classifiers = [
1917
"Programming Language :: Python :: 3",
2018
"Operating System :: OS Independent",
21-
"License :: OSI Approved :: MIT License"
19+
"License :: OSI Approved :: MIT License",
2220
]
2321

2422
[project.scripts]

weco/cli.py

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@ def main() -> None:
437437
transition_delay=0.1,
438438
)
439439

440-
# Send initial heartbeat immediately after starting
441-
send_heartbeat(session_id, auth_headers)
440+
# # Send initial heartbeat immediately after starting
441+
# send_heartbeat(session_id, auth_headers)
442442

443443
# Run evaluation on the initial solution
444444
term_out = run_evaluation(eval_command=args.eval_command)
@@ -460,23 +460,14 @@ def main() -> None:
460460
)
461461

462462
# Send feedback and get next suggestion
463-
try:
464-
eval_and_next_solution_response = evaluate_feedback_then_suggest_next_solution(
465-
session_id=session_id,
466-
execution_output=term_out,
467-
additional_instructions=current_additional_instructions, # Pass current instructions
468-
api_keys=llm_api_keys, # Pass client LLM keys
469-
auth_headers=auth_headers, # Pass Weco key if logged in
470-
timeout=timeout,
471-
)
472-
except (requests.exceptions.HTTPError, requests.exceptions.RequestException) as suggest_error:
473-
# If suggest fails, we consider it a CLI error and break the loop
474-
console.print(
475-
f"\n[bold red]Error communicating with API during step {step}. Stopping optimization.[/]"
476-
)
477-
# Error details should have been printed by handle_api_error or the exception handler in evaluate_feedback_then_suggest_next_solution
478-
# Prepare to report error in finally block
479-
raise RuntimeError(f"API error during suggest at step {step}") from suggest_error
463+
eval_and_next_solution_response = evaluate_feedback_then_suggest_next_solution(
464+
session_id=session_id,
465+
execution_output=term_out,
466+
additional_instructions=current_additional_instructions, # Pass current instructions
467+
api_keys=llm_api_keys, # Pass client LLM keys
468+
auth_headers=auth_headers, # Pass Weco key if logged in
469+
timeout=timeout,
470+
)
480471

481472
# Save next solution (.runs/<session-id>/step_<step>.<extension>)
482473
write_to_path(
@@ -569,20 +560,14 @@ def main() -> None:
569560
)
570561

571562
# Final evaluation report
572-
try:
573-
eval_and_next_solution_response = evaluate_feedback_then_suggest_next_solution(
574-
session_id=session_id,
575-
execution_output=term_out,
576-
additional_instructions=current_additional_instructions,
577-
api_keys=llm_api_keys,
578-
timeout=timeout,
579-
auth_headers=auth_headers,
580-
)
581-
except (requests.exceptions.HTTPError, requests.exceptions.RequestException) as suggest_error:
582-
console.print(
583-
"\n[bold red]Error communicating with API during final evaluation report. Results might be incomplete.[/]"
584-
)
585-
raise RuntimeError("API error during final suggest call") from suggest_error
563+
eval_and_next_solution_response = evaluate_feedback_then_suggest_next_solution(
564+
session_id=session_id,
565+
execution_output=term_out,
566+
additional_instructions=current_additional_instructions,
567+
api_keys=llm_api_keys,
568+
timeout=timeout,
569+
auth_headers=auth_headers,
570+
)
586571

587572
# Update the progress bar
588573
summary_panel.set_step(step=steps)

0 commit comments

Comments
 (0)