Airflow GUI User Guide
Airflow GUI is a visual orchestration tool provided by DMS that is built on the open-source Airflow. It lets you create and manage Airflow Directed Acyclic Graph (DAG) tasks using a drag-and-drop interface, which eliminates the need to write Python code. This topic describes how to access the Airflow GUI, configure global settings and nodes, and publish tasks.
Prerequisites
You have set up the Airflow environment.
To use the email alerting feature, you must configure email in Airflow first. Use a custom email service.
Quick Start
Feature Entry Points
Log in to DMS 5.0.
From the top menu bar, select Data+AI > Workspace, or in Simplified Mode, click the
icon in the upper-left corner and select All Features > Data+AI > Workspace.On the workspace list page, click the ID of the target workspace to open it.
In the left navigation pane, click Resource Manager. In the blank area of the CODE module, right-click and select New Airflow File.
Workflow Canvas Overview
The GUI editor provides an intuitive visual canvas.
Left: The node panel. You can click the
button to select and add different types of task nodes.Middle: The main canvas. You can drag nodes, connect dependencies, and build your workflow on the canvas.
Right: The configuration panel. When you select a node or a blank area on the canvas, its corresponding configuration items appear in this panel.

Core Operations
Global Configuration: In the right-side panel, configure the global settings for the DAG, such as its name, scheduling policy, and alerts.
Add and Configure Nodes: Drag the required nodes from the left-side panel to the canvas and configure their basic and advanced settings in the right-side panel.
Set Dependencies: Drag the anchor points between nodes to establish upstream and downstream dependencies.
Save and Publish: After you design the workflow, save and publish it to the Airflow environment.
Core Concepts and Configuration Details
Global Configuration
In the top navigation bar, click the Global Configuration button to view the global configuration of the DAG.
Basic Information:
Name: Specifies the
DAG IDin Airflow. This ID must be unique in your Airflow environment.
Scheduling Configuration:
Cron Expression: Defines the periodic scheduling policy for the DAG.

Start/End Date: Defines the time range during which the DAG can be scheduled.
Alert Settings:
Configure email alerts for task failures, successes, or retries. You can separate multiple email addresses with commas.

Prerequisite: You must configure email services in Airflow before you can use email alerts.
Template Support: Alert titles and bodies support Jinja templates. You can dynamically insert built-in variables, such as
dagandti. The email body supports the HTML format.
Variables:
Define global variables that can be used in all tasks within the DAG. Variable values also support Jinja templates.
Retry Settings:
You can configure the global default retry count and retry interval for failed tasks.
Node Configurations
Each node that you add from the left-side panel has basic and advanced configurations. The advanced configurations are common to all nodes, whereas the basic configurations vary by node type.
Advanced Configurations (General)
Alert Configuration: Overrides the global alert settings to define an independent alert policy for the current node.
Retry: Overrides the global retry settings to define an independent retry policy for the current node.
Resource Pool Configuration: Specifies the Airflow resource pool (Pool) in which the task runs to control task concurrency.

Trigger Rule: Defines the execution conditions for the current task, such as "all upstream tasks successful" or "at least one upstream task successful".

Basic Configurations (by Node Type)
The following section describes the basic configurations for some common nodes:
Single-Instance SQL
Function: Executes a single SQL statement on the specified database instance.
Configuration: Select the instance and database, and then write the SQL statement directly or select an existing
.sqlfile in the workspace.
Callback Code (Optional): Specifies the Python code that runs after the SQL statement is successfully executed. The main uses are as follows:
Pass Data (XCom): Retrieve SQL query results using the built-in
resultvariable, which is a dictionary that contains adatakey, and pass the results to downstream tasks. For example,result['data'][0]['co']retrieves the value of the column namedcoin the first row of the result set.Result Validation: Checks the SQL results. If the conditions are not met, you can throw an exception to fail the task.
if len(result["data"]) > 10: raise Exception("too many data")
ADB Spark
Function: Submits jobs to the Spark engine of AnalyticDB for MySQL.
Configuration: Select the AnalyticDB for MySQL instance and resource group, and then configure the job based on the task type (SQL or BATCH).
SQL Task: Write the Spark SQL statement directly or select an
.sqlfile.
BATCH Task: Provide the Spark job configuration in JSON format.
{ "args": [ "1000" ], "className": "org.apache.spark.examples.SparkPi", "comments": [ "-- Here is just an example of SparkPi. Modify the content and run your spark program." ], "conf": { "spark.driver.resourceSpec": "medium", "spark.executor.instances": 2, "spark.executor.resourceSpec": "medium" }, "file": "local:///tmp/spark-examples.jar", "name": "SparkPi" }
Notebook
Function: Runs Notebook files in the workspace.
Configuration:
Select a Notebook session.
Select the path of the Notebook file. The file must be configured in the workspace, and the path must be a workspace file path.

Lindorm Spark
Function: Submits Lindorm Spark jobs.
Configuration:
Select a Lindorm instance.
Select the job type and configure the job parameters.

Lock-Free Data Change
Function: Executes data change SQL statements in a lock-free manner on the specified instance and database. The configuration method is the same as that for the Single-Instance SQL node. This node also supports callback code to process execution results.
Conditional Branch
Function: Determines the workflow path based on different conditions.
Configuration: Add multiple branch conditions. Each condition is a Python expression that returns
TrueorFalse. The expressions support Jinja templates and can reference Airflow variables.
Conditional branches have multiple downstream edges. You can drag and drop the edges to set them.

SSH Operations
Function: Connects to a remote server over SSH and executes commands.
Configuration:
Pre-configure the SSH connection information in Airflow's
Connectionsand obtain itsConnection ID.In the Edit Connection dialog box, set Connection Id to
ssh_ecs_default, select SSH for Connection Type, enter10.0.0.252for Host, enterrootfor Username, and then click Save.In the node configuration, enter the
Connection IDand the shell command to be executed.
Bash Task
Function: Executes Bash commands in the local environment.
Configuration:
Configure the Bash command to be executed.
Configure the environment variables for the command execution.

Time Interval
Function: Pauses the workflow for a specified period before it continues to execute subsequent nodes.
Wait for Specified Time
Function: Waits until a specified time before it continues to execute subsequent nodes. The target time can be dynamically set using the Airflow Jinja template syntax.
External Task Sensor
Function: Configures external task dependency checks. The workflow waits for an external DAG or task in the same Airflow instance to be completed before it continues execution.
Configuration:
Upstream DAG Name: The ID of the DAG on which the current DAG depends.

Upstream Node Name (Optional): The ID of the task on which the current task depends. If you leave this parameter empty, the workflow waits for the entire upstream DAG to be completed.
Empty Task
Function: A placeholder node that performs no action. You can use it to aggregate multiple upstream branches or as a logical start or end point to clarify the workflow structure.
Configuration: None.
Data Lake Integration
Function: Integrates data from a source database into a destination data lake.
Configuration:
Select the source database and the destination database.

Configure other parameters for the data integration task.

Set Dependencies
Add Dependencies: Hover the mouse pointer over the edge of a node to display an anchor point. Drag the anchor point from one node to another to create an edge that represents a dependency.

Delete Dependencies: Click an edge to select it and then press the
Deletekey.
Publish and Verify
Git Integration (Optional)
If your workspace is associated with a Git repository, you must commit the code to Git before you publish it.
Commit: Commit your changes in the Git panel.

Push: Push the commit to the remote repository.
Deploy to Airflow
Click the Deploy button in the upper-right corner of the editor. The system converts the workflow that you designed in the GUI into Python code and publishes the code to your Airflow environment.
Verify in Airflow
After the deployment is successful, log on to the Airflow UI. A new DAG appears. The DAG ID of the new DAG is the same as the name that you configured in the GUI. The DAG also has a generated tag, which indicates that the DAG was generated by the GUI. You can trigger, monitor, and manage the execution of the DAG in the Airflow UI.














