snowflake.core.service.ServiceCollection¶
- class snowflake.core.service.ServiceCollection(schema: SchemaResource)¶
- Bases: - SchemaObjectCollectionParent[- ServiceResource]- Represents the collection operations on the Snowflake Snowpark Container Service resource. - With this collection, you can create, update, iterate through, and fetch SPCSs that you have access to in the current context. - Examples - Creating a service instance: - >>> my_service = Service( ... name="my_service", ... min_instances=1, ... max_instances=2, ... compute_pool="my_compute_pool", ... spec=ServiceSpec("@my_stage/my_service_spec.yaml"), ... ) >>> root.databases["my_db"].schemas["my_schema"].services.create(my_service) - Attributes - database¶
- The DatabaseResource this collection belongs to. 
 - root¶
- The Root object this collection belongs to. 
 - Methods - create(service: Service, *, mode: CreateMode = CreateMode.error_if_exists) ServiceResource¶
- Create a Snowpark Container service in Snowflake. - Parameters:
- service (Service) – The - Serviceobject, together with the- Service’s properties: name, compute_pool, spec; auto_resume, min_instances, max_instances, status, external_access_integrations, query_warehouse, comment are optional.
- mode (CreateMode, optional) 
- values. (One of the following enum) 
- CreateMode.error_if_exists (Throw an - snowflake.core.exceptions.ConflictError)
- .... (create or replace service <name>) 
- CreateMode.or_replace (Replace if the service already exists in Snowflake. Equivalent to SQL) 
- .... 
- CreateMode.if_not_exists (Do nothing if the service already exists in Snowflake.) 
- exists... (Equivalent to SQL create service <name> if not) 
- CreateMode.error_if_exists. (Default is) 
 
 - Examples - Creating a service, replacing any existing service with the same name: - >>> services = root.databases["my_db"].schemas["my_schema"].services >>> my_service = Service( ... name="my_service", ... compute_pool="my_compute_pool", ... spec=ServiceSpec("@my_stage/my_service_spec.yaml"), ... ) >>> services.create(my_service, mode=CreateMode.or_replace) 
 - create_async(service: Service, *, mode: CreateMode = CreateMode.error_if_exists) PollingOperation[ServiceResource]¶
- An asynchronous version of - create().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - execute_job(job_service: JobService) ServiceResource¶
- Execute a Snowpark Container job service in Snowflake. - Parameters:
- job_service (JobService) – The - JobServiceobject, together with the- JobService’s properties: name, compute_pool, spec; status, external_access_integrations, query_warehouse, comment are optional
 - Examples - Executing a job service: - >>> job_service = JobService( ... name="my_job_service", compute_pool="my_cp", spec=ServiceSpec("@my_stage/my_service_spec.yaml") ... ) >>> services.execute_job(job_service) 
 - execute_job_async(job_service: JobService) PollingOperation[ServiceResource]¶
- An asynchronous version of - execute_job().- Refer to - PollingOperationfor 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, from_name: str | None = None) Iterator[Service]¶
- Iterate through - Serviceobjects from 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. 
- show_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- 1and- 10000.
- from_name (str, optional) – Fetch rows only following the first row whose object name matches the specified string. This is case-sensitive and does not have to be the full name. 
 
 - Examples - Showing all services that you have access to see: - >>> services = service_collection.iter() - Showing information of the exact service you want to see: - >>> services = service_collection.iter(like="your-service-name") - Showing services starting with ‘your-service-name-‘: - >>> services = service_collection.iter(like="your-service-name-%") - Using a for loop to retrieve information from iterator: - >>> for service in services: >>> print(service.name) 
 - iter_async(*, like: str | None = None, starts_with: str | None = None, limit: int | None = None, from_name: str | None = None) PollingOperation[Iterator[Service]]¶
- An asynchronous version of - iter().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - keys() KeysView[str]¶
 - update_reference(old_name: str, new_name: str, resource: T) None¶
- Update the collection with a new item. 
 - values() ValuesView[T]¶