linumpy.metrics.core#
Core metrics primitives: JSON encoder, PipelineMetrics, and IO.
Attributes#
Classes#
Custom JSON encoder to handle numpy types. |
|
Class for collecting and managing metrics from pipeline steps. |
Functions#
|
Load metrics from a JSON file. |
Module Contents#
- class linumpy.metrics.core.MetricsEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]#
Bases:
json.JSONEncoderCustom JSON encoder to handle numpy types.
- class linumpy.metrics.core.PipelineMetrics(step_name, output_dir=None)[source]#
Class for collecting and managing metrics from pipeline steps.
Each step can record multiple metrics with associated quality indicators. Metrics are saved as JSON files for later aggregation and report generation.
- add_metric(name, value, unit=None, threshold_name=None, custom_thresholds=None, description=None)[source]#
Add a metric with optional quality assessment.
- Parameters:
name (str) – Name of the metric.
value (Any) – Value of the metric.
unit (str, optional) – Unit of measurement.
threshold_name (str, optional) – Name of threshold to use from DEFAULT_THRESHOLDS.
custom_thresholds (dict, optional) – Custom thresholds {‘warning’: val, ‘error’: val, ‘higher_is_better’: bool}
description (str, optional) – Human-readable description of the metric.
- Return type:
None
- add_params(params)[source]#
Record each entry of
paramsas an info field. No-op ifparamsis falsy.- Parameters:
params (dict | None)
- Return type:
None
- finalize(filename=None)[source]#
Save metrics, log warnings/errors, and return self.
- Parameters:
filename (str | None)
- Return type:
- get_overall_status()[source]#
Get overall status based on all metrics.
- Returns:
‘error’, ‘warning’, or ‘ok’
- Return type:
- to_dict()[source]#
Convert metrics to dictionary format.
- Returns:
Dictionary containing all metrics and metadata.
- Return type: