Skip to content

proxystore.stream.filters

Set of common stream filters.

NullFilter

Filter which never filters out objects.

__call__

__call__(metadata: dict[str, Any]) -> bool

Apply the filter to event metadata.

Source code in proxystore/stream/filters.py
def __call__(self, metadata: dict[str, Any]) -> bool:
    """Apply the filter to event metadata."""
    return False

SamplingFilter

SamplingFilter(p: float)

Filter that randomly filters out objects.

Parameters:

  • p (float) –

    Probability of the filter return True. I.e., the object gets filtered out.

Raises:

Source code in proxystore/stream/filters.py
def __init__(self, p: float) -> None:
    if p < 0 or p > 1:
        raise ValueError(
            f'Filter probability p must be in [0, 1]. Got p={p}.',
        )
    self._p = p

__call__

__call__(metadata: dict[str, Any]) -> bool

Apply the filter to event metadata.

Source code in proxystore/stream/filters.py
def __call__(self, metadata: dict[str, Any]) -> bool:
    """Apply the filter to event metadata."""
    return random.random() <= self._p