snowflake.core.task.dagv1.DAGOperationΒΆ

class snowflake.core.task.dagv1.DAGOperation(schema: SchemaResource)ΒΆ

Bases: object

APIs to manage task graph child task operations.

Methods

delete(dag: DAG | str) β†’ NoneΒΆ

The delete method is deprecated; use drop instead.

deploy(dag: DAG, mode: CreateMode = CreateMode.error_if_exists) β†’ NoneΒΆ

Deploys (create) this task graph including all child tasks under a specific schema in Snowflake.

Parameters:
  • dag (The DAG instance.)

  • mode (CreateMode, optional) –

    One of the following strings.

    CreateMode.error_if_exists: Throw an snowflake.core.exceptions.ConflictError if the task already exists in Snowflake. Equivalent to SQL create task <name> ....

    CreateMode.or_replace: Replace if the task already exists in Snowflake. Equivalent to SQL create or replace task <name> ....

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

    Default value is CreateMode.error_if_exists.

drop(dag: DAG | str) β†’ NoneΒΆ

Remove a task graph and all child tasks.

Parameters:

dag (Union[DAG, str]) – Name of the task graph to be dropped or a DAG instance.

Examples

Drop a task graph:

>>> dag_op.drop("your-dag-name")
Copy
get_complete_dag_runs(dag: DAG | str, *, error_only: bool = True) β†’ List[DAGRun]ΒΆ

Get the complete task graph runs within 60 minutes in Snowflake.

Parameters:
  • dag (Union[DAG, str]) – The task graph to get the task graph runs.

  • error_only (bool, optional) – If True, only return the task graph runs that have failed. Default is True.

Examples

Get the complete task graph runs:

>>> dag_op.get_complete_dag_runs("your-dag-name")
Copy
get_current_dag_runs(dag: DAG | str) β†’ List[DAGRun]ΒΆ

Get the current task graph runs or next schedule dag run for next 8 days in Snowflake.

Parameters:

dag (Union[DAG, str]) – The task graph to get the task graph runs.

Examples

Get the current task graph runs:

>>> dag_op.get_current_dag_runs("your-dag-name")
Copy
iter_dags(*, like: str) β†’ List[str]ΒΆ

Return the task graph names under this schema.

Parameters:

like (str) – A case-insensitive string functioning as a filter, with support for SQL wildcard characters (% and _).

Examples

Get all task graph names under the schema:

>>> dags = dag_op.iter_dags(like="your-dag-name")
Copy
run(dag: DAG | str, *, retry_last: bool = False) β†’ NoneΒΆ

Execute the task graph once without waiting for the schedule.

It resumes the task graph then executes it.

Parameters:

retry_last (bool, optional) – Re-execute the last failed task of the task graph. Default is False.

Examples

Run a task graph:

>>> dag_op.run("your-dag-name")
Copy