{"record":{"id":"d402609a8876ef9c","repo":"pola-rs/polars","slug":"distributed-options-sorted-kwargs-r-are-not-sup","errorCode":null,"errorMessage":"distributed options {sorted(kwargs)!r} are not supported with `scaling_mode='single-node'`","messagePattern":"distributed options (.+?) are not supported with `scaling_mode='single-node'`","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/lazyframe/engine_remote.py","lineNumber":131,"sourceCode":"    \"\"\"Additional options forwarded to the distributed planner.\"\"\"\n\n    def __init__(\n        self,\n        context: pc.ClientContext | None = None,\n        *,\n        scaling_mode: ScalingMode = \"auto\",\n        engine: EngineTypeName = \"auto\",\n        plan_type: PlanTypePreference = \"dot\",\n        n_retries: int = 0,\n        labels: list[str] | str | None = None,\n        **kwargs: Any,\n    ) -> None:\n        if scaling_mode not in _SCALING_MODES:\n            msg = f\"invalid `scaling_mode` {scaling_mode!r}\"\n            raise ValueError(msg)\n        if engine not in _WORKER_ENGINE_NAMES:\n            msg = f\"Invalid engine argument {engine=}\"\n            raise ValueError(msg)\n        if scaling_mode == \"single-node\" and kwargs:\n            msg = (\n                f\"distributed options {sorted(kwargs)!r} are not supported with \"\n                \"`scaling_mode='single-node'`\"\n            )\n            raise ValueError(msg)\n\n        # fail here rather than deep inside a sink\n        import_optional(\n            \"polars_cloud\",\n            err_prefix=\"remote engine requested, but required package\",\n            install_message=\"Please install using the command `pip install polars-cloud`\",\n        )\n\n        self.context = context\n        self.scaling_mode = scaling_mode\n        self.engine = engine\n        self.plan_type = plan_type","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/lazyframe/engine_remote.py#L113-L149","documentation":"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.","triggerScenarios":"RemoteEngine(scaling_mode='single-node', num_workers=4) or any distributed kwarg combined with single-node mode.","commonSituations":"Copy-pasting a distributed engine config and changing only scaling_mode; templates that always pass distributed options.","solutions":["Remove the distributed keyword arguments when using scaling_mode='single-node'.","Switch to a distributed-compatible scaling_mode (e.g. 'autoscaling') if you need those options.","Build the kwargs dict conditionally based on the chosen scaling mode."],"exampleFix":"// before\nengine = RemoteEngine(scaling_mode='single-node', num_workers=4)\n\n// after\nengine = RemoteEngine(scaling_mode='single-node')","handlingStrategy":"validation","validationCode":"if scaling_mode == 'single-node':\n    distributed_kwargs.clear()  # or assert not distributed_kwargs","typeGuard":"def options_compatible(scaling_mode: str, kwargs: dict) -> bool:\n    return not (scaling_mode == 'single-node' and bool(kwargs))","tryCatchPattern":"try:\n    engine = RemoteEngine(scaling_mode='single-node', **kwargs)\nexcept ValueError as e:\n    if 'not supported with' in str(e):\n        engine = RemoteEngine(scaling_mode='single-node')\n    else:\n        raise","preventionTips":["Build engine kwargs conditionally on the scaling mode instead of forwarding everything.","When editing a distributed config to single-node, delete rather than comment out the distributed options."],"tags":["polars","polars-cloud","conflicting-options","remote-engine"],"backgroundTag":"conflicting-config-options","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}