Skip to content

Commit

Permalink
feat(population): add dbt step to airflow dag(
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisig committed Nov 18, 2024
1 parent e8dc95e commit 453d741
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 9 additions & 1 deletion airflow/dags/ingest_population.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import pandas as pd
from airflow.decorators import dag, task
from include.container import Container
from include.pools import DBT_POOL
from include.utils import get_dbt_command_from_directory
from pendulum import datetime

URL = "https://www.insee.fr/fr/statistiques/fichier/3698339/base-pop-historiques-1876-2021.xlsx"
Expand Down Expand Up @@ -42,8 +44,14 @@ def ingest(path_on_bucket) -> int | None:
os.remove(tmp_localpath)
return row_count

@task.bash(pool=DBT_POOL)
def dbt_build() -> str:
return get_dbt_command_from_directory(cmd="dbt build -s +insee+")

path_on_bucket = download()
ingest(path_on_bucket)
ingest_task = ingest(path_on_bucket)

path_on_bucket >> ingest_task >> dbt_build()


ingest_population()
4 changes: 0 additions & 4 deletions airflow/include/sql/sparte/models/majic/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ models:
- name: departement
data_tests:
- not_null
- unique
- has_all_departements
- relationships:
to: ref('departement')
Expand All @@ -44,7 +43,6 @@ models:
- name: epci
data_tests:
- not_null
- unique
- has_all_epcis
- relationships:
to: ref('epci')
Expand All @@ -54,7 +52,6 @@ models:
- name: region
data_tests:
- not_null
- unique
- has_all_regions
- relationships:
to: ref('region')
Expand All @@ -64,7 +61,6 @@ models:
- name: scot
data_tests:
- not_null
- unique
- has_all_scots
- relationships:
to: ref('scot')
Expand Down

0 comments on commit 453d741

Please sign in to comment.