Skip to content

Expose the resampler source properties as read-only #1502

Backlog

Description

@llucax

What's needed?

SourceProperties is a mutable dataclass (code), and the resampler gives its own instance of each source to users: Resampler.get_source_properties() returns it (code), and resampling functions receive it at every call (code).

The resampler also uses these fields as its own state. It estimates the input period from sampling_start and received_samples, only while sampling_period is None (code), and it finds new dropped samples by comparing with dropped_samples (code). #1501 adds current_windows_without_samples, which also decides when the missing samples are logged.

So writing to any of these fields, even by mistake, changes how the resampler works, and nothing prevents it.

Proposed solution

Keep the mutable object private to the resampler, and give users a read-only view of it, or a copy. A copy is simpler, but resampling functions would need a new one for every window of every source, so a read-only view is probably better there.

Changing what users get could break code that writes to it, so it might need a deprecation period. If only mutability of fields is changed, then it can ship as a bug fix, as changing the source properties was never intended to work.

Use cases

Applications read the source properties to check how healthy a timeseries is, through Resampler.get_source_properties() or in a custom resampling function. They should be able to do that without any risk of breaking the resampler.

Alternatives and workarounds

Documenting that the fields must not be modified is the cheapest option, but nothing enforces it.

Making SourceProperties frozen, and replacing it with a new instance on every update, would need a new object for every sample received, as received_samples changes with each one. Adding samples must be as fast as possible, so that's probably too slow.

Additional context

Found during the review of #1501: #1501 (comment)

Activity

  1. added
    priority:❓
    type:enhancement
    part:data-pipeline
    on Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    part:data-pipelinepriority:❓type:enhancement

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions