You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use more reasonable defaults in the resampler config #1473
As I understand it, ResamplerConfig2 is the config that should be used going forward, so I think its defaults should match what users expect. Currently, I find two of them unintuitive:
max_data_age_in_periods=3.0 reads like a staleness tolerance, but since all relevant samples are averaged, it also sets the averaging window: every value is the mean of the last three periods, not of its own period. At 1 s this smooths every value over 3 s and adds about 1 s of delay.
closed=RIGHT, label=RIGHT differ from our reporting data, which is labelled at the start of its interval (a 15-minute value at 10:00 covers [10:00, 10:15)), and from pandas, which also defaults to left. When both conventions meet, windows are off by one sample or one period, which is easy to miss.
Proposed solution
Change the defaults of ResamplerConfig2 to max_data_age_in_periods=1.0, closed=LEFT and label=LEFT, and leave ResamplerConfig as it is.
As far as I know, the edge app is currently the only user of ResamplerConfig2, and it already sets max_data_age_in_periods via RESAMPLING_MAX_DATA_AGE_IN_PERIODS (default 3.0). Adding the same kind of env vars for closed and label (default right) before changing the defaults here would keep its behaviour unchanged and let us switch sites one by one. I'm currently testing max_data_age_in_periods=1.0 on single sites and will share the results here.
This will need careful consideration. I suggest that, before touching the defaults, we manually start using these values everywhere, so we can test how they really work. Then when we need to change the default we should do the following instead:
Remove ResamplerConfig and make a breaking release
Add ResamplerConfig back as a copy of ResamplerConfig2, only with the defaults changed, and release.
My impression is we should probably have a better resampling function too to ship this. The 3 periods was important for failure tollerance. We can have both, store 3 windows of sample, but only average the samples of the first window, and fallback to the previous windows only when there is no data. Not sure if that works for data science, but I think it was the main intention for the 3 windows on the control side. Avoid having to deal with Nones only because of a small glitch in the data. But we can also reassess if this makes sense at all, or if every component should decide how to deal with this independently. This was designed a long time ago, so I wouldn't be surprised if requirements and constraints changed since then.
I fully agree that the max-data-age parameter default of 3 periods is highly confusing and it is not a reasonable choice for a default. Same with closed and label arguments. On the other hand, changing these defaults silently could have severe consequences in many edge deployments.
Since ResamplerConfig2 is also used already, I would first remove defaults for the fields we want to change to force downstream users to explicitly set the current defaults if they want to keep current behavior. If and when we add back the new defaults can happen some time later, even on a minor release.
I would create a new ResamplerConfig3 with the new defaults to avoid a breaking change. We already need to deprecate and remove ResamplerConfig (see #1496), we can then deprecate and remove ResamplerConfig2 and eventually rename ResamplerConfig3 simply as ResamplerConfig and hope we don't need any new changes for it 😬
Instead of making all downstream project break, we notify them via a deprecation that they should update to the new ResamplerConfig3.
All our internal actors import ResamplerConfig (the old one yes, they need updating already), and we have (or had, not sure) at least one external SDK user, which I think used resampling, but I'm not sure which config class exactly. If you prefer to go with a breaking change, we can do it, but in a new "major", which means more effort to rollout.
changed the title [-]Use more intuitive defaults in `ResamplerConfig2` (`max_data_age_in_periods`, `closed`, `label`)[/-][+]Use more reasonable defaults in the resampler config[/+]on Nov 26, 2026
The default resampling function doesn't make sense, and we want a new one that that only fall back to using old data if the last window doesn't have enough data.
Resampler config defaults need to change to not surprise data scientists, it happened that people wanting to use the resampler or moving window had defaults that were very suprising and made them waste a lot of time trying to find out what was causing the weird behavior (that makes sense only for control). This means max_data_age_in_periods=1.0, closed=LEFT and label=LEFT as stated in the issue.
The new defaults would probably be very bad for control, so we would like to have different defaults when calling microgrid.initialize() that use the current defaults.
I will do a PR so we can discuss with a concrete solution proposal.
OK, looking at the code, microgrid.initialize() requires a ResamplerConfig because this class requires specifying the resampling period, so there is no default there. I think the easiest solution here will be to just document the reasonable defaults instead of looking a way to provide them automatically.
The new defaults would probably be very bad for control, so we would like to have different defaults when calling microgrid.initialize() that use the current defaults.
They could be bad for control, we don't know without further testing.
Activity
llucax commentedon Oct 22, 2026
This will need careful consideration. I suggest that, before touching the defaults, we manually start using these values everywhere, so we can test how they really work. Then when we need to change the default we should do the following instead:
ResamplerConfigand make a breaking releaseResamplerConfigback as a copy ofResamplerConfig2, only with the defaults changed, and release.My impression is we should probably have a better resampling function too to ship this. The 3 periods was important for failure tollerance. We can have both, store 3 windows of sample, but only average the samples of the first window, and fallback to the previous windows only when there is no data. Not sure if that works for data science, but I think it was the main intention for the 3 windows on the control side. Avoid having to deal with
Nones only because of a small glitch in the data. But we can also reassess if this makes sense at all, or if every component should decide how to deal with this independently. This was designed a long time ago, so I wouldn't be surprised if requirements and constraints changed since then.cwasicki commentedon Oct 30, 2026
I fully agree that the max-data-age parameter default of 3 periods is highly confusing and it is not a reasonable choice for a default. Same with
closedandlabelarguments. On the other hand, changing these defaults silently could have severe consequences in many edge deployments.Since
ResamplerConfig2is also used already, I would first remove defaults for the fields we want to change to force downstream users to explicitly set the current defaults if they want to keep current behavior. If and when we add back the new defaults can happen some time later, even on a minor release.cwasicki commentedon Nov 23, 2026
Any objections @llucax ?
llucax commentedon Nov 25, 2026
I would create a new
ResamplerConfig3with the new defaults to avoid a breaking change. We already need to deprecate and removeResamplerConfig(see #1496), we can then deprecate and removeResamplerConfig2and eventually renameResamplerConfig3simply asResamplerConfigand hope we don't need any new changes for it 😬Instead of making all downstream project break, we notify them via a deprecation that they should update to the new
ResamplerConfig3.cwasicki commentedon Nov 25, 2026
Do you know of more than one downstream project?
llucax commentedon Nov 25, 2026
All our internal actors import
ResamplerConfig(the old one yes, they need updating already), and we have (or had, not sure) at least one external SDK user, which I think used resampling, but I'm not sure which config class exactly. If you prefer to go with a breaking change, we can do it, but in a new "major", which means more effort to rollout.[-]Use more intuitive defaults in `ResamplerConfig2` (`max_data_age_in_periods`, `closed`, `label`)[/-][+]Use more reasonable defaults in the resampler config[/+]llucax commentedon Nov 26, 2026
I'll try to summarize what we discussed:
max_data_age_in_periods=1.0,closed=LEFTandlabel=LEFTas stated in the issue.microgrid.initialize()that use the current defaults.I will do a PR so we can discuss with a concrete solution proposal.
llucax commentedon Nov 26, 2026
OK, looking at the code,
microgrid.initialize()requires aResamplerConfigbecause this class requires specifying the resampling period, so there is no default there. I think the easiest solution here will be to just document the reasonable defaults instead of looking a way to provide them automatically.cwasicki commentedon Nov 26, 2026
Thank you for the summary!
They could be bad for control, we don't know without further testing.
llucax commentedon Nov 26, 2026
If some components report metrics every 2 seconds, it is very unlikely that this would not be problematic, but you are right.
llucax commentedon Nov 26, 2026
Also "probably" == "could", right? 😆