dragon.ai.inference.reader_utils.MetricsConsolidator

class MetricsConsolidator[source]

Bases: object

Handles reading from the response queue and returning the response to the front end. Also terminates reading as soon as the expected number of inputs have been received.

__init__(q, end_ev, read_ev, descriptor, base_start_time, excel_workbook, sheet_name)[source]

Initialize a MetricsConsolidator instance.

Parameters:
  • q (mp.Queue) – Multiprocessing queue to read metrics from.

  • end_ev (mp.Event) – Multiprocessing event to signal the end of reading.

  • read_ev (mp.Event) – Event that signals when all metrics have been read.

  • descriptor (str ) – Descriptor string used to identify the metrics.

  • base_start_time (float ) – Base start time used to compute total processing time.

  • excel_workbook (str ) – Path to the Excel workbook to write metrics to.

  • sheet_name (str ) – Sheet name in the Excel workbook for metrics.

Methods

__init__(q, end_ev, read_ev, descriptor, ...)

Initialize a MetricsConsolidator instance.

read_and_compute(num_prompts)

Read metrics from the queue and compute aggregated statistics.

__init__(q, end_ev, read_ev, descriptor, base_start_time, excel_workbook, sheet_name)[source]

Initialize a MetricsConsolidator instance.

Parameters:
  • q (mp.Queue) – Multiprocessing queue to read metrics from.

  • end_ev (mp.Event) – Multiprocessing event to signal the end of reading.

  • read_ev (mp.Event) – Event that signals when all metrics have been read.

  • descriptor (str ) – Descriptor string used to identify the metrics.

  • base_start_time (float ) – Base start time used to compute total processing time.

  • excel_workbook (str ) – Path to the Excel workbook to write metrics to.

  • sheet_name (str ) – Sheet name in the Excel workbook for metrics.

read_and_compute(num_prompts)[source]

Read metrics from the queue and compute aggregated statistics.

The worker sits inside a loop and continuously reads from a metrics queue. It exits when the expected number of prompts has been read and the end event is set.

Parameters:

num_prompts (int ) – Number of expected input prompts to read.