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:

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:

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]