pathwaycom/pathway · error · ValueError

synchronization_group can only be set once

Error message

synchronization_group can only be set once

What it means

DataSourceOptions is a frozen dataclass whose set_synchronization_group assigns a connector synchronization group exactly once. Calling it a second time (or when synchronization_group was already set at construction) raises, because two conflicting synchronization-group assignments would make commit-ordering semantics ambiguous.

Source

Thrown at python/pathway/internals/datasource.py:28

import pandas as pd

from pathway.internals import api
from pathway.internals.schema import Schema, schema_from_pandas


@dataclass(frozen=True)
class DataSourceOptions:
    commit_duration_ms: int | None = None
    unsafe_trusted_ids: bool | None = False
    unique_name: str | None = None
    synchronization_group: api.ConnectorGroupDescriptor | None = None
    max_backlog_size: int | None = None

    def set_synchronization_group(self, group: api.ConnectorGroupDescriptor | None):
        if self.synchronization_group is None:
            object.__setattr__(self, "synchronization_group", group)
        else:
            raise ValueError("synchronization_group can only be set once")


@dataclass(frozen=True, kw_only=True)
class DataSource(ABC):
    schema: type[Schema]
    data_source_options: DataSourceOptions = DataSourceOptions()

    @property
    def connector_properties(self) -> api.ConnectorProperties:
        columns: list[api.ColumnProperties] = []
        for column in self.schema.columns().values():
            columns.append(
                api.ColumnProperties(
                    dtype=column.dtype.to_engine(),
                    append_only=self.is_append_only(),
                )
            )

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Set the synchronization group once — pass it directly to the read function: pw.io.csv.read(path, synchronization_group=my_group).
  2. Guard before setting: if source.data_source_options.synchronization_group is None: ...set... .
  3. If a different group is genuinely needed, construct a new source instead of mutating the existing one.

Example fix

# before
opts.set_synchronization_group(group_a)
...
opts.set_synchronization_group(group_b)  # raises

# after
# decide the group up front and set it only once
pw.io.csv.read(path, synchronization_group=group_b)
Defensive patterns

Strategy: validation

Validate before calling

assert source.data_source_options.synchronization_group is None, 'synchronization group already assigned; construct a new source instead'

Prevention

When it happens

Trigger: Calling source.options.set_synchronization_group(g1) and later set_synchronization_group(g2); applying a synchronization group to a source that already got one from the read API (e.g. pw.io.csv.read(..., synchronization_group=...) followed by another set).

Common situations: Framework code that wraps Pathway connectors and sets a default sync group, then user code sets its own; refactored pipelines calling a helper that sets the group twice.

Related errors


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