feat(simple_metrics): thread thresholds config from model_config to activity

Reads optional simple_metrics_thresholds from model_config and passes
to calculate_simple_metrics. Threshold schema: {rmse_max, r2_min, ...}.
None when not configured (no alerting, no crash).

Updates workflow tests to expect the new key in the activity-call dict.

SIENTIAPDE-1986

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
PedroHMCosme
2026-08-19 11:25:49 -03:00
parent 666188a7b3
commit 4e3b5756be
2 changed files with 4 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ class SimpleMetrics:
model_config = input_data['model_config']
target_name = model_config['target']
model_type = model_config.get('model_type')
thresholds = model_config.get('simple_metrics_thresholds')
query = f"""
select p."timestamp", p.prediction, ld.value as "target"
@@ -72,6 +73,7 @@ class SimpleMetrics:
'metrics': input_data.get('metrics', ['rmse', 'mse', 'mae', 'r2']),
'interval_minutes': interval_minutes,
'model_type': model_type,
'thresholds': thresholds,
},
retry_policy=retry_policy,
start_to_close_timeout=timedelta(seconds=300),

View File

@@ -104,6 +104,7 @@ async def test_run(workflow_mock: AsyncMock, simple_metrics: SimpleMetrics):
'metrics': input_data['metrics'],
'interval_minutes': input_data['interval_minutes'],
'model_type': None,
'thresholds': None,
},
retry_policy=ANY,
start_to_close_timeout=ANY,
@@ -211,6 +212,7 @@ async def test_run_default_metrics(workflow_mock: AsyncMock, simple_metrics: Sim
'metrics': ['rmse', 'mse', 'mae', 'r2'], # Default value
'interval_minutes': input_data['interval_minutes'],
'model_type': None,
'thresholds': None,
},
retry_policy=ANY,
start_to_close_timeout=ANY,