@@ -26,35 +26,30 @@ def make_path_from_env(env: str, alternative_path: Path) -> Path:
2626 return Path (os .getenv (env ) or alternative_path )
2727
2828
29- print ("""
30- ##########
31- # Config #
32- ##########
33- """ )
34-
29+ ALL_CONFIG = {}
3530
3631# Nombre maximal de workers utilisables par Prefect. Défaut : 16
3732MAX_PREFECT_WORKERS = int (os .getenv ("MAX_PREFECT_WORKERS" , 4 ))
38- print ( f" { ' MAX_PREFECT_WORKERS' :<40 } " , MAX_PREFECT_WORKERS )
33+ ALL_CONFIG [ " MAX_PREFECT_WORKERS" ] = MAX_PREFECT_WORKERS
3934
4035# Durée avant l'expiration du cache des ressources (en heure). Défaut : 168 (7 jours)
4136CACHE_EXPIRATION_TIME_HOURS = int (os .getenv ("CACHE_EXPIRATION_TIME_HOURS" , 168 ))
42- print ( f" { ' CACHE_EXPIRATION_TIME_HOURS' :<40 } " , CACHE_EXPIRATION_TIME_HOURS )
37+ ALL_CONFIG [ " CACHE_EXPIRATION_TIME_HOURS" ] = CACHE_EXPIRATION_TIME_HOURS
4338
4439
4540DATE_NOW = datetime .now ().isoformat ()[0 :10 ] # YYYY-MM-DD
4641MONTH_NOW = DATE_NOW [:7 ] # YYYY-MM
4742
4843# Publication ou non des fichiers produits sur data.gouv.fr
4944DECP_PROCESSING_PUBLISH = os .getenv ("DECP_PROCESSING_PUBLISH" , "" ).lower () == "true"
50- print ( f" { ' DECP_PROCESSING_PUBLISH' :<40 } " , DECP_PROCESSING_PUBLISH )
45+ ALL_CONFIG [ " DECP_PROCESSING_PUBLISH" ] = DECP_PROCESSING_PUBLISH
5146
5247
5348# Client HTTP
5449HTTP_CLIENT = httpx .Client ()
5550HTTP_HEADERS = {
5651 "Connection" : "keep-alive" ,
57- "User-agent" : "Projet : https:// decp.info/a-propos | Client HTTP : https://pypi.org/project/httpx/ " ,
52+ "User-agent" : "decp.info" ,
5853}
5954
6055# Timeout pour la publication de chaque ressource sur data.gouv.fr
@@ -77,21 +72,22 @@ def make_path_from_env(env: str, alternative_path: Path) -> Path:
7772
7873# Dossier racine
7974BASE_DIR = make_path_from_env ("DECP_BASE_DIR" , Path (__file__ ).absolute ().parent .parent )
80- print ( f" { ' BASE_DIR' :<40 } " , BASE_DIR )
75+ ALL_CONFIG [ " BASE_DIR" ] = BASE_DIR
8176
8277# Les variables configurées sur le serveur doivent avoir la priorité
8378DATA_DIR = make_path_from_env ("DECP_DATA_DIR" , BASE_DIR / "data" )
8479DATA_DIR .mkdir (exist_ok = True , parents = True )
85- print ( f" { ' DATA_DIR' :<40 } " , DATA_DIR )
80+ ALL_CONFIG [ " DATA_DIR" ] = DATA_DIR
8681
8782RESOURCE_CACHE_DIR = make_path_from_env (
8883 "RESOURCE_CACHE_DIR" , DATA_DIR / "resource_cache"
8984)
9085RESOURCE_CACHE_DIR .mkdir (exist_ok = True , parents = True )
86+ ALL_CONFIG ["RESOURCE_CACHE_DIR" ] = RESOURCE_CACHE_DIR
9187
9288DIST_DIR = make_path_from_env ("DECP_DIST_DIR" , BASE_DIR / "dist" )
9389DIST_DIR .mkdir (exist_ok = True , parents = True , mode = 777 )
94- print ( f" { ' DIST_DIR' :<40 } " , DIST_DIR )
90+ ALL_CONFIG [ " DIST_DIR" ] = DIST_DIR
9591
9692
9793def make_sirene_data_dir (sirene_data_parent_dir ) -> Path :
@@ -116,19 +112,19 @@ def make_sirene_data_dir(sirene_data_parent_dir) -> Path:
116112 SIRENE_DATA_DIR = Path (os .path .join (BASE_DIR , SIRENE_DATA_DIR ))
117113
118114# SIRENE_DATA_DIR on ne le crée que si nécessaire, dans flows.py
119- print ( f" { ' SIRENE_DATA_PARENT_DIR' :<40 } " , SIRENE_DATA_PARENT_DIR )
120- print ( f" { ' SIRENE_DATA_DIR' :<40 } " , SIRENE_DATA_DIR )
115+ ALL_CONFIG [ " SIRENE_DATA_PARENT_DIR" ] = SIRENE_DATA_PARENT_DIR
116+ ALL_CONFIG [ " SIRENE_DATA_DIR" ] = SIRENE_DATA_DIR
121117
122118
123119SIRENE_UNITES_LEGALES_URL = os .getenv ("SIRENE_UNITES_LEGALES_URL" , "" )
124120
125121# Mode de scraping
126122SCRAPING_MODE = os .getenv ("SCRAPING_MODE" , "month" )
127- print ( f" { ' SCRAPING_MODE' :<40 } " , SCRAPING_MODE )
123+ ALL_CONFIG [ " SCRAPING_MODE" ] = SCRAPING_MODE
128124
129125# Target (plateforme cible pour le scraping)
130126SCRAPING_TARGET = os .getenv ("SCRAPING_TARGET" )
131- print ( f" { ' SCRAPING_TARGET' :<40 } " , SCRAPING_TARGET )
127+ ALL_CONFIG [ " SCRAPING_TARGET" ] = SCRAPING_TARGET
132128
133129# Lecture ou non des ressource en cache
134130DECP_USE_CACHE = os .getenv ("DECP_USE_CACHE" , "false" ).lower () == "true"
@@ -138,6 +134,7 @@ def make_sirene_data_dir(sirene_data_parent_dir) -> Path:
138134
139135# Données de référence
140136REFERENCE_DIR = BASE_DIR / "reference"
137+ ALL_CONFIG ["REFERENCE_DIR" ] = REFERENCE_DIR
141138
142139# Liste et ordre des colonnes pour le mono dataframe de base (avant normalisation et spécialisation)
143140# Sert aussi à vérifier qu'au moins ces colonnes sont présentes (d'autres peuvent être présentes en plus, les colonnes "innatendues")
@@ -169,7 +166,7 @@ def make_sirene_data_dir(sirene_data_parent_dir) -> Path:
169166
170167# Liste des ID de ressources présentes dans un dataset à traiter, au format JSON ou XML, mais exclues du traitement
171168EXCLUDED_RESOURCES = os .getenv ("EXCLUDED_RESOURCES" , "" ).replace (" " , "" )
172- print ( f" { ' EXCLUDED_RESOURCES' :<40 } " , EXCLUDED_RESOURCES )
169+ ALL_CONFIG [ " EXCLUDED_RESOURCES" ] = EXCLUDED_RESOURCES
173170
174171EXCLUDED_RESOURCES = EXCLUDED_RESOURCES .split ("," )
175172EXCLUDED_RESOURCES = (
@@ -191,7 +188,7 @@ def make_sirene_data_dir(sirene_data_parent_dir) -> Path:
191188
192189# Ne traiter qu'un seul dataset identifier par son ID
193190SOLO_DATASET = os .getenv ("SOLO_DATASET" , "" )
194- print ( f" { ' SOLO_DATASET' :<40 } " , SOLO_DATASET )
191+ ALL_CONFIG [ " SOLO_DATASET" ] = SOLO_DATASET
195192
196193with open (
197194 make_path_from_env (
@@ -212,6 +209,3 @@ class DecpFormat:
212209 prefixe_json_marches : str
213210 liste_marches_ijson : sendable_list | None = None
214211 coroutine_ijson : Coroutine | None = None
215-
216-
217- print ("" )
0 commit comments