Metrics Handler
- class codestral_ros2_gen.utils.metrics_handler.MetricsHandler(metrics_file)[source]
Bases:
object
Handler for collecting, recording, and analyzing code generation metrics.
This class manages per-attempt metrics and overall aggregated metrics for the code generation process. It provides functionalities to record metrics, save and load metrics from a JSONL file, generate summary statistics, analyze error patterns, and produce plots.
- Parameters:
metrics_file (str | Path)
- __init__(metrics_file)[source]
Initialize the MetricsHandler.
- Parameters:
metrics_file (str | Path) – The path to the JSONL file where metrics will be stored.
- record_attempt(iteration_number, attempt_number, attempt_metrics)[source]
Record the metrics for a single generation attempt.
- Parameters:
iteration_number (int) – The sequential number of the iteration.
attempt_number (int) – The sequential number of the attempt.
attempt_metrics (AttemptMetrics) – An AttemptMetrics instance containing metrics for the attempt.
- Return type:
None
- _save_metrics()[source]
Save the current metrics DataFrame to the JSONL file.
- Raises:
RuntimeError – If saving fails.
- Return type:
None