|
| 1 | +""" |
| 2 | +DAG to anonymize QFDMO acteur which names |
| 3 | +contains people from Annuaire Entreprise (AE) |
| 4 | +""" |
| 5 | + |
| 6 | +from airflow import DAG |
| 7 | +from enrich.config import ( |
| 8 | + COHORTS, |
| 9 | + DBT, |
| 10 | + TASKS, |
| 11 | + EnrichActeursClosedConfig, |
| 12 | +) |
| 13 | +from enrich.tasks.airflow_logic.enrich_config_create_task import ( |
| 14 | + enrich_config_create_task, |
| 15 | +) |
| 16 | +from enrich.tasks.airflow_logic.enrich_dbt_model_suggest_task import ( |
| 17 | + enrich_dbt_model_suggest_task, |
| 18 | +) |
| 19 | +from enrich.tasks.airflow_logic.enrich_dbt_models_refresh_task import ( |
| 20 | + enrich_dbt_models_refresh_task, |
| 21 | +) |
| 22 | +from shared.config import CATCHUPS, SCHEDULES, START_DATES, config_to_airflow_params |
| 23 | + |
| 24 | +with DAG( |
| 25 | + dag_id="enrich_acteurs_closed", |
| 26 | + dag_display_name="🚪 Enrichir - Acteurs Fermés", |
| 27 | + default_args={ |
| 28 | + "owner": "airflow", |
| 29 | + "depends_on_past": False, |
| 30 | + "email_on_failure": False, |
| 31 | + "email_on_retry": False, |
| 32 | + "retries": 0, |
| 33 | + }, |
| 34 | + description=( |
| 35 | + "Un DAG pour détécter et remplacer les acteurs fermés" |
| 36 | + "dans l'Annuaire Entreprises (AE)" |
| 37 | + ), |
| 38 | + tags=["annuaire", "entreprises", "ae", "siren", "siret", "acteurs", "fermés"], |
| 39 | + schedule=SCHEDULES.NONE, |
| 40 | + catchup=CATCHUPS.AWLAYS_FALSE, |
| 41 | + start_date=START_DATES.YESTERDAY, |
| 42 | + params=config_to_airflow_params( |
| 43 | + EnrichActeursClosedConfig( |
| 44 | + dbt_models_refresh=False, |
| 45 | + dbt_models_refresh_command=( |
| 46 | + "dbt build --select tag:marts,tag:enrich,tag:closed" |
| 47 | + ), |
| 48 | + filter_equals__acteur_statut="ACTIF", |
| 49 | + ) |
| 50 | + ), |
| 51 | +) as dag: |
| 52 | + # Instantiation |
| 53 | + config = enrich_config_create_task(dag) |
| 54 | + dbt_refresh = enrich_dbt_models_refresh_task(dag) |
| 55 | + suggest_not_replaced = enrich_dbt_model_suggest_task( |
| 56 | + dag, |
| 57 | + task_id=TASKS.ENRICH_CLOSED_SUGGESTIONS_NOT_REPLACED, |
| 58 | + cohort=COHORTS.CLOSED_NOT_REPLACED, |
| 59 | + dbt_model_name=DBT.MARTS_ENRICH_AE_CLOSED_NOT_REPLACED, |
| 60 | + ) |
| 61 | + suggest_other_siren = enrich_dbt_model_suggest_task( |
| 62 | + dag, |
| 63 | + task_id=TASKS.ENRICH_CLOSED_SUGGESTIONS_OTHER_SIREN, |
| 64 | + cohort=COHORTS.CLOSED_REP_OTHER_SIREN, |
| 65 | + dbt_model_name=DBT.MARTS_ENRICH_AE_CLOSED_REPLACED_OTHER_SIREN, |
| 66 | + ) |
| 67 | + suggest_same_siren = enrich_dbt_model_suggest_task( |
| 68 | + dag, |
| 69 | + task_id=TASKS.ENRICH_CLOSED_SUGGESTIONS_SAME_SIREN, |
| 70 | + cohort=COHORTS.CLOSED_REP_SAME_SIREN, |
| 71 | + dbt_model_name=DBT.MARTS_ENRICH_AE_CLOSED_REPLACED_SAME_SIREN, |
| 72 | + ) |
| 73 | + |
| 74 | + # Graph |
| 75 | + config >> dbt_refresh # type: ignore |
| 76 | + dbt_refresh >> suggest_not_replaced # type: ignore |
| 77 | + dbt_refresh >> suggest_other_siren # type: ignore |
| 78 | + dbt_refresh >> suggest_same_siren # type: ignore |
0 commit comments