ComputeContext#
- class polars_cloud.ComputeContext(
- *,
- cpus: int | None = None,
- memory: int | None = None,
- instance_type: str | None = None,
- storage: int | None = None,
- cluster_size: int | None = None,
- requirements: str | Path | io.IOBase | bytes | None = None,
- interactive: bool = False,
- workspace: str | UUID | Workspace | None = None,
- labels: list[str] | str | None = None,
- log_level: pcr.LogLevelSchema | None = None,
Compute context in which queries are executed.
The compute context is an abstraction of the underlying hardware (either a single node or multiple nodes in case of a cluster).
- Parameters:
- cpus
The minimum number of CPUs the compute context should have access to.
- memory
The minimum amount of RAM (in GB) the compute context should have access to.
- instance_type
The instance type to use.
- storage
The minimum amount of disk space (in GB) the compute context should have access to.
- cluster_size
The number of machines to spin up in the cluster. Defaults to
1
.- requirements
Path to a file or a file-like object [1] containing dependencies to install in the compute context, in the requirements.txt format.
- interactive
Whether to compute context should run in interactive mode. Defaults to
False
.- workspace
The workspace to run this context in. You may specify the name (str), the id (UUID) or the Workspace object.
- labels
Labels of the workspace (will be implicitly created)
- log_level
Override the log level of the context for debug purposes. One of
"info", "debug", "trace"
.
Notes
Note
If the
cpus
,memory
, andinstance_type
parameters are not set, the parameters are resolved with the default context specs of the workspace.Footnotes
Methods:
get_status
Get the status of the compute context.
start
Start the compute context.
stop
Stop the compute context.
list
List all compute contexts in the workspace.
connect
Reconnect with an already running compute context.
Attributes:
cpus
The number of CPUs the compute context has access to.
memory
The amount of RAM (in GB) the compute context has access to.
instance_type
The instance type of the compute context.
storage
The amount of disk space (in GB) the compute context has access to.
cluster_size
The number of compute nodes in the context.
interactive
Whether the compute context runs in interactive mode.
labels
The labels of the compute context.
workspace
The workspace to run the compute context in.
- get_status() ComputeContextStatus
Get the status of the compute context.
- start(*, wait: bool = False) None
Start the compute context.
This boots up the underlying node(s) of the compute context.
- Parameters:
- wait
Wait for the context to be ready before returning. If in interactive mode, always True.
- stop(*, wait: bool = False) None
Stop the compute context.
- Parameters:
- wait
Wait for the context to be stopped.
- classmethod list(workspace_id: UUID) list[Self]
List all compute contexts in the workspace.
- classmethod connect(workspace_id: UUID, compute_id: UUID) Self
Reconnect with an already running compute context.
- Parameters:
- workspace_id
The identifier of the Workspace
- compute_id
The unique identifier of the existing compute context.
- property cluster_size: int
The number of compute nodes in the context.
- property interactive: bool
Whether the compute context runs in interactive mode.
- property workspace: Workspace
The workspace to run the compute context in.