Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
dcf5429
Add jinja2 template example
pankajastro Jun 30, 2025
f688669
Fix some import
pankajastro Jun 30, 2025
8e724ef
Fix some import
pankajastro Jun 30, 2025
0da4e57
Fix test
pankajastro Jun 30, 2025
e3bf811
Fix unit tests
pankajastro Jun 30, 2025
081c67b
Fix unit tests
pankajastro Jun 30, 2025
35de485
cleanup
pankajastro Jun 30, 2025
7a95ea6
Install Airflow 3.0.2
pankajastro Jun 30, 2025
2c06ec0
Install Airflow 3.0.2
pankajastro Jun 30, 2025
9c4d9fc
Force reinstall
pankajastro Jun 30, 2025
567aff0
Force reinstall
pankajastro Jun 30, 2025
52658ae
change pythonpath
pankajastro Jun 30, 2025
64bc5ec
Remove reinstall
pankajastro Jun 30, 2025
3864782
Not use dag.test
pankajastro Jun 30, 2025
07ec3c2
Not use dag.test
pankajastro Jun 30, 2025
64e9099
Add more linting rule
pankajastro Jun 30, 2025
3cd420d
use no cache
pankajastro Jun 30, 2025
ac94c0e
Force to install apache-airflow>3.0.2
pankajastro Jun 30, 2025
d89c941
Force to install apache-airflow>3.0.2
pankajastro Jun 30, 2025
2557b0b
Force to install apache-airflow>=3.0.2
pankajastro Jun 30, 2025
be68b9e
Force to install apache-airflow>=3.0.2
pankajastro Jun 30, 2025
79ad54c
Force reinstall airflow 3
pankajastro Jun 30, 2025
f81b5fe
Install cncf
pankajastro Jun 30, 2025
4a41484
Install cncf
pankajastro Jun 30, 2025
8925000
Install cncf
pankajastro Jun 30, 2025
90bb092
Fix static check
pankajastro Jun 30, 2025
2b863a8
Revert CI changes
pankajastro Jul 8, 2025
ebdd7a7
Revert CI changes
pankajastro Jul 8, 2025
b2614b8
Revert CI changes
pankajastro Jul 8, 2025
2824d5a
Merge branch 'main' into jinja_template_example
pankajastro Jul 8, 2025
635e0cf
Revert CI changes
pankajastro Jul 8, 2025
cd8fa89
Merge branch 'main' into jinja_template_example
pankajastro Jul 10, 2025
bc63f7c
Fix tests
pankajastro Jul 10, 2025
ec7f67b
Update dag
pankajastro Jul 10, 2025
c39879d
Revert some changes
pankajastro Jul 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions dev/dags/example_jinja2_template_dag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os
from pathlib import Path

# The following import is here so Airflow parses this file
# from airflow import DAG
import dagfactory

DEFAULT_CONFIG_ROOT_DIR = "/usr/local/airflow/dags/"
Comment thread
tatiana marked this conversation as resolved.
CONFIG_ROOT_DIR = Path(os.getenv("CONFIG_ROOT_DIR", DEFAULT_CONFIG_ROOT_DIR))

config_file = str(CONFIG_ROOT_DIR / "example_jinja2_template_dag.yml")
example_dag_factory = dagfactory.DagFactory(config_file)

# Creating task dependencies
example_dag_factory.clean_dags(globals())
example_dag_factory.generate_dags(globals())
16 changes: 16 additions & 0 deletions dev/dags/example_jinja2_template_dag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
example_jinja2_template_dag:
default_args:
start_date: "2025-01-01"
schedule_interval: "@daily"
description: "A DAG that uses Airflow's built-in Jinja templates"
catchup: false
tasks:
print_run_id:
operator: "airflow.operators.bash.BashOperator"
bash_command: "echo 'run-id is {{ run_id }}'"

print_task:
operator: "airflow.operators.bash.BashOperator"
bash_command: "echo 'The task is {{ task }}'"
dependencies:
- print_run_id
9 changes: 9 additions & 0 deletions docs/configuration/jinja2_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Jinja2 Template

This example shows how to use [Apache Airflow®](https://airflow.apache.org/) built-in Jinja templating within a YAML-based DAG definition using DAG-Factory

## Example DAG

```yaml
--8<-- "dev/dags/example_jinja2_template_dag.yml"
```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ nav:
- configuration/environment_variables.md
- configuration/defaults.md
- configuration/params.md
- configuration/jinja2_template.md
- configuration/schedule.md
- Features:
- features/dynamic_tasks.md
Expand Down