@@ -44,31 +44,19 @@ def parse_args() -> argparse.Namespace:
4444 choices = ["DEBUG" , "INFO" , "WARNING" , "ERROR" , "CRITICAL" ],
4545 default = "INFO" ,
4646 )
47-
47+
4848 parser .add_argument (
4949 "--checkpoint" ,
5050 help = "Path to checkpoint directory to resume from (e.g., openevolve_output/checkpoints/checkpoint_50)" ,
51- default = None
52- )
53-
54- parser .add_argument (
55- "--api-base" ,
56- help = "Base URL for the LLM API" ,
57- default = None
58- )
59-
60- parser .add_argument (
61- "--primary-model" ,
62- help = "Primary LLM model name" ,
63- default = None
51+ default = None ,
6452 )
65-
66- parser .add_argument (
67- "--secondary-model" ,
68- help = "Secondary LLM model name" ,
69- default = None
70- )
71-
53+
54+ parser .add_argument ("--api-base" , help = "Base URL for the LLM API" , default = None )
55+
56+ parser . add_argument ( "--primary-model" , help = "Primary LLM model name" , default = None )
57+
58+ parser . add_argument ( "--secondary-model" , help = "Secondary LLM model name" , default = None )
59+
7260 return parser .parse_args ()
7361
7462
@@ -118,16 +106,18 @@ async def main_async() -> int:
118106 config_path = args .config if config is None else None ,
119107 output_dir = args .output ,
120108 )
121-
109+
122110 # Load from checkpoint if specified
123111 if args .checkpoint :
124112 if not os .path .exists (args .checkpoint ):
125113 print (f"Error: Checkpoint directory '{ args .checkpoint } ' not found" )
126114 return 1
127115 print (f"Loading checkpoint from { args .checkpoint } " )
128116 openevolve .database .load (args .checkpoint )
129- print (f"Checkpoint loaded successfully (iteration { openevolve .database .last_iteration } )" )
130-
117+ print (
118+ f"Checkpoint loaded successfully (iteration { openevolve .database .last_iteration } )"
119+ )
120+
131121 # Override log level if specified
132122 if args .log_level :
133123 logging .getLogger ().setLevel (getattr (logging , args .log_level ))
@@ -137,25 +127,30 @@ async def main_async() -> int:
137127 iterations = args .iterations ,
138128 target_score = args .target_score ,
139129 )
140-
130+
141131 # Get the checkpoint path
142132 checkpoint_dir = os .path .join (openevolve .output_dir , "checkpoints" )
143133 latest_checkpoint = None
144134 if os .path .exists (checkpoint_dir ):
145- checkpoints = [os .path .join (checkpoint_dir , d ) for d in os .listdir (checkpoint_dir )
146- if os .path .isdir (os .path .join (checkpoint_dir , d ))]
135+ checkpoints = [
136+ os .path .join (checkpoint_dir , d )
137+ for d in os .listdir (checkpoint_dir )
138+ if os .path .isdir (os .path .join (checkpoint_dir , d ))
139+ ]
147140 if checkpoints :
148- latest_checkpoint = sorted (checkpoints , key = lambda x : int (x .split ("_" )[- 1 ]) if "_" in x else 0 )[- 1 ]
149-
141+ latest_checkpoint = sorted (
142+ checkpoints , key = lambda x : int (x .split ("_" )[- 1 ]) if "_" in x else 0
143+ )[- 1 ]
144+
150145 print (f"\n Evolution complete!" )
151146 print (f"Best program metrics:" )
152147 for name , value in best_program .metrics .items ():
153148 print (f" { name } : { value :.4f} " )
154-
149+
155150 if latest_checkpoint :
156151 print (f"\n Latest checkpoint saved at: { latest_checkpoint } " )
157152 print (f"To resume, use: --checkpoint { latest_checkpoint } " )
158-
153+
159154 return 0
160155
161156 except Exception as e :
0 commit comments