Skip to main content

What is AirflowDAGGenerator?

Dynamically generates Python Airflow DAG file based on given Jinja2 Template and YAML configuration to encourage reusable code. It also validates the correctness (by checking DAG contains cyclic dependency between tasks, invalid tasks, invalid arguments, typos etc.) of the generated DAG automatically by leveraging airflow DagBag, therefore it ensures the generated DAG is safe to deploy into Airflow.

Why is it useful?

Most of the time the Data processing DAG pipelines are same except the parameters like source, target, schedule interval etc. So having a dynamic DAG generator using a templating language can greatly benefit when you have to manage a large number of pipelines at enterprise level. Also it ensures code re-usability and standardizing the DAG, by having a standardized template. It also improves the maintainability and testing effort.

How is it Implemented?

By leveraging the de-facto templating language used in Airflow itself, that is Jinja2 and the standard YAML configuration to provide the parameters specific to a use case while generating the DAG.

Requirements

Python 3.6 or later

Note: Tested on 3.6, 3.7 and 3.8 python environments, see tox.ini for details

How to use this Package?

  1. First install the package using:

pip install airflowdaggenerator
  1. Airflow Dag Generator should now be available as a command line tool to execute. To verify run

airflowdaggenerator -h
  1. Airflow Dag Generator can also be run as follows:

python -m airflowdaggenerator -h

Sample Usage:

If you have installed the package then:
airflowdaggenerator \
    -config_yml_path path/to/config_yml_file \
    -config_yml_file_name  config_yml_file \
    -template_path path/to/jinja2_template_file \
    -template_file_name jinja2_template_file \
    -dag_path path/to/generated_output_dag_py_file \
    -dag_file_name generated_output_dag_py_file
OR
python -m airflowdaggenerator \
          -config_yml_path path/to/config_yml_file \
          -config_yml_file_name  config_yml_file \
          -template_path path/to/jinja2_template_file \
          -template_file_name jinja2_template_file \
          -dag_path path/to/generated_output_dag_py_file \
          -dag_file_name generated_output_dag_py_file

If you have cloned the project source code then you have sample jinja2 template and YAML configuration file present under tests/data folder, so you can test the behaviour by opening a terminal window under project root directory and run the following command:

python -m airflowdaggenerator \
          -config_yml_path ./tests/data \
          -config_yml_file_name dag_properties.yml \
          -template_path ./tests/data \
          -template_file_name sample_dag_template.py.j2 \
          -dag_path ./tests/data/output \
          -dag_file_name test_dag.py

And you can see that test_dag.py is created under ./tests/data/output folder.

Troubleshooting

In case you get some error while generating the dag using this package like (sqlite3.OperationalError)…, then please execute following command:

airflow initdb

Metadata

Release files for airflowdaggenerator 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for airflowdaggenerator 0.0.2
File Size Uploaded Provenance Actions
airflowdaggenerator-0.0.2.tar.gz 4.7 kB Without provenance Details for airflowdaggenerator-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for airflowdaggenerator 0.0.2
File Interpreter ABI Platform Actions
airflowdaggenerator-0.0.2-py3-none-any.whl Python 3 none any Details for airflowdaggenerator-0.0.2-py3-none-any.whl

Total release size: 13.6 kB

Release files / airflowdaggenerator-0.0.2.tar.gz

Download URL airflowdaggenerator-0.0.2.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c4301ffaa73a33abe04ec5205d20ebaeeb18e38b8f0da9cdcace61500986d1b3
BLAKE2b-256 checksum
How to use checksums
c906212da7e752966dd2f1763f65f115b19f77fad1a6f304e59a272ec895f808
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.1

Release files / airflowdaggenerator-0.0.2-py3-none-any.whl

Download URL airflowdaggenerator-0.0.2-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
306de6fb48efd90a207be0954f41935e3a2792e1a9527993c92cb8c380b8eb2d
BLAKE2b-256 checksum
How to use checksums
34039c0dda5197a4e2fac322ee99f4da265e092b2e583368ef30bdf832d5c658
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.1

Security for airflowdaggenerator 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page