{"record":{"id":"5da86fd51b622441","repo":"pola-rs/polars","slug":"invalid-engine","errorCode":null,"errorMessage":"invalid engine","messagePattern":"invalid engine","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/config.py","lineNumber":1606,"sourceCode":"\n        >>> pl.Config.set_engine_affinity(\n        ...     pl.GPUEngine(device=1, raise_on_fail=True)\n        ... )  # doctest: +SKIP\n\n        Raises\n        ------\n        ValueError: if engine is not recognised.\n        \"\"\"\n        if isinstance(engine, Engine):\n            # Object affinities are Python-only; clear the named affinity.\n            os.environ.pop(\"POLARS_ENGINE_AFFINITY\", None)\n            set_engine_affinity_override(engine)\n            plr.config_reload_env_var(\"POLARS_ENGINE_AFFINITY\")\n            return cls\n\n        if engine not in {*SUPPORTED_ENGINE_NAMES, None}:\n            msg = \"invalid engine\"\n            raise ValueError(msg)\n        if engine is None:\n            os.environ.pop(\"POLARS_ENGINE_AFFINITY\", None)\n        else:\n            os.environ[\"POLARS_ENGINE_AFFINITY\"] = engine\n        set_engine_affinity_override(None)\n        plr.config_reload_env_var(\"POLARS_ENGINE_AFFINITY\")\n\n        return cls\n\n    @classmethod\n    def enable_monitoring(\n        cls,\n        active: bool | None = True,\n        *,\n        workspace: str | None = None,\n        organization: str | None = None,\n    ) -> type[Config]:\n        \"\"\"","sourceCodeStart":1588,"sourceCodeEnd":1624,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/config.py#L1588-L1624","documentation":"Config.set_engine_affinity validates the engine name against SUPPORTED_ENGINE_NAMES (plus None to reset) before storing POLARS_ENGINE_AFFINITY. Any other value raises a plain ValueError with the message 'invalid engine'. This config pins which execution engine (e.g. 'in-memory', 'streaming') Polars uses.","triggerScenarios":"pl.Config.set_engine_affinity('gpu'), 'lazy', 'old-streaming', or any misspelled engine name; also via Config.enable_monitoring if it forwards an invalid engine.","commonSituations":"Using engine names from other libraries (e.g. dask 'gpu' variants) or from older Polars versions where the streaming engine had a different name.","solutions":["Use a supported name, e.g. pl.Config.set_engine_affinity('in-memory') or 'streaming'.","Pass None to clear the override and use the default engine selection.","Check polars.exceptions / docs for SUPPORTED_ENGINE_NAMES in your installed version, as names change across releases."],"exampleFix":"// before\npl.Config.set_engine_affinity(\"old-streaming\")\n// after\npl.Config.set_engine_affinity(\"streaming\")","handlingStrategy":"validation","validationCode":"SUPPORTED = {\"in-memory\", \"streaming\"}  # match SUPPORTED_ENGINE_NAMES for your version\nif engine is not None and engine not in SUPPORTED:\n    raise ValueError(f\"engine must be one of {SUPPORTED} or None\")\npl.Config.set_engine_affinity(engine)","typeGuard":"def is_valid_engine(v) -> bool:\n    return v is None or (isinstance(v, str) and v in {\"in-memory\", \"streaming\"})","tryCatchPattern":"try:\n    pl.Config.set_engine_affinity(engine)\nexcept ValueError:\n    logging.warning(\"unknown engine %r; using default\", engine)\n    pl.Config.set_engine_affinity(None)","preventionTips":["Check SUPPORTED_ENGINE_NAMES for your installed polars version — names change between releases.","Use None to clear overrides rather than guessing a 'default' keyword.","Pin engine choice via collect(engine=...) instead of global config where possible."],"tags":["python","polars","config","invalid-enum-value"],"backgroundTag":"invalid-config-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"}