|
1 | | -""" |
2 | | -
|
3 | | -Ce dag permet d'exécuter des commandes dbt. |
4 | | -
|
5 | | -""" |
6 | | - |
7 | 1 | from datetime import datetime, timedelta |
8 | 2 |
|
9 | 3 | from airflow.models.param import Param |
|
22 | 16 | } |
23 | 17 |
|
24 | 18 | with DAG( |
25 | | - "dbt_selector_dag", |
| 19 | + "dbt_build", |
26 | 20 | default_args=default_args, |
27 | | - description="Exécute des commandes DBT avec un sélecteur", |
| 21 | + description="Exécute des commandes DBT", |
28 | 22 | schedule_interval=None, |
29 | 23 | start_date=datetime(2024, 1, 1), |
30 | 24 | catchup=False, |
31 | 25 | params={ |
32 | | - "select": Param(default="default", type="string", description="Sélecteur DBT à utiliser pour l'exécution"), |
33 | 26 | "command": Param( |
34 | | - default="build", |
| 27 | + default="dbt build -s", |
35 | 28 | type="string", |
36 | | - description="Commande DBT à exécuter (build, run, test, etc.)", |
37 | | - enum=["build", "run", "test", "compile", "debug", "deps", "clean"], |
38 | 29 | ), |
39 | 30 | }, |
40 | 31 | ) as dag: |
41 | | - # Validation du sélecteur |
42 | | - validate_selector = BashOperator( |
43 | | - task_id="validate_selector", |
44 | | - bash_command=get_dbt_command_from_directory("dbt ls --select {{ params.select }} || exit 1"), |
45 | | - ) |
46 | | - |
47 | | - # Exécution de dbt avec le sélecteur |
48 | 32 | execute_dbt = BashOperator( |
49 | 33 | task_id="execute_dbt", |
50 | | - bash_command=get_dbt_command_from_directory("dbt {{ params.command }} --select {{ params.select }}"), |
| 34 | + bash_command=get_dbt_command_from_directory("{{ params.command }}"), |
51 | 35 | ) |
52 | 36 |
|
53 | | - validate_selector >> execute_dbt |
| 37 | + execute_dbt |
0 commit comments