Spec-Zone.ru › Polars

polars.Config.set_engine_affinity

classmethod Config.set_engine_affinity(
    engine: EngineType | None = None,
) → type[Config]

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 Engine object may also be used to configure the default. Engine objects are process-local and omitted from Config.save(); loading a state containing POLARS_ENGINE_AFFINITY replaces 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)
... )  

© 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

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API