SIENTIAPDE-2212

SIENTIAPDE-2212-drift-janela-e-chunk-period: Remove default 1-minute margin from drift window calculation. The default interval now directly matches the frequency, ensuring consecutive windows do not overlap.
This commit is contained in:
2026-10-27 16:42:48 -03:00
parent 9e160655f2
commit 2d794d02b2
4 changed files with 14 additions and 16 deletions

View File

@@ -47,14 +47,13 @@ def common_config(config: dict[str, Any]):
# Kept in sync by hand with the `chunk_period` validation in
# sientia-dataops-laborious/laborious/activities/model_metrics.py (no shared contract).
DRIFT_CHUNK_PERIODS = ('min', 's')
# Re-reads the tail of the previous window so rows ingested up to 1 minute late still count.
DRIFT_WINDOW_MARGIN_MINUTES = 1
def _drift_interval_minutes(config: dict[str, Any], frequency: Any) -> int:
"""
Drift window in minutes: `interval_minutes` as configured (no margin), otherwise the
schedule frequency rounded up to whole minutes (min 1) plus DRIFT_WINDOW_MARGIN_MINUTES.
Drift window in minutes: `interval_minutes` as configured, otherwise the schedule frequency
rounded up to whole minutes (min 1). Consecutive default windows do not overlap, so each
drift chunk is stored once.
"""
if 'interval_minutes' in config:
return config['interval_minutes']
@@ -63,7 +62,7 @@ def _drift_interval_minutes(config: dict[str, Any], frequency: Any) -> int:
except ValueError:
# create_schedules fails this schedule on its own; don't kill the tick for every model.
return 60
return max(1, ceil(seconds / 60)) + DRIFT_WINDOW_MARGIN_MINUTES
return max(1, ceil(seconds / 60))
def drift(config: dict[str, Any]):
@@ -76,10 +75,9 @@ def drift(config: dict[str, Any]):
Args:
config (dict[str, Any]): Pipeline configuration containing:
- interval_minutes (int, optional): Time window for data comparison in minutes,
used as-is (no margin). Default: `frequency` rounded up to whole minutes
(min 1) plus a 1-minute margin for late data (2 with the default '1m').
Pipelines whose ingestion lag exceeds 1 minute should set it explicitly
(frequency + lag); `interval_minutes: 60` keeps the legacy window.
used as-is. Default: `frequency` rounded up to whole minutes (min 1), so
consecutive windows do not overlap (1 with the default '1m');
`interval_minutes: 60` keeps the legacy window.
- chunk_period (str, optional): Drift bucket size, 'min' or 's' (default: 'min').
Any other value falls back to 'min' and create_schedule_config warns.
- drift_metrics (list[str], optional): Statistical metrics to compute (default: