@@ -136,9 +136,9 @@ def async_run_codeevolve(
136136 error_msg = f"Island { isl_data .id } crashed with exception: { type (e ).__name__ } : { str (e )} "
137137 full_traceback = traceback .format_exc ()
138138 try :
139- isl_out_dir : Path = run_args .get ("isl_out_dir " )
140- if isl_out_dir :
141- _write_island_crash_log (isl_out_dir , error_msg , full_traceback )
139+ isl_logs_dir : Path = run_args .get ("logs_dir " )
140+ if isl_logs_dir :
141+ _write_island_crash_log (isl_logs_dir , error_msg , full_traceback , int ( global_data . start_time . value ) )
142142 except Exception :
143143 pass
144144
@@ -247,29 +247,29 @@ def cleanup_log_daemon(
247247# ---------------------------------------------------------------------------
248248
249249
250- def _write_island_crash_log (isl_out_dir : Path , error_msg : str , full_traceback : str ) -> None :
250+ def _write_island_crash_log (isl_logs_dir : Path , error_msg : str , full_traceback : str , time : int = 0 ) -> None :
251251 """Writes detailed crash information to an island's crash log file.
252252
253253 Called from within the child process where the exception occurred.
254254
255255 Args:
256- isl_out_dir : Island's output directory.
256+ isl_logs_dir : Island's logs directory.
257257 error_msg: Summary error message.
258258 full_traceback: Full Python traceback string.
259+ time: Int identifying global time of the run.
259260 """
260- crash_log_path : Path = isl_out_dir .joinpath (CRASH_LOG_FILE )
261- timestamp : str = datetime .now ().strftime ("%Y-%m-%d %H:%M:%S" )
261+ crash_log_path : Path = isl_logs_dir .joinpath (CRASH_LOG_FILE .format (time = time ))
262262 with open (crash_log_path , "a" ) as f :
263263 f .write (f"\n { '=' * 60 } \n " )
264- f .write (f"CRASH REPORT - { timestamp } \n " )
264+ f .write (f"CRASH REPORT\n " )
265265 f .write (f"{ '=' * 60 } \n " )
266266 f .write (f"{ error_msg } \n \n " )
267267 f .write ("Full Traceback:\n " )
268268 f .write (full_traceback )
269269 f .write (f"{ '=' * 60 } \n \n " )
270270
271271
272- def _write_crash_summary (out_dir : Path , island_id : int , exit_code : int , message : str ) -> None :
272+ def _write_crash_summary (out_dir : Path , island_id : int , exit_code : int , message : str , time : int = 0 ) -> None :
273273 """Writes crash summary to the main output directory's crash log.
274274
275275 Called from the parent process when it detects an island has crashed.
@@ -279,18 +279,17 @@ def _write_crash_summary(out_dir: Path, island_id: int, exit_code: int, message:
279279 island_id: ID of the island that crashed.
280280 exit_code: Exit code of the crashed process.
281281 message: Summary message.
282+ time: Int identifying global time of the run.
282283 """
283- crash_log_path : Path = out_dir .joinpath (CRASH_LOG_FILE )
284- timestamp : str = datetime .now ().strftime ("%Y-%m-%d %H:%M:%S" )
285-
284+ crash_log_path : Path = out_dir .joinpath (CRASH_LOG_FILE .format (time = time ))
286285 with open (crash_log_path , "a" ) as f :
287286 f .write (f"\n { '=' * 60 } \n " )
288- f .write (f"CRASH REPORT - { timestamp } \n " )
287+ f .write (f"CRASH REPORT\n " )
289288 f .write (f"{ '=' * 60 } \n " )
290289 f .write (f"Island: { island_id } \n " )
291290 f .write (f"Exit Code: { exit_code } \n " )
292291 f .write (f"Message: { message } \n " )
293- f .write (f"See island { island_id } /{ CRASH_LOG_FILE } for full traceback.\n " )
292+ f .write (f"See island_ { island_id } /logs/ { CRASH_LOG_FILE . format ( time = time ) } for full traceback.\n " )
294293 f .write (f"{ '=' * 60 } \n \n " )
295294
296295
@@ -327,6 +326,7 @@ def monitor_island_processes(
327326 """
328327 num_islands : int = len (processes )
329328 completed : List [bool ] = [False ] * num_islands
329+ time : int = int (global_data .start_time .value )
330330
331331 try :
332332 while not all (completed ):
@@ -345,13 +345,12 @@ def monitor_island_processes(
345345 error_msg : str = (
346346 f"Island { i } died unexpectedly with exit code { process .exitcode } "
347347 )
348-
349- _write_crash_summary (out_dir , i , process .exitcode , error_msg )
348+ _write_crash_summary (out_dir , i , process .exitcode , error_msg , time )
350349
351350 print (f"\n { '=' * 60 } " , file = sys .stderr )
352351 print (f"ERROR: { error_msg } " , file = sys .stderr )
353352 print (
354- f"See { out_dir } /{ CRASH_LOG_FILE } and island logs for details." ,
353+ f"See { out_dir } /{ CRASH_LOG_FILE . format ( time = time ) } and island logs for details." ,
355354 file = sys .stderr ,
356355 )
357356 print (f"{ '=' * 60 } \n " , file = sys .stderr )
0 commit comments