pathwaycom/pathway · error · ValueError

demo.generate_custom_stream error: nb_rows should be None or

Error message

demo.generate_custom_stream error: nb_rows should be None or strictly positive.

What it means

The airbyte connector's refresh_interval_ms parameter was replaced by refresh_interval, which takes seconds (int/float) or a datetime.timedelta. Passing the old parameter now raises a TypeError immediately, with a computed suggestion converting the old milliseconds value to seconds.

Source

Thrown at python/pathway/demo/__init__.py:84

    ...     'name': lambda x: f'Person {x}',
    ...     'age': lambda x: 20 + x,
    ... }
    >>> class InputSchema(pw.Schema):
    ...      number: int
    ...      name: str
    ...      age: int
    >>> pw.demo.generate_custom_stream(value_functions, schema=InputSchema, nb_rows=10)
    <pathway.Table schema={'number': <class 'int'>, 'name': <class 'str'>, 'age': <class 'int'>}>

    In the above example, a data stream is generated with 10 rows, where each row has columns \
        'number', 'name', and 'age'.
    The 'number' column contains values incremented by 1 from 1 to 10, the 'name' column contains 'Person'
    followed by the respective row index, and the 'age' column contains values starting from 20 incremented by
    the row index.
    """

    if nb_rows is not None and nb_rows < 0:
        raise ValueError(
            "demo.generate_custom_stream error: nb_rows should be None or strictly positive."
        )

    class FileStreamSubject(pw.io.python.ConnectorSubject):
        def run(self):
            def _get_row(i):
                row = {}
                for name, fun in value_generators.items():
                    row[name] = fun(i)
                return row

            if nb_rows is None:
                row_index = 0
                while True:
                    self.next_json(_get_row(row_index))
                    row_index = row_index + 1
                    time.sleep(1.0 / input_rate)
            else:

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Replace refresh_interval_ms=X with refresh_interval=X/1000 (seconds) or refresh_interval=timedelta(milliseconds=X).
  2. Apply the exact suggestion printed in the error message, e.g. refresh_interval=30.
  3. Search the codebase for refresh_interval_ms and migrate all occurrences.

Example fix

# before
pw.io.airbyte.read(..., refresh_interval_ms=30000)

# after
from datetime import timedelta
pw.io.airbyte.read(..., refresh_interval=timedelta(seconds=30))
Defensive patterns

Strategy: validation

Validate before calling

from datetime import timedelta

def refresh_interval_arg(refresh_interval_ms: int | None,
                         refresh_interval: int | float | timedelta | None):
    if refresh_interval_ms is not None:
        if refresh_interval is not None:
            raise ValueError("pass only refresh_interval")
        refresh_interval = timedelta(milliseconds=refresh_interval_ms)
    return {"refresh_interval": refresh_interval}

pw.io.airbyte.read(..., **refresh_interval_arg(refresh_interval_ms, refresh_interval))

Prevention

When it happens

Trigger: Calling pw.io.airbyte.read(..., refresh_interval_ms=30000) on a Pathway version where the parameter was removed.

Common situations: Code written against an older Pathway release (or copied from old docs/tutorials) after upgrading Pathway; the same call previously worked and now fails at argument validation.

Related errors


AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15). Data as JSON: /api/errors/75d430d22dd60543. Report an issue: GitHub.