polars.Config.set_engine_affinity
-
Set which engine to use by default.
- Parameters:
-
-
engine{None, ‘auto’, ‘in-memory’, ‘streaming’, ‘gpu’} -
The default execution engine Polars will attempt to use when calling
.collect(). However, the query is not guaranteed to execute with the specified engine.An
Engineobject may also be used to configure the default. Engine objects are process-local and omitted fromConfig.save(); loading a state containingPOLARS_ENGINE_AFFINITYreplaces the object affinity.
-
- Raises:
-
- ValueError: if engine is not recognised.
Examples
>>> pl.Config.set_engine_affinity("streaming") >>> lf = pl.LazyFrame({"v": [1, 2, 3], "v2": [4, 5, 6]}) >>> lf.max().collect() shape: (3, 2) ┌─────┬─────┐ │ v ┆ v2 │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞═════╪═════╡ │ 1 ┆ 4 │ │ 2 ┆ 5 │ │ 3 ┆ 6 │ └─────┴─────┘ >>> pl.Config.set_engine_affinity("gpu") >>> lf.max().collect() shape: (3, 2) ┌─────┬─────┐ │ v ┆ v2 │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞═════╪═════╡ │ 1 ┆ 4 │ │ 2 ┆ 5 │ │ 3 ┆ 6 │ └─────┴─────┘Set a configured engine as the default:
>>> pl.Config.set_engine_affinity( ... pl.GPUEngine(device=1, raise_on_fail=True) ... )
classmethod Config.set_engine_affinity(
engine: EngineType | None = None,
) → type[Config]
© 2020 Ritchie Vink
© 2022 Polars contributors
Licensed under the MIT License.
https://docs.pola.rs/api/python/stable/reference/api/polars.Config.set_engine_affinity.html