{"record":{"id":"e50eb128d20b44c8","repo":"pola-rs/polars","slug":"invalid-scaling-mode-scaling-mode-r","errorCode":null,"errorMessage":"invalid `scaling_mode` {scaling_mode!r}","messagePattern":"invalid `scaling_mode` (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/lazyframe/engine_remote.py","lineNumber":128,"sourceCode":"    labels: list[str] | None\n    \"\"\"Labels attached to the query.\"\"\"\n    config: Mapping[str, Any]\n    \"\"\"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","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/lazyframe/engine_remote.py#L110-L146","documentation":"The remote engine's scaling configuration accepts only a fixed set of scaling_mode values (_SCALING_MODES, e.g. 'single-node', 'autoscaling'). Passing anything else in the RemoteEngine/EngineRemote constructor raises ValueError.","triggerScenarios":"Constructing the remote engine as e.g. EngineRemote(scaling_mode='auto') or EngineRemote(scaling_mode='cluster'), or loading scaling_mode from config with a typo.","commonSituations":"Guessing the scaling mode name instead of consulting polars-cloud docs; reusing values from other orchestrators ('elastic', 'fixed'); YAML/JSON config drift.","solutions":["Use an accepted scaling_mode such as 'single-node' or 'autoscaling'.","Omit scaling_mode to use the default.","Check membership against the engine module's _SCALING_MODES before constructing."],"exampleFix":"// before\nengine = RemoteEngine(scaling_mode='auto')\n\n// after\nengine = RemoteEngine(scaling_mode='autoscaling')","handlingStrategy":"validation","validationCode":"if scaling_mode is not None and scaling_mode not in ('single-node', 'autoscaling'):\n    raise ValueError(f'bad scaling_mode {scaling_mode!r}')","typeGuard":"def is_valid_scaling_mode(v: object) -> bool:\n    return v in ('single-node', 'autoscaling')","tryCatchPattern":"try:\n    engine = RemoteEngine(scaling_mode=scaling_mode)\nexcept ValueError:\n    engine = RemoteEngine()","preventionTips":["Define scaling-mode constants once and reuse them everywhere.","Validate YAML/JSON config values against the documented set before constructing engines."],"tags":["polars","polars-cloud","remote-engine","invalid-enum-value"],"backgroundTag":"invalid-enum-value","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"}