Uploading DAG files to a Managed Service for Apache Airflow™ cluster
A Managed Service for Apache Airflow™ cluster automatically loads DAG files from the configured source, such as the following:
Prepare a DAG file. You can find an example in this Apache Airflow™ guide
Importing DAG files from a bucket
When creating or updating a cluster, select a bucket as the source of DAG files and configure the bucket access permissions for the cluster’s service account.
-
Create a folder, e.g.,
dags, in the selected bucket and upload your DAG file to it. If the DAG uses additional scripts or modules, upload them along with the DAG.You can upload your DAG file to the bucket root, but it uploads quicker to a folder.
-
Make sure that the new DAG has appeared in the DAGs section. It may take a few minutes to load a DAG file from the bucket.
Importing DAG files from a Git repository
When creating or updating a cluster, select a Git repository as the source of DAG files. Specify the repository URL, branch, DAG files directory, and authentication parameters.
Warning
To use a Git repository, configure internet access through a NAT gateway from the Managed Service for Apache Airflow™ cluster network. When configuring it, link a NAT gateway route table to all the cluster subnets.
- Add the DAG file to the Git repository directory specified in the cluster settings. If the DAG uses additional scripts or modules, add them along with the DAG.
- Push your changes to the remote branch specified in the cluster settings. If you are working with a local repository copy, create a commit and push it to that branch.
- Open the Apache Airflow™ web interface.
- Make sure that the new DAG has appeared in the DAGs section. It may take a few minutes to import your DAG file from the Git repository.
Using additional scripts and modules
If a DAG uses additional scripts or modules, upload them along with the DAG file to the bucket or Git repository. In the DAG file, specify the full path to these scripts or modules. Let’s say, you have uploaded all files to the dags folder. In this case, specify the following in the from ... import construct:
from dags.<file_name> import <object>