snowflake.core.compute_pool.ComputePoolCollection | Snowflake Documentation (original) (raw)
class snowflake.core.compute_pool.ComputePoolCollection(root: Root)¶
Bases: AccountObjectCollectionParent
[ComputePoolResource]
Represents the collection operations on the Snowflake Compute Pool resource.
With this collection, you can create, iterate through, and search for compute pools that you have access to in the current context.
Examples
Creating a compute pool instance:
compute_pool = ComputePool(name="my_compute_pool", instance_family="CPU_X64_XS", min_nodes=1, max_nodes=2) compute_pool_reference = root.compute_pools.create(compute_pool)
Attributes
root¶
The Root object this collection belongs to.
Methods
create(compute_pool: ComputePoolModel, *, mode: CreateMode = CreateMode.error_if_exists, initially_suspended: bool = False) → ComputePoolResource¶
Create a compute pool in Snowflake.
Parameters:
- compute_pool (ComputePool) – The
ComputePool
object, together with theComputePool
’s properties: name, min_nodes, max_nodes, instance_family; auto_resume, initially_suspended, auto_suspend_secs, comment are optional - mode (CreateMode, optional) –
One of the below enum values.CreateMode.error_if_exists
: Throw an snowflake.core.exceptions.ConflictError if the compute pool already exists in Snowflake. Equivalent to SQLcreate compute pool <name> ...
.CreateMode.if_not_exists
: Do nothing if the compute pool already exists in Snowflake. Equivalent to SQLcreate compute pool <name> if not exists...
.
Default value isCreateMode.error_if_exists
. - initially_suspended (bool , optional) – Determines if the compute pool should be suspended when initially created. Default value is False.
Examples
Creating a compute pool, replacing an existing compute pool with the same name:
compute_pool = ComputePool(name='my_compute_pool', instance_family="CPU_X64_XS", min_nodes=1, max_nodes=2) compute_pool_reference = compute_pools.create(compute_pool, mode=CreateMode.or_replace)
Creating a compute pool that is initially suspended:
compute_pool = ComputePool(name='my_compute_pool', instance_family="CPU_X64_XS", min_nodes=1, max_nodes=5) compute_pool_reference = compute_pools.create(compute_pool, initially_suspended=True)
create_async(compute_pool: ComputePoolModel, *, mode: CreateMode = CreateMode.error_if_exists, initially_suspended: bool = False) → PollingOperation[ComputePoolResource]¶
An asynchronous version of create().
Refer to PollingOperation for more information on asynchronous execution and the return type.
items() → ItemsView[str, T]¶
iter(*, like: str | None = None, starts_with: str | None = None, limit: int | None = None) → Iterator[ComputePoolModel]¶
Iterate through Compute Pool
objects in Snowflake, filtering on any optional ‘like’ pattern.
Parameters:
- like (str , optional) – A case-insensitive string functioning as a filter, with support for SQL wildcard characters (% and _).
- starts_with (str , optional) – String used to filter the command output based on the string of characters that appear at the beginning of the object name. Uses case-sensitive pattern matching.
- limit (int , optional) – Limit of the maximum number of rows returned by iter(). The default is
None
, which behaves equivalently to show_limit=10000. This value must be between1
and10000
.
Examples
Showing all compute pools that you have access to see:
compute_pools = root.compute_pools.iter()
Showing information of the exact compute pool you want to see:
compute_pools = root.compute_pools.iter(like="your-compute-pool-name")
Showing compute pools starting with ‘your-compute-pool-name-‘:
compute_pools = root.compute_pools.iter(like="your-compute-pool-name-%")
Using a for loop to retrieve information from iterator:
for compute_pool in compute_pools: print(compute_pool.name)
iter_async(*, like: str | None = None, starts_with: str | None = None, limit: int | None = None) → PollingOperation[Iterator[ComputePoolModel]]¶
An asynchronous version of iter().
Refer to PollingOperation for more information on asynchronous execution and the return type.
keys() → KeysView[str]¶
values() → ValuesView[T]¶