SteGONZALEZ commited on
Commit
85be28c
·
1 Parent(s): 3207010

modifcation pour suprabase

Browse files
scripts/build_ml_features.py CHANGED
@@ -78,16 +78,18 @@ CREATE INDEX IF NOT EXISTS idx_ml_features_target_created_at
78
  ON clean.ml_features_employees(a_quitte_l_entreprise, created_at);
79
  """
80
 
81
- # Fonction pour exécuter les commandes DDL
82
- def _exec_ddl(conn, ddl: str) -> None:
83
- parts = [p.strip() for p in ddl.split(";") if p.strip()]
84
- for stmt in parts:
85
- conn.execute(text(stmt))
86
 
87
  # Point d'entrée du script
88
  def main():
89
  with engine.begin() as conn:
90
- _exec_ddl(conn, DDL)
 
 
91
  print("Table clean.ml_features_employees créée / vérifiée (avec employee_id)")
92
 
93
  if __name__ == "__main__":
 
78
  ON clean.ml_features_employees(a_quitte_l_entreprise, created_at);
79
  """
80
 
81
+ # # Fonction pour exécuter les commandes DDL
82
+ # def _exec_ddl(conn, ddl: str) -> None:
83
+ # parts = [p.strip() for p in ddl.split(";") if p.strip()]
84
+ # for stmt in parts:
85
+ # conn.execute(text(stmt))
86
 
87
  # Point d'entrée du script
88
  def main():
89
  with engine.begin() as conn:
90
+ conn.exec_driver_sql(DDL)
91
+ # with engine.begin() as conn:
92
+ # _exec_ddl(conn, DDL)
93
  print("Table clean.ml_features_employees créée / vérifiée (avec employee_id)")
94
 
95
  if __name__ == "__main__":
scripts/create_db.py CHANGED
@@ -138,18 +138,21 @@ CREATE INDEX IF NOT EXISTS ix_predictions_model_version
138
  ON app.predictions(model_version);
139
  """
140
 
141
- # Fonction utilitaire pour exécuter du DDL de manière robuste
142
- def _exec_ddl(conn, ddl: str) -> None:
143
- # robuste: exécute statement par statement
144
- parts = [p.strip() for p in ddl.split(";") if p.strip()]
145
- for stmt in parts:
146
- conn.execute(text(stmt))
147
 
148
  # Point d'entrée du script
149
  def main():
150
  with engine.begin() as conn:
151
- _exec_ddl(conn, DDL)
152
  print("Schemas + tables créés / vérifiés (raw / clean / app)")
 
 
 
153
 
154
  if __name__ == "__main__":
155
  main()
 
138
  ON app.predictions(model_version);
139
  """
140
 
141
+ # # Fonction utilitaire pour exécuter du DDL de manière robuste
142
+ # def _exec_ddl(conn, ddl: str) -> None:
143
+ # # robuste: exécute statement par statement
144
+ # parts = [p.strip() for p in ddl.split(";") if p.strip()]
145
+ # for stmt in parts:
146
+ # conn.execute(text(stmt))
147
 
148
  # Point d'entrée du script
149
  def main():
150
  with engine.begin() as conn:
151
+ conn.exec_driver_sql(DDL)
152
  print("Schemas + tables créés / vérifiés (raw / clean / app)")
153
+ # with engine.begin() as conn:
154
+ # _exec_ddl(conn, DDL)
155
+ # print("Schemas + tables créés / vérifiés (raw / clean / app)")
156
 
157
  if __name__ == "__main__":
158
  main()
scripts/seed_from_csv.py CHANGED
@@ -217,9 +217,9 @@ def main(
217
  with engine.begin() as conn:
218
  if refresh:
219
  logger.info("Mode --refresh: purge raw tables (snapshots/surveys/ground_truth)")
220
- conn.execute(text("TRUNCATE TABLE raw.employee_snapshots RESTART IDENTITY CASCADE"))
221
- conn.execute(text("TRUNCATE TABLE raw.surveys RESTART IDENTITY CASCADE"))
222
- conn.execute(text("TRUNCATE TABLE raw.ground_truth RESTART IDENTITY CASCADE"))
223
  # raw.employees: on garde l'upsert
224
 
225
  # 1) upsert employees
 
217
  with engine.begin() as conn:
218
  if refresh:
219
  logger.info("Mode --refresh: purge raw tables (snapshots/surveys/ground_truth)")
220
+ conn.execute(text("TRUNCATE TABLE raw.employee_snapshots RESTART IDENTITY CASCADE;"))
221
+ conn.execute(text("TRUNCATE TABLE raw.surveys RESTART IDENTITY CASCADE;"))
222
+ conn.execute(text("TRUNCATE TABLE raw.ground_truth RESTART IDENTITY CASCADE;"))
223
  # raw.employees: on garde l'upsert
224
 
225
  # 1) upsert employees