pola-rs/polars · error · ValueError
Invalid engine argument
Error message
Invalid engine argument {engine=} What it means
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.
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.
Example fix
// before engine = RemoteEngine(engine='in-memory') // after engine = RemoteEngine() # or engine=<supported worker engine>
Defensive patterns
Strategy: validation
Validate before calling
WORKER_ENGINES = {'cpu', 'gpu'} # confirm against installed polars-cloud
if engine is not None and engine not in WORKER_ENGINES:
raise ValueError(f'bad remote worker engine {engine!r}') Type guard
def is_valid_worker_engine(v: object) -> bool:
return v is None or v in {'cpu', 'gpu'} Try / catch
try:
engine = RemoteEngine(engine=name)
except ValueError as e:
if 'Invalid engine argument' in str(e):
engine = RemoteEngine()
else:
raise Prevention
- 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.
When it happens
Trigger: 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).
Common situations: Reusing the local engine name strings for the remote engine; older/newer polars-cloud versions with different worker engine names.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- distributed options are not supported with…
- invalid `scaling_mode
- ` ` is not supported by the remote engine
- Invalid engine argument
- `strict` cannot be used with `how='horizontal_extend'`
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/b4beb07fecae3666.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/src/polars/lazyframe/engine_remote.py:137
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
self.n_retries = n_retries
self.labels = [labels] if isinstance(labels, str) else labels
self.config = kwargs
@property
def name(self) -> str:View on GitHub (pinned to fe841f959e)