snowflake.core.task.TaskResource¶
- class snowflake.core.task.TaskResource(name: str, collection: TaskCollection)¶
- Bases: - SchemaObjectReferenceMixin[- TaskCollection]- Represents a reference to a Snowflake Task resource. - Attributes - database¶
- The DatabaseResource this reference belongs to. 
 - fully_qualified_name¶
- Return the fully qualified name of the object this reference points to. 
 - root¶
- The Root object this reference belongs to. 
 - Methods - create_or_alter(task: Task) None¶
- Create a task in Snowflake or alter one if it already exists. - The Snowflake task’s properties will be updated to the properties of the input - taskif the task already exists. Note that the full picture of a task is expected. If a property isn’t set a value in the input- task, the property will be set to- NULLin Snowflake too because it’s regarded as the expected value.- Examples - >>> task_parameters = Task(name="your-task-name", definition="select 1") - # Using a - TaskCollectionto create a reference to task in Snowflake server:- >>> root.warehouses["your-task-name"].create_or_alter(task_parameters) 
 - create_or_alter_async(task: Task) PollingOperation[None]¶
- An asynchronous version of - create_or_alter().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - create_or_update(task: Task) None¶
- The - create_or_update()method is deprecated; use- create_or_alter()instead.
 - drop(if_exists: bool | None = None) None¶
- Drop this task. - Parameters:
- if_exists (bool, optional) – Check the existence of this task before dropping it. Default is - None, which is equivalent to- False.
 - Examples - Deleting a task using its reference: - >>> task_reference.drop() 
 - drop_async(if_exists: bool | None = None) PollingOperation[None]¶
- An asynchronous version of - drop().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - execute(*, retry_last: bool = False) None¶
- Execute the task immediately without waiting for the schedule. - Parameters:
- retry_last (bool, optional) – Re-execute the last failed task of the DAG. Default is - False.
 - Examples - Execute a task using its reference: - >>> task_reference.execute() 
 - execute_async(*, retry_last: bool = False) PollingOperation[None]¶
- An asynchronous version of - execute().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - fetch() Task¶
- Fetch the task resource. - Examples - Fetching a task using its reference: - >>> task = task_reference.fetch() - Accessing information of the task with task instance: - >>> print(task.name, task.comment) 
 - fetch_async() PollingOperation[Task]¶
- An asynchronous version of - fetch().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - fetch_task_dependents() list[Task]¶
- Return the list of child tasks that use this task as the root in a DAG. - Examples - Fetching the child tasks of a task using its reference: - >>> child_tasks = task_reference.fetch_task_dependents() 
 - fetch_task_dependents_async() PollingOperation[list[Task]]¶
- An asynchronous version of - fetch_task_dependents().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - get_complete_graphs(*, error_only: bool = True) Iterable[TaskRun]¶
- Return the status of a completed graph run. - It returns details for runs that executed successfully, failed, or were cancelled in the past 60 minutes. - To retrieve the details for graph runs that are currently executing, or are next scheduled to run within the next 8 days, use - get_current_graphs().- Parameters:
- error_only (bool, optional) – Return only the graph runs that have failed. Default is - True.
 - Examples - Getting the completed graph runs of a task using its reference: - >>> completed_graphs = task_reference.get_complete_graphs() 
 - get_complete_graphs_async(*, error_only: bool = True) PollingOperation[Iterable[TaskRun]]¶
- An asynchronous version of - get_complete_graphs().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - get_current_graphs() Iterable[TaskRun]¶
- Return the status of a graph run that is currently scheduled or is executing. - It returns details for graph runs that are currently executing or are next scheduled to run within the next 8 days. To retrieve the details for graph runs that have completed in the past 60 minutes, use - get_complete_graphs().- Examples - Getting the current graph runs of a task using its reference: - >>> current_graphs = task_reference.get_current_graphs() 
 - get_current_graphs_async() PollingOperation[Iterable[TaskRun]]¶
- An asynchronous version of - get_current_graphs().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - resume() None¶
- Resume the task then it will run on the schedule. - Examples - Resume a task using its reference: - >>> task_reference.resume() 
 - resume_async() PollingOperation[None]¶
- An asynchronous version of - resume().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - suspend() None¶
- Suspend the task so it won’t run again on the schedule. - Examples - Suspend a task using its reference: - >>> task_reference.suspend() 
 - suspend_async() PollingOperation[None]¶
- An asynchronous version of - suspend().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.