Directed Acyclic Graph (DAG)
In Cloudera Workflow Orchestrator, a workflow is defined as a DAG. Using a DAG file, Cloudera Workflow Orchestrator parses the script, schedules the tasks, and runs them in the defined order.
A DAG is a collection of all the tasks you want to run, organized in a way that reflects their
relationships and dependencies. A DAG is characterized by the following properties:
- Directed – The workflow has a specific direction (Task A → Task B).
- Acyclic – The workflow cannot loop back on itself- preventing infinite cycles.
- Graph – A structure consisting of nodes (tasks) and edges (dependencies).
A DAG, includes the following key attributes that define its behavior:
- Schedule – Specifies when the workflow is triggered to run.
- Tasks – Defines discrete units of work that are run on workers.
- Task dependencies – Determines the order and conditions under which tasks run.
- Callbacks – Specifies actions to take when the entire workflow completes.
- Additional parameters – Provides further operational details.
The following example shows a basic DAG
structure:
from datetime import datetime
from airflow.sdk import DAG, task
from airflow.providers.standard.operators.bash import BashOperator
# A Dag represents a workflow, a collection of tasks
with DAG(dag_id="demo", start_date=datetime(2026, 1, 1), schedule="0 0 * * *") as dag:
# Tasks are represented as operators
hello = BashOperator(task_id="hello", bash_command="echo hello")
@task()
def airflow():
print("airflow")
# Set dependencies between tasks
hello >> airflow()The example defines the following components:
- A DAG named
demoA workflow scheduled to run daily starting onJanuary 1st, 2022. - Two tasks – One using a
BashOperatorto run a shell script, and another using the@taskdecorator to define a Python function. - The
>>operator – A dependency marker that links the two tasks and controls the execution order.
