polars.RemoteEngine#
- class polars.RemoteEngine(
- context: pc.ClientContext | None = None,
- *,
- scaling_mode: ScalingMode = 'auto',
- engine: EngineTypeName = 'auto',
- plan_type: PlanTypePreference = 'dot',
- n_retries: int = 0,
- labels: list[str] | str | None = None,
- **kwargs: Any,
Execute queries remotely on Polars Cloud.
Use this engine with
LazyFrame.collect(),LazyFrame.execute(), aLazyFrame.sink_*method, or as the default throughConfig.set_engine_affinity().Requires the
polars_cloudpackage.LazyFrame.collect()andLazyFrame.collect_batches()stream the result back to this machine, which Polars Cloud only supports on a cluster context.Warning
This functionality is considered unstable. It may be changed at any point without it being considered a breaking change.
- Parameters:
- context
Compute context. Defaults to the current
polars_cloudsession.- scaling_mode{‘auto’, ‘single-node’, ‘distributed’}
Whether to run the query on a single node or distributed over the cluster. If
'auto', a query runs distributed if the cluster has more than one node.- engine{‘auto’, ‘in-memory’, ‘streaming’, ‘gpu’}
Preferred worker engine. This is a hint and also controls plan rendering.
- plan_type{‘dot’, ‘plain’}
Query-plan rendering format.
- n_retries
Number of retries per failed stage.
- labels
Labels attached to the query. Missing labels are created automatically.
- **kwargs
Additional options forwarded to the distributed planner, such as
max_workers,min_workers,shuffle_formatorpartitions_per_worker. Passing any of these is incompatible withscaling_mode='single-node'.
Examples
>>> import polars_cloud as pc >>> engine = pl.RemoteEngine( ... pc.ComputeContext(cpus=16, memory=64), ... scaling_mode="distributed", ... max_workers=8, ... ) >>> lf.sink_parquet("s3://my-destination/", engine=engine)
Make it the default for every query in a scope:
>>> with pl.Config(engine_affinity=engine): ... lf.sink_parquet("s3://my-destination/")
- __init__(
- context: pc.ClientContext | None = None,
- *,
- scaling_mode: ScalingMode = 'auto',
- engine: EngineTypeName = 'auto',
- plan_type: PlanTypePreference = 'dot',
- n_retries: int = 0,
- labels: list[str] | str | None = None,
- **kwargs: Any,
Methods
__init__([context, scaling_mode, engine, ...])collect(lf, *, optimizations[, background, ...])Collect
lfremotely, streaming the result back to this machine.collect_all(lfs, *, optimizations)Execute several queries, potentially in parallel.
collect_all_async(lfs, *, optimizations[, ...])Execute several queries asynchronously.
collect_async(lf, *, optimizations[, gevent])Execute
lfasynchronously.collect_batches(lf, *, optimizations[, ...])execute(lf, *, optimizations)sink_batches(lf, function, *, chunk_size, ...)sink_csv(lf, path, *, include_bom, ...)sink_ipc(lf, path, *, compression, ...)sink_ndjson(lf, path, *, compression, ...)sink_parquet(lf, path, *, compression, ...)Attributes
nameEngine identifier.
plan_enginePreferred worker engine used to render query plans.
contextCompute context in which queries are executed.
scaling_modeWhether the query runs on a single node or distributed over the cluster.
engineEngine the workers are asked to prefer.
plan_typeHow query plans are rendered.
n_retriesHow often a stage should be retried on failure.
labelsLabels attached to the query.
configAdditional options forwarded to the distributed planner.