TraceHandler#

class composer.profiler.TraceHandler(*args, **kwargs)[source]#

Base class for Composer Profiler trace handlers.

Subclasses should implement process_duration_event(), process_instant_event(), process_counter_event(), and process_chrome_json_trace_file() to record trace events.

Since TraceHandler subclasses Callback, a trace handler can run on any Event (such as on Event.INIT to open files or on Event.BATCH_END to periodically dump data to files) and use Callback.close() to perform any cleanup.

process_chrome_json_trace_file(filepath)[source]#

Invoked when there are events in Chrome JSON format to record.

See this document for more information.

Parameters

filepath (Path) โ€“ The filepath to a Chrome JSON trace file.

process_counter_event(name, categories, timestamp, wall_clock_time_ns, values)[source]#

Invoked whenever there is an counter event to record.

Parameters
  • name (str) โ€“ The name of the event.

  • categories (List[str] | Tuple[str, ...]) โ€“ The categories for the event.

  • timestamp (Timestamp) โ€“ The timestamp.

  • wall_clock_time_ns (int) โ€“ The time.time_ns() corresponding to the event.

  • values (Dict[str, int | float]) โ€“ The values corresponding to this counter event.

process_duration_event(name, categories, is_start, timestamp, wall_clock_time_ns)[source]#

Invoked whenever there is a duration event to record.

This method is called twice for each duration event โ€“ once with is_start = True, and then again with is_start = False. Interleaving events are not permitted. Specifically, for each event (identified by the name), a call with is_start = True will be followed by a call with is_start = False before another call with is_start = True.

Parameters
  • name (str) โ€“ The name of the event.

  • categories (Union[List[str], Tuple[str, ...]]) โ€“ The categories for the event.

  • is_start (bool) โ€“ Whether the event is a start event or end event.

  • timestamp (Timestamp) โ€“ Snapshot of the training time.

  • wall_clock_time_ns (int) โ€“ The time.time_ns() corresponding to the event.

process_instant_event(name, categories, timestamp, wall_clock_time_ns)[source]#

Invoked whenever there is an instant event to record.

Parameters
  • name (str) โ€“ The name of the event.

  • categories (List[str] | Tuple[str, ...]) โ€“ The categories for the event.

  • timestamp (Timestamp) โ€“ Snapshot of current training time.

  • wall_clock_time_ns (int) โ€“ The time.time_ns() corresponding to the event.