set_compute_context#
- polars_cloud.set_compute_context(context: ClientContext | None) None #
Set a compute context as the default during this session.
Setting a compute context allows spawning queries without explicitly passing a compute context.
See also
ComputeContext
Examples
small_machine = pc.ComputeContext(cpus=1, memory=2) large_machine = pc.ComputeContext(cpus=2, memory=4) lf = pl.LazyFrame({"a": [1, 2, 3, 4]}) # Queries will execute on the small machine by default pc.set_compute_context(small_machine) with pc.set_compute_context(large_machine): # These queries will execute on the large machine lf.remote().show() lf.select(a_sum=pl.col("a").sum()).remote().show() @pc.set_compute_context(large_machine) def execute_on_large_machine(lf: pl.LazyFrame): # These queries will execute on the large machine lf.remote().show() lf.select(a_min=pl.col("a").min(), a_max=pl.col("a").max()).remote().show()