{"record":{"id":"b4beb07fecae3666","repo":"pola-rs/polars","slug":"invalid-engine-argument-engine-b4beb0","errorCode":null,"errorMessage":"Invalid engine argument {engine=}","messagePattern":"Invalid engine argument (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/lazyframe/engine_remote.py","lineNumber":137,"sourceCode":"        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\n        self.n_retries = n_retries\n        self.labels = [labels] if isinstance(labels, str) else labels\n        self.config = kwargs\n\n    @property\n    def name(self) -> str:","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/lazyframe/engine_remote.py#L119-L155","documentation":"The remote engine only accepts worker engine names in _WORKER_ENGINE_NAMES; constructing the remote engine with a different engine value raises ValueError. This check exists so failure happens at construction rather than deep inside a later sink/collect.","triggerScenarios":"RemoteEngine(engine='gpu') or engine='in-memory', or a typo like engine='cudf', when the remote engine expects one of its supported worker engines (e.g. 'cpu'/'gpu' names defined by polars-cloud).","commonSituations":"Reusing the local engine name strings for the remote engine; older/newer polars-cloud versions with different worker engine names.","solutions":["Pass a supported worker engine name (see polars_cloud / _WORKER_ENGINE_NAMES) or omit engine to use the default.","Align engine names with the installed polars-cloud version rather than assuming local engine names.","Validate the value against _WORKER_ENGINE_NAMES before constructing."],"exampleFix":"// before\nengine = RemoteEngine(engine='in-memory')\n\n// after\nengine = RemoteEngine()  # or engine=<supported worker engine>","handlingStrategy":"validation","validationCode":"WORKER_ENGINES = {'cpu', 'gpu'}  # confirm against installed polars-cloud\nif engine is not None and engine not in WORKER_ENGINES:\n    raise ValueError(f'bad remote worker engine {engine!r}')","typeGuard":"def is_valid_worker_engine(v: object) -> bool:\n    return v is None or v in {'cpu', 'gpu'}","tryCatchPattern":"try:\n    engine = RemoteEngine(engine=name)\nexcept ValueError as e:\n    if 'Invalid engine argument' in str(e):\n        engine = RemoteEngine()\n    else:\n        raise","preventionTips":["Do not reuse local engine names for the remote engine's worker engine.","Pin and document the polars-cloud version the engine names were verified against."],"tags":["polars","polars-cloud","remote-engine","invalid-argument-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"}