snowflake.core.task.dagv1.DAGOperation

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

Bases: object

Represents a client that has the convenient APIs to manage child tasks of a DAG in the Snowflake database.

Attributes

schema

The schema that the DAG child tasks will be read from or create into.

Methods

__init__(schema: SchemaResource) None
delete(dag: DAG | str) None

Remove a DAG and all child tasks.

Parameters:

dag – Name of the DAG to be deleted or a DAG instance.

deploy(dag: DAG, mode: CreateMode = CreateMode.error_if_exists) None

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

Parameters:
  • dag – The DAG instance.

  • mode

    One of the following enum values.

    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

get_complete_dag_runs(dag: DAG | str, *, error_only: bool = True) List[DAGRun]

Get the complete DAG runs within 60 minutes in Snowflake.

get_current_dag_runs(dag: DAG | str) List[DAGRun]

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

iter_dags(*, like: str) List[str]

Return the DAG names under this schema.

Parameters:

like – The pattern of the DAG name. Use % represent any number of characters and ? for a single character.

run(dag: DAG | str, *, retry_last: bool = False) None

Execute the DAG once without waiting for the schedule.

It resumes the DAG then executes it.

Parameters:

retry_last – Re-execute the last failed task of the DAG.