@@ -36,7 +36,7 @@ def main() -> None:
3636 parser = argparse .ArgumentParser (
3737 description = "[bold cyan]Weco CLI[/]" , formatter_class = argparse .RawDescriptionHelpFormatter
3838 )
39- parser .add_argument ("--source" , type = str , required = True , help = "Path to the Python source code (e.g. optimize.py)" )
39+ parser .add_argument ("--source" , type = str , required = True , help = "Path to the source code (e.g. optimize.py)" )
4040 parser .add_argument (
4141 "--eval-command" , type = str , required = True , help = "Command to run for evaluation (e.g. 'python eval.py --arg1=val1')"
4242 )
@@ -88,7 +88,7 @@ def main() -> None:
8888 maximize = maximize , metric_name = metric_name , total_steps = steps , model = args .model , runs_dir = args .log_dir
8989 )
9090 plan_panel = PlanPanel ()
91- solution_panels = SolutionPanels (metric_name = metric_name )
91+ solution_panels = SolutionPanels (metric_name = metric_name , source_fp = source_fp )
9292 eval_output_panel = EvaluationOutputPanel ()
9393 tree_panel = MetricTreePanel (maximize = maximize )
9494 layout = create_optimization_layout ()
@@ -118,8 +118,8 @@ def main() -> None:
118118 runs_dir = pathlib .Path (args .log_dir ) / session_id
119119 runs_dir .mkdir (parents = True , exist_ok = True )
120120
121- # Save the original code (.runs/<session-id>/original.py )
122- runs_copy_source_fp = runs_dir / "original.py "
121+ # Save the original code (.runs/<session-id>/original.<extension> )
122+ runs_copy_source_fp = runs_dir / f "original.{ source_fp . suffix } "
123123 write_to_path (fp = runs_copy_source_fp , content = source_code )
124124
125125 # Write the code string to the source file path
@@ -200,8 +200,8 @@ def main() -> None:
200200 api_keys = api_keys ,
201201 timeout = timeout ,
202202 )
203- # Save next solution (.runs/<session-id>/step_<step>.py )
204- write_to_path (fp = runs_dir / f"step_{ step } .py " , content = eval_and_next_solution_response ["code" ])
203+ # Save next solution (.runs/<session-id>/step_<step>.<extension> )
204+ write_to_path (fp = runs_dir / f"step_{ step } .{ source_fp . suffix } " , content = eval_and_next_solution_response ["code" ])
205205
206206 # Write the next solution to the source file
207207 write_to_path (fp = source_fp , content = eval_and_next_solution_response ["code" ])
@@ -351,8 +351,8 @@ def main() -> None:
351351 )
352352 best_solution_content = f"# Best solution from Weco with a score of { best_score_str } \n \n { best_solution_code } "
353353
354- # Save best solution to .runs/<session-id>/best.py
355- write_to_path (fp = runs_dir / "best.py " , content = best_solution_content )
354+ # Save best solution to .runs/<session-id>/best.<extension>
355+ write_to_path (fp = runs_dir / f "best.{ source_fp . suffix } " , content = best_solution_content )
356356
357357 # write the best solution to the source file
358358 write_to_path (fp = source_fp , content = best_solution_content )
0 commit comments