@@ -339,48 +339,6 @@ def main(): # noqa: C901
339339
340340 run_state = RunState (spec_filename = args .filename , replay_with = args .replay_with )
341341
342- # === TEMP: event bus recording (do not commit) ===
343- import dataclasses as _dc
344- import datetime as _dt
345- import enum as _enum
346- import time as _time
347-
348- event_bus ._recorded_events = [] # type: ignore[attr-defined]
349- event_bus ._recording_started_monotonic = _time .monotonic () # type: ignore[attr-defined]
350- event_bus ._recording_started_wall = _dt .datetime .now ().isoformat () # type: ignore[attr-defined]
351- _orig_publish = event_bus .publish
352-
353- def _recording_serialize (o ):
354- if _dc .is_dataclass (o ) and not isinstance (o , type ):
355- return {f .name : _recording_serialize (getattr (o , f .name )) for f in _dc .fields (o )}
356- if isinstance (o , dict ):
357- return {str (k ): _recording_serialize (v ) for k , v in o .items ()}
358- if isinstance (o , (list , tuple , set , frozenset )):
359- return [_recording_serialize (v ) for v in o ]
360- if isinstance (o , _enum .Enum ):
361- return o .name
362- if isinstance (o , (str , int , float , bool )) or o is None :
363- return o
364- if hasattr (o , "__dict__" ):
365- return {k : _recording_serialize (v ) for k , v in vars (o ).items () if not k .startswith ("_" )}
366- return repr (o )
367-
368- def _recording_publish (evt , _orig = _orig_publish ):
369- now = _time .monotonic ()
370- event_bus ._recorded_events .append ( # type: ignore[attr-defined]
371- {
372- "wall_clock" : _dt .datetime .now ().isoformat (),
373- "seconds_since_recording_start" : round (now - event_bus ._recording_started_monotonic , 4 ),
374- "seconds_since_render_start" : round (now - run_state .last_render_start_timestamp , 4 ),
375- "event_type" : type (evt ).__name__ ,
376- "data" : _recording_serialize (evt ),
377- }
378- )
379- return _orig (evt )
380-
381- event_bus .publish = _recording_publish # type: ignore[method-assign]
382- # === END TEMP ===
383-
384342 if args .headless :
385343 # Suppress Rich console output.
386344 console .quiet = True
@@ -410,27 +368,6 @@ def _recording_publish(evt, _orig=_orig_publish):
410368 if not isinstance (e , EXPECTED_EXCEPTIONS ):
411369 exc_info = sys .exc_info ()
412370 finally :
413- # === TEMP: dump event bus recording (do not commit) ===
414- try :
415- import json as _json
416-
417- _recording_path = Path (args .filename ).parent / f"event_bus_recording_{ run_state .render_id } .json"
418- with open (_recording_path , "w" ) as _rf :
419- _json .dump (
420- {
421- "render_id" : run_state .render_id ,
422- "spec_filename" : args .filename ,
423- "recording_started_wall" : getattr (event_bus , "_recording_started_wall" , None ),
424- "events" : getattr (event_bus , "_recorded_events" , []),
425- },
426- _rf ,
427- indent = 2 ,
428- default = str ,
429- )
430- console .info (f"Event bus recording saved to { _recording_path } " )
431- except Exception as _rec_err :
432- console .error (f"Failed to save event bus recording: { _rec_err } " )
433- # === END TEMP ===
434371 if exc_info :
435372 dump_crash_logs (args , run_state )
436373 capture_crash (exc_info , run_state , args )
0 commit comments