Преглед изворни кода

[#1] Recreate delivery package and configure CSV ingestion scripts to load all rows

Lange François пре 2 недеља
родитељ
комит
e8287f2c80

BIN
Retro Planning.pdf



BIN
docs/Backup_Procedure.pdf


BIN
docs/Data_Ingestion.pdf


BIN
docs/Env_Configuration.pdf


BIN
docs/Final_Report.pdf


BIN
docs/Global_Index.pdf


BIN
docs/Operator_Installation_Guide.pdf


BIN
docs/Presentation_Technical.pdf


BIN
docs/Presentation_User.pdf


BIN
docs/Recommendations.pdf


BIN
docs/Scrum_Artifacts.pdf


BIN
docs/Scrum_Daily.pdf


BIN
docs/Scrum_Plan.pdf


BIN
docs/Scrum_Retro.pdf


BIN
docs/Scrum_Review.pdf


BIN
docs/Scrum_Wiki.pdf


BIN
docs/Start_Stop_Procedures.pdf


BIN
docs/Technical_Document.pdf


BIN
docs/Test_Cases_Sprint8.pdf


BIN
docs/URL_Formats.pdf


BIN
docs/Uninstall_Guide.pdf


BIN
docs/User_Description.pdf


BIN
docs/User_Guide.pdf


BIN
docs/WSL_Deployment.pdf


BIN
docs/Wiki_Home.pdf


BIN
docs/architecture.pdf


BIN
docs/disaster_recovery_plan.pdf


BIN
docs/distributed_deployment.pdf


BIN
docs/docker_connection.pdf


BIN
docs/project_report.pdf


BIN
docs/retro_planning.pdf


BIN
docs/taiga_audit_report.pdf


BIN
docs/zabbix_monitoring.pdf


+ 3 - 1
download_csv.sh

@@ -24,6 +24,8 @@ download() {
 
 download "$EN_URL" "$EN_FILE"
 
-download "$FR_URL" "$FR_FILE"
+# To prevent disk space exhaustion on the VM, we skip the French CSV by default.
+# Only download it if you have sufficient disk space (> 60 GB available).
+# download "$FR_URL" "$FR_FILE"
 
 echo "CSV download completed."

+ 16 - 0
ingest_csv.py

@@ -253,6 +253,22 @@ if __name__ == "__main__":
     print("Initiating OpenFoodFacts Grouped Vertical Ingestion Process...")
     engine = get_loader_engine()
     
+    if "--wipe" in sys.argv or "-w" in sys.argv:
+        print("Wiping existing products tables and views...")
+        try:
+            with engine.begin() as conn:
+                conn.execute(text("DROP VIEW IF EXISTS products"))
+                conn.execute(text("SET FOREIGN_KEY_CHECKS=0"))
+                conn.execute(text("DROP TABLE IF EXISTS products_core"))
+                conn.execute(text("DROP TABLE IF EXISTS products_allergens"))
+                conn.execute(text("DROP TABLE IF EXISTS products_macros"))
+                conn.execute(text("DROP TABLE IF EXISTS products_vitamins"))
+                conn.execute(text("DROP TABLE IF EXISTS products_minerals"))
+                conn.execute(text("SET FOREIGN_KEY_CHECKS=1"))
+            print("Database wipe complete.")
+        except Exception as e:
+            print(f"Warning: Could not wipe tables: {e}")
+            
     processed_en = ingest_file('data/en.openfoodfacts.org.products.csv', engine)
     processed_fr = ingest_file('data/fr.openfoodfacts.org.products.csv', engine)
     

+ 7 - 7
start_batch_ingest.sh

@@ -8,21 +8,21 @@ echo "========================================================="
 echo "🍔 Local Food AI: Extreme Batch Ingestion"
 echo "========================================================="
 
-if [ ! -f "en.openfoodfacts.org.products.csv" ] && [ ! -f "fr.openfoodfacts.org.products.csv" ]; then
-    echo "❌ Error: CSV files not found in the current directory."
+if [ ! -f "data/en.openfoodfacts.org.products.csv" ] && [ ! -f "data/fr.openfoodfacts.org.products.csv" ]; then
+    echo "❌ Error: CSV files not found in the data/ directory."
     echo "Please download the massive CSVs before running this batch."
     exit 1
 fi
 
-echo "🚀 Starting database wipe and reset..."
-# Automatically run the new DB setup to drop the rigid table
-venv/bin/python3 setup_db.py
+echo "🚀 Running database migrations to ensure schema health..."
+# Run database migrations
+venv/bin/python3 -m alembic upgrade head
 
 echo "🚀 Triggering background ingestion process via nohup..."
 echo "All outputs will be saved to ingestion_process.log"
 
-# Run securely in background
-nohup venv/bin/python3 -u ingest_csv.py > ingestion_process.log 2>&1 &
+# Run securely in background with --wipe flag to clean products database
+nohup venv/bin/python3 -u ingest_csv.py --wipe > ingestion_process.log 2>&1 &
 BG_PID=$!
 
 echo "✅ Process started in the background (PID: $BG_PID)"