pola-rs/polars · error · ValueError

distributed options are not supported with…

Error message

distributed options {sorted(kwargs)!r} are not supported with `scaling_mode='single-node'`

What it means

With scaling_mode='single-node', the remote engine runs on one node, so distributed-only keyword options (worker counts, partitioning hints, etc.) are contradictory and rejected. The unknown distributed kwargs are caught via **kwargs and listed in the message.

Solutions

  1. Remove the distributed keyword arguments when using scaling_mode='single-node'.
  2. Switch to a distributed-compatible scaling_mode (e.g. 'autoscaling') if you need those options.
  3. Build the kwargs dict conditionally based on the chosen scaling mode.

Example fix

// before
engine = RemoteEngine(scaling_mode='single-node', num_workers=4)

// after
engine = RemoteEngine(scaling_mode='single-node')
Defensive patterns

Strategy: validation

Validate before calling

if scaling_mode == 'single-node':
    distributed_kwargs.clear()  # or assert not distributed_kwargs

Type guard

def options_compatible(scaling_mode: str, kwargs: dict) -> bool:
    return not (scaling_mode == 'single-node' and bool(kwargs))

Try / catch

try:
    engine = RemoteEngine(scaling_mode='single-node', **kwargs)
except ValueError as e:
    if 'not supported with' in str(e):
        engine = RemoteEngine(scaling_mode='single-node')
    else:
        raise

Prevention

When it happens

Trigger: RemoteEngine(scaling_mode='single-node', num_workers=4) or any distributed kwarg combined with single-node mode.

Common situations: Copy-pasting a distributed engine config and changing only scaling_mode; templates that always pass distributed options.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/d402609a8876ef9c. Report an issue: GitHub.

Appendix: source

Thrown at py-polars/src/polars/lazyframe/engine_remote.py:131

    """Additional options forwarded to the distributed planner."""

    def __init__(
        self,
        context: pc.ClientContext | None = None,
        *,
        scaling_mode: ScalingMode = "auto",
        engine: EngineTypeName = "auto",
        plan_type: PlanTypePreference = "dot",
        n_retries: int = 0,
        labels: list[str] | str | None = None,
        **kwargs: Any,
    ) -> None:
        if scaling_mode not in _SCALING_MODES:
            msg = f"invalid `scaling_mode` {scaling_mode!r}"
            raise ValueError(msg)
        if engine not in _WORKER_ENGINE_NAMES:
            msg = f"Invalid engine argument {engine=}"
            raise ValueError(msg)
        if scaling_mode == "single-node" and kwargs:
            msg = (
                f"distributed options {sorted(kwargs)!r} are not supported with "
                "`scaling_mode='single-node'`"
            )
            raise ValueError(msg)

        # fail here rather than deep inside a sink
        import_optional(
            "polars_cloud",
            err_prefix="remote engine requested, but required package",
            install_message="Please install using the command `pip install polars-cloud`",
        )

        self.context = context
        self.scaling_mode = scaling_mode
        self.engine = engine
        self.plan_type = plan_type

View on GitHub (pinned to fe841f959e)