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:
@@ -32,6 +32,7 @@ class SimpleMetrics:
|
|||||||
model_config = input_data['model_config']
|
model_config = input_data['model_config']
|
||||||
target_name = model_config['target']
|
target_name = model_config['target']
|
||||||
model_type = model_config.get('model_type')
|
model_type = model_config.get('model_type')
|
||||||
|
thresholds = model_config.get('simple_metrics_thresholds')
|
||||||
|
|
||||||
query = f"""
|
query = f"""
|
||||||
select p."timestamp", p.prediction, ld.value as "target"
|
select p."timestamp", p.prediction, ld.value as "target"
|
||||||
@@ -72,6 +73,7 @@ class SimpleMetrics:
|
|||||||
'metrics': input_data.get('metrics', ['rmse', 'mse', 'mae', 'r2']),
|
'metrics': input_data.get('metrics', ['rmse', 'mse', 'mae', 'r2']),
|
||||||
'interval_minutes': interval_minutes,
|
'interval_minutes': interval_minutes,
|
||||||
'model_type': model_type,
|
'model_type': model_type,
|
||||||
|
'thresholds': thresholds,
|
||||||
},
|
},
|
||||||
retry_policy=retry_policy,
|
retry_policy=retry_policy,
|
||||||
start_to_close_timeout=timedelta(seconds=300),
|
start_to_close_timeout=timedelta(seconds=300),
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ async def test_run(workflow_mock: AsyncMock, simple_metrics: SimpleMetrics):
|
|||||||
'metrics': input_data['metrics'],
|
'metrics': input_data['metrics'],
|
||||||
'interval_minutes': input_data['interval_minutes'],
|
'interval_minutes': input_data['interval_minutes'],
|
||||||
'model_type': None,
|
'model_type': None,
|
||||||
|
'thresholds': None,
|
||||||
},
|
},
|
||||||
retry_policy=ANY,
|
retry_policy=ANY,
|
||||||
start_to_close_timeout=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
|
'metrics': ['rmse', 'mse', 'mae', 'r2'], # Default value
|
||||||
'interval_minutes': input_data['interval_minutes'],
|
'interval_minutes': input_data['interval_minutes'],
|
||||||
'model_type': None,
|
'model_type': None,
|
||||||
|
'thresholds': None,
|
||||||
},
|
},
|
||||||
retry_policy=ANY,
|
retry_policy=ANY,
|
||||||
start_to_close_timeout=ANY,
|
start_to_close_timeout=ANY,
|
||||||
|
|||||||
Reference in New Issue
Block a user