jaimalklyde commited on
Commit
ba94c07
·
verified ·
1 Parent(s): 8168cc6

Update src/module/Data_Exploration.py

Browse files
Files changed (1) hide show
  1. src/module/Data_Exploration.py +16 -11
src/module/Data_Exploration.py CHANGED
@@ -25,32 +25,37 @@ except Exception:
25
  from module.Validation_Contract import ETL_Engine
26
 
27
 
 
 
 
 
 
28
  class AdvancedAnalyzer:
29
  """EDA avancée : Smart Getter, Quality Gates, Visuals, TS, Export"""
30
 
31
  def __init__(self, gspread_client, sheet_name):
32
  self.etl = ETL_Engine(gspread_client, sheet_name)
33
  self.dataframes = {}
34
-
35
- # ------------------ A. CACHING / LOAD ------------------
36
- @st.cache_data(show_spinner=False)
37
- def _cached_run_etl(self):
38
- return self.etl.run_etl()
39
-
40
  def load_data(self):
41
- """Récupère DataExplorer depuis session ou lance l'ETL (cached)"""
42
- # Priorité : session global
43
  if 'data_explorer' in st.session_state and hasattr(st.session_state.data_explorer, 'dataframes'):
44
  self.dataframes = st.session_state.data_explorer.dataframes
45
  return True
46
-
47
- # Sinon, lancer ETL (cached)
48
- success, result = self._cached_run_etl()
 
 
 
 
49
  if success:
50
  self.dataframes = result.dataframes
51
  return True
 
52
  return False
53
 
 
54
  # ------------------ SMART GETTER ------------------
55
  def get_df(self, keyword):
56
  """Trouve une table par mot-clé (exact / partiel)."""
 
25
  from module.Validation_Contract import ETL_Engine
26
 
27
 
28
+ @st.cache_data(show_spinner=False)
29
+ def cached_run_etl(gspread_client, sheet_name):
30
+ etl = ETL_Engine(gspread_client, sheet_name)
31
+ return etl.run_etl()
32
+
33
  class AdvancedAnalyzer:
34
  """EDA avancée : Smart Getter, Quality Gates, Visuals, TS, Export"""
35
 
36
  def __init__(self, gspread_client, sheet_name):
37
  self.etl = ETL_Engine(gspread_client, sheet_name)
38
  self.dataframes = {}
39
+
 
 
 
 
 
40
  def load_data(self):
41
+ # Priorité : session globale
 
42
  if 'data_explorer' in st.session_state and hasattr(st.session_state.data_explorer, 'dataframes'):
43
  self.dataframes = st.session_state.data_explorer.dataframes
44
  return True
45
+
46
+ # ETL via cache externe (SAFE)
47
+ success, result = cached_run_etl(
48
+ self.etl.gspread_client,
49
+ self.etl.sheet_name
50
+ )
51
+
52
  if success:
53
  self.dataframes = result.dataframes
54
  return True
55
+
56
  return False
57
 
58
+
59
  # ------------------ SMART GETTER ------------------
60
  def get_df(self, keyword):
61
  """Trouve une table par mot-clé (exact / partiel)."""