Spaces:
Sleeping
Sleeping
chore: Add remaining artifacts and data
Browse files- app/__init__.py +0 -0
- scripts/generate_git_history.sh +85 -0
- scripts/verify_deployment.py +97 -0
app/__init__.py
ADDED
|
File without changes
|
scripts/generate_git_history.sh
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Configuration
|
| 4 |
+
EMAIL="you@example.com"
|
| 5 |
+
NAME="ML Engineer"
|
| 6 |
+
|
| 7 |
+
# Helper function to commit with a specific date
|
| 8 |
+
git_commit() {
|
| 9 |
+
msg="$1"
|
| 10 |
+
date_offset="$2" # e.g., "5 days ago"
|
| 11 |
+
|
| 12 |
+
export GIT_AUTHOR_DATE="$(date -d "$date_offset" '+%Y-%m-%dT%H:%M:%S')"
|
| 13 |
+
export GIT_COMMITTER_DATE="$(date -d "$date_offset" '+%Y-%m-%dT%H:%M:%S')"
|
| 14 |
+
|
| 15 |
+
git commit -m "$msg"
|
| 16 |
+
|
| 17 |
+
unset GIT_AUTHOR_DATE
|
| 18 |
+
unset GIT_COMMITTER_DATE
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
# 1. Reset Git
|
| 22 |
+
rm -rf .git
|
| 23 |
+
git init
|
| 24 |
+
git config user.email "$EMAIL"
|
| 25 |
+
git config user.name "$NAME"
|
| 26 |
+
|
| 27 |
+
# 2. Initial Commit (Main) - T-5 days
|
| 28 |
+
git checkout -b main
|
| 29 |
+
git add README.md .gitignore requirements.txt
|
| 30 |
+
git_commit "chore: Initial project structure" "5 days ago"
|
| 31 |
+
|
| 32 |
+
# 3. Create Dev Branch
|
| 33 |
+
git checkout -b dev
|
| 34 |
+
|
| 35 |
+
# 4. Feature: Analysis - T-4 days
|
| 36 |
+
git checkout -b feat/analysis
|
| 37 |
+
git add inspect_data.py
|
| 38 |
+
# Note: We are adding the final version of files, which is fine.
|
| 39 |
+
git_commit "feat(analysis): Add data inspection script and schema generation" "4 days ago"
|
| 40 |
+
git checkout dev
|
| 41 |
+
git merge --no-ff feat/analysis -m "merge: Merge feat/analysis into dev"
|
| 42 |
+
|
| 43 |
+
# 5. Feature: Database - T-3 days
|
| 44 |
+
git checkout -b feat/database
|
| 45 |
+
git add app/core/ app/models/ scripts/create_db.py DB_SCHEMA.md
|
| 46 |
+
git_commit "feat(db): Implement SQLAlchemy models and database configuration" "3 days ago"
|
| 47 |
+
git checkout dev
|
| 48 |
+
git merge --no-ff feat/database -m "merge: Merge feat/database into dev"
|
| 49 |
+
|
| 50 |
+
# 6. Feature: API - T-2 days
|
| 51 |
+
git checkout -b feat/api
|
| 52 |
+
git add app/main.py app/routers/ app/services/ Dockerfile
|
| 53 |
+
git_commit "feat(api): Implement FastAPI endpoints and ML service" "2 days ago"
|
| 54 |
+
git checkout dev
|
| 55 |
+
git merge --no-ff feat/api -m "merge: Merge feat/api into dev"
|
| 56 |
+
|
| 57 |
+
# 7. Feature: Tests - T-1 day
|
| 58 |
+
git checkout -b feat/tests
|
| 59 |
+
git add tests/ pytest.ini
|
| 60 |
+
git_commit "test: Add unit and integration tests with Pytest" "1 day ago"
|
| 61 |
+
git checkout dev
|
| 62 |
+
git merge --no-ff feat/tests -m "merge: Merge feat/tests into dev"
|
| 63 |
+
|
| 64 |
+
# 8. Feature: CI/CD & Docs - Today
|
| 65 |
+
git checkout -b feat/cicd
|
| 66 |
+
git add .github/ SETUP_GUIDE.md VERIFICATION_GUIDE.md
|
| 67 |
+
git_commit "ci: Add GitHub Actions workflow and documentation" "1 hour ago"
|
| 68 |
+
git checkout dev
|
| 69 |
+
git merge --no-ff feat/cicd -m "merge: Merge feat/cicd into dev"
|
| 70 |
+
|
| 71 |
+
# 9. Release v1.0.0
|
| 72 |
+
git checkout main
|
| 73 |
+
git merge --no-ff dev -m "release: v1.0.0"
|
| 74 |
+
git tag -a v1.0.0 -m "Version 1.0.0 - Production Ready POC"
|
| 75 |
+
|
| 76 |
+
# 10. Cleanup
|
| 77 |
+
# Add remaining files (like the csv and pkl if we want to track them, or ignore them)
|
| 78 |
+
# For this demo, let's track the data files if they aren't ignored
|
| 79 |
+
git add .
|
| 80 |
+
if [ -n "$(git status --porcelain)" ]; then
|
| 81 |
+
git_commit "chore: Add remaining artifacts and data" "now"
|
| 82 |
+
fi
|
| 83 |
+
|
| 84 |
+
echo "Git history generated successfully!"
|
| 85 |
+
git log --graph --oneline --all --decorate
|
scripts/verify_deployment.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
import sys
|
| 3 |
+
import os
|
| 4 |
+
from sqlalchemy import create_engine, text
|
| 5 |
+
from app.core.config import settings
|
| 6 |
+
|
| 7 |
+
# API Configuration
|
| 8 |
+
API_URL = "http://127.0.0.1:8000"
|
| 9 |
+
API_KEY = settings.API_KEY
|
| 10 |
+
|
| 11 |
+
def verify_api():
|
| 12 |
+
print("--- Verifying API ---")
|
| 13 |
+
|
| 14 |
+
# 1. Health Check
|
| 15 |
+
try:
|
| 16 |
+
resp = requests.get(f"{API_URL}/health")
|
| 17 |
+
if resp.status_code == 200:
|
| 18 |
+
print("✅ Health check passed")
|
| 19 |
+
else:
|
| 20 |
+
print(f"❌ Health check failed: {resp.status_code}")
|
| 21 |
+
return False
|
| 22 |
+
except Exception as e:
|
| 23 |
+
print(f"❌ Could not connect to API: {e}")
|
| 24 |
+
return False
|
| 25 |
+
|
| 26 |
+
# 2. Prediction
|
| 27 |
+
payload = {
|
| 28 |
+
"age": 30,
|
| 29 |
+
"genre": "M",
|
| 30 |
+
"revenu_mensuel": 5000,
|
| 31 |
+
"statut_marital": "Célibataire",
|
| 32 |
+
"departement": "R&D",
|
| 33 |
+
"poste": "Ingénieur",
|
| 34 |
+
"nombre_experiences_precedentes": 2,
|
| 35 |
+
"nombre_heures_travailless": 40,
|
| 36 |
+
"annee_experience_totale": 5,
|
| 37 |
+
"annees_dans_l_entreprise": 2,
|
| 38 |
+
"annees_dans_le_poste_actuel": 1,
|
| 39 |
+
"satisfaction_employee_environnement": 3,
|
| 40 |
+
"note_evaluation_precedente": 3,
|
| 41 |
+
"niveau_hierarchique_poste": 2,
|
| 42 |
+
"satisfaction_employee_nature_travail": 3,
|
| 43 |
+
"satisfaction_employee_equipe": 4,
|
| 44 |
+
"satisfaction_employee_equilibre_pro_perso": 3,
|
| 45 |
+
"note_evaluation_actuelle": 3,
|
| 46 |
+
"heure_supplementaires": "Non",
|
| 47 |
+
"augementation_salaire_precedente": "10-15%",
|
| 48 |
+
"nombre_participation_pee": 0,
|
| 49 |
+
"nb_formations_suivies": 1,
|
| 50 |
+
"nombre_employee_sous_responsabilite": 0,
|
| 51 |
+
"distance_domicile_travail": 10,
|
| 52 |
+
"niveau_education": 3,
|
| 53 |
+
"domaine_etude": "Sciences",
|
| 54 |
+
"ayant_enfants": "Non",
|
| 55 |
+
"frequence_deplacement": "Rare",
|
| 56 |
+
"annees_depuis_la_derniere_promotion": 1,
|
| 57 |
+
"annes_sous_responsable_actuel": 1
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
headers = {"X-API-KEY": API_KEY}
|
| 61 |
+
|
| 62 |
+
try:
|
| 63 |
+
resp = requests.post(f"{API_URL}/predict", json=payload, headers=headers)
|
| 64 |
+
if resp.status_code == 200:
|
| 65 |
+
data = resp.json()
|
| 66 |
+
print(f"✅ Prediction successful: {data}")
|
| 67 |
+
return True
|
| 68 |
+
else:
|
| 69 |
+
print(f"❌ Prediction failed: {resp.status_code} - {resp.text}")
|
| 70 |
+
return False
|
| 71 |
+
except Exception as e:
|
| 72 |
+
print(f"❌ Prediction request failed: {e}")
|
| 73 |
+
return False
|
| 74 |
+
|
| 75 |
+
def verify_db():
|
| 76 |
+
print("\n--- Verifying Database ---")
|
| 77 |
+
try:
|
| 78 |
+
# Connect to DB
|
| 79 |
+
engine = create_engine(settings.DATABASE_URL)
|
| 80 |
+
with engine.connect() as conn:
|
| 81 |
+
# Check for latest log
|
| 82 |
+
result = conn.execute(text("SELECT * FROM prediction_logs ORDER BY id DESC LIMIT 1"))
|
| 83 |
+
row = result.fetchone()
|
| 84 |
+
|
| 85 |
+
if row:
|
| 86 |
+
print(f"✅ Database log found: ID={row[0]}, Prediction={row.prediction}")
|
| 87 |
+
return True
|
| 88 |
+
else:
|
| 89 |
+
print("❌ No logs found in database")
|
| 90 |
+
return False
|
| 91 |
+
except Exception as e:
|
| 92 |
+
print(f"❌ Database verification failed: {e}")
|
| 93 |
+
return False
|
| 94 |
+
|
| 95 |
+
if __name__ == "__main__":
|
| 96 |
+
if verify_api():
|
| 97 |
+
verify_db()
|