snowflake.core.compute_pool.ComputePoolCollection

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)
Copy

Attributes

root

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 the ComputePool’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 SQL create compute pool <name> ....

    CreateMode.if_not_exists: Do nothing if the compute pool already exists in Snowflake. Equivalent to SQL create compute pool <name> if not exists....

    Default value is CreateMode.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)
Copy

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)
Copy
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 between 1 and 10000.

Examples

Showing all compute pools that you have access to see:

>>> compute_pools = root.compute_pools.iter()
Copy

Showing information of the exact compute pool you want to see:

>>> compute_pools = root.compute_pools.iter(like="your-compute-pool-name")
Copy

Showing compute pools starting with ‘your-compute-pool-name-‘:

>>> compute_pools = root.compute_pools.iter(like="your-compute-pool-name-%")
Copy

Using a for loop to retrieve information from iterator:

>>> for compute_pool in compute_pools:
>>>     print(compute_pool.name)
Copy
keys() KeysView[str]
values() ValuesView[T]
Language: English