Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Use more reasonable defaults in the resampler config #1473

In progress

Description

@malteschaaf

What's needed?

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.

Use cases

No response

Alternatives and workarounds

No response

Additional context

No response

Activity

  1. added
    part:❓
    priority:❓
    type:enhancement
    on Oct 15, 2026
  2. added
    scope:breaking-change
    part:data-pipeline
    and removed
    part:❓
    priority:❓
    on Oct 22, 2026
  3. llucax commented on Oct 22, 2026

    @llucax
    Contributor

    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:

    1. Remove ResamplerConfig and make a breaking release
    2. 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.

  4. cwasicki commented on Oct 30, 2026

    @cwasicki
    Collaborator

    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.

  5. cwasicki commented on Nov 23, 2026

    @cwasicki
    Collaborator

    Any objections @llucax ?

  6. llucax commented on Nov 25, 2026

    @llucax
    Contributor

    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.

  7. cwasicki commented on Nov 25, 2026

    @cwasicki
    Collaborator

    Do you know of more than one downstream project?

  8. llucax commented on Nov 25, 2026

    @llucax
    Contributor

    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.

  9. self-assigned this
    on Nov 26, 2026
  10. 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
  11. llucax commented on Nov 26, 2026

    @llucax
    Contributor

    I'll try to summarize what we discussed:

    • 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.

  12. llucax commented on Nov 26, 2026

    @llucax
    Contributor

    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.

  13. cwasicki commented on Nov 26, 2026

    @cwasicki
    Collaborator

    Thank you for the summary!

    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.

  14. llucax commented on Nov 26, 2026

    @llucax
    Contributor

    If some components report metrics every 2 seconds, it is very unlikely that this would not be problematic, but you are right.

  15. llucax commented on Nov 26, 2026

    @llucax
    Contributor

    Also "probably" == "could", right? 😆

  16. moved this from To do to In progress in Python SDK Roadmapon Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

part:data-pipelinescope:breaking-changetype:enhancement

Fields

Priority

None yet

Effort

None yet

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions