Spaces:
Sleeping
Sleeping
chore: Remove remaining docs from git
Browse files- DB_SCHEMA.md +0 -45
- SETUP_GUIDE.md +0 -66
- VERIFICATION_GUIDE.md +0 -44
DB_SCHEMA.md
DELETED
|
@@ -1,45 +0,0 @@
|
|
| 1 |
-
# Database Schema Documentation
|
| 2 |
-
|
| 3 |
-
The application uses a single table `prediction_logs` to store all prediction requests and results.
|
| 4 |
-
|
| 5 |
-
## Table: `prediction_logs`
|
| 6 |
-
|
| 7 |
-
| Column Name | Type | Description |
|
| 8 |
-
| :--- | :--- | :--- |
|
| 9 |
-
| `id` | Integer | Primary Key, Auto-increment |
|
| 10 |
-
| `timestamp` | DateTime | Timestamp of the prediction (UTC) |
|
| 11 |
-
| `prediction` | Integer | Predicted class (0 or 1) |
|
| 12 |
-
| `probability` | Float | Probability of the positive class (optional) |
|
| 13 |
-
| `age` | Integer | Age of the employee |
|
| 14 |
-
| `genre` | String | Gender (M/F) |
|
| 15 |
-
| `revenu_mensuel` | Integer | Monthly income |
|
| 16 |
-
| `statut_marital` | String | Marital status |
|
| 17 |
-
| `departement` | String | Department |
|
| 18 |
-
| `poste` | String | Job title |
|
| 19 |
-
| `nombre_experiences_precedentes` | Integer | Number of previous companies |
|
| 20 |
-
| `nombre_heures_travailless` | Integer | Hours worked |
|
| 21 |
-
| `annee_experience_totale` | Integer | Total working years |
|
| 22 |
-
| `annees_dans_l_entreprise` | Integer | Years at current company |
|
| 23 |
-
| `annees_dans_le_poste_actuel` | Integer | Years in current role |
|
| 24 |
-
| `satisfaction_employee_environnement` | Integer | Environment satisfaction (1-4) |
|
| 25 |
-
| `note_evaluation_precedente` | Integer | Previous performance rating |
|
| 26 |
-
| `niveau_hierarchique_poste` | Integer | Job level |
|
| 27 |
-
| `satisfaction_employee_nature_travail` | Integer | Job involvement (1-4) |
|
| 28 |
-
| `satisfaction_employee_equipe` | Integer | Relationship satisfaction (1-4) |
|
| 29 |
-
| `satisfaction_employee_equilibre_pro_perso` | Integer | Work-life balance (1-4) |
|
| 30 |
-
| `note_evaluation_actuelle` | Integer | Current performance rating |
|
| 31 |
-
| `heure_supplementaires` | String | Overtime (Yes/No) |
|
| 32 |
-
| `augementation_salaire_precedente` | String | Percent salary hike |
|
| 33 |
-
| `nombre_participation_pee` | Integer | Stock option level |
|
| 34 |
-
| `nb_formations_suivies` | Integer | Training times last year |
|
| 35 |
-
| `nombre_employee_sous_responsabilite` | Integer | Number of subordinates |
|
| 36 |
-
| `distance_domicile_travail` | Integer | Distance from home |
|
| 37 |
-
| `niveau_education` | Integer | Education level (1-5) |
|
| 38 |
-
| `domaine_etude` | String | Education field |
|
| 39 |
-
| `ayant_enfants` | String | Has children (Yes/No) |
|
| 40 |
-
| `frequence_deplacement` | String | Business travel frequency |
|
| 41 |
-
| `annees_depuis_la_derniere_promotion` | Integer | Years since last promotion |
|
| 42 |
-
| `annes_sous_responsable_actuel` | Integer | Years with current manager |
|
| 43 |
-
|
| 44 |
-
## Relationships
|
| 45 |
-
No relationships as this is a single-table logging schema for this POC.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SETUP_GUIDE.md
DELETED
|
@@ -1,66 +0,0 @@
|
|
| 1 |
-
# Environment & Deployment Setup Guide
|
| 2 |
-
|
| 3 |
-
## 1. Verify Local Environment
|
| 4 |
-
|
| 5 |
-
### Installed Packages
|
| 6 |
-
Your environment has all necessary packages installed (`fastapi`, `uvicorn`, `xgboost`, `sqlalchemy`, etc.).
|
| 7 |
-
You can verify this anytime with:
|
| 8 |
-
```bash
|
| 9 |
-
pip list | grep -E "fastapi|uvicorn|xgboost|sqlalchemy|pandas"
|
| 10 |
-
```
|
| 11 |
-
|
| 12 |
-
### Local Server
|
| 13 |
-
Your local server is running successfully at `http://127.0.0.1:8000`.
|
| 14 |
-
Health check:
|
| 15 |
-
```bash
|
| 16 |
-
curl http://127.0.0.1:8000/health
|
| 17 |
-
```
|
| 18 |
-
|
| 19 |
-
## 2. Hugging Face Credentials
|
| 20 |
-
|
| 21 |
-
To deploy your application to Hugging Face Spaces via GitHub Actions, you need to configure some secrets.
|
| 22 |
-
|
| 23 |
-
### A. Get your Hugging Face Token (HF_TOKEN)
|
| 24 |
-
This token allows GitHub to push code to your Space.
|
| 25 |
-
|
| 26 |
-
1. Log in to your [Hugging Face account](https://huggingface.co/).
|
| 27 |
-
2. Go to **Settings** > **Access Tokens** (https://huggingface.co/settings/tokens).
|
| 28 |
-
3. Click **"New token"**.
|
| 29 |
-
4. Name it (e.g., `github-actions`).
|
| 30 |
-
5. Select **"Write"** permissions (Crucial for deployment).
|
| 31 |
-
6. Click **"Generate a token"** and copy it.
|
| 32 |
-
7. **Action**: Add this as a Secret in your GitHub Repository (`Settings` > `Secrets and variables` > `Actions` > `New repository secret`) with the name `HF_TOKEN`.
|
| 33 |
-
|
| 34 |
-
### B. Create the Space
|
| 35 |
-
1. Go to [Hugging Face Spaces](https://huggingface.co/spaces).
|
| 36 |
-
2. Click **"Create new Space"**.
|
| 37 |
-
3. Enter a name (e.g., `prediction-api`).
|
| 38 |
-
4. Select **Docker** as the SDK.
|
| 39 |
-
5. Click **"Create Space"**.
|
| 40 |
-
6. **Action**: Note down the `HF_USERNAME` (your username) and `SPACE_NAME` (the name you gave). Add these as Secrets in GitHub as well.
|
| 41 |
-
|
| 42 |
-
### C. Configure Space Secrets (Environment Variables)
|
| 43 |
-
These are the variables your running application needs (Database, API Key).
|
| 44 |
-
|
| 45 |
-
1. In your Space, go to **Settings**.
|
| 46 |
-
2. Scroll down to **"Variables and secrets"**.
|
| 47 |
-
3. Click **"New secret"**.
|
| 48 |
-
4. Add the following:
|
| 49 |
-
* `API_KEY`: A strong password you choose (e.g., `my-super-secret-key-123`).
|
| 50 |
-
* `DATABASE_URL`:
|
| 51 |
-
* **Option 1 (External PostgreSQL)**: `postgresql://user:password@host:port/dbname` (If you have a hosted DB like Supabase, Neon, or AWS RDS).
|
| 52 |
-
* **Option 2 (Internal SQLite - NOT Recommended for Prod)**: `sqlite:///./data.db` (Note: Data will be lost if the Space restarts unless you use persistent storage).
|
| 53 |
-
* **Option 3 (Persistent Storage)**: If you enable Persistent Storage in HF Space settings, map it to `/data` and use `sqlite:////data/db.sqlite`.
|
| 54 |
-
|
| 55 |
-
## 3. Summary of Secrets needed in GitHub
|
| 56 |
-
| Secret Name | Value |
|
| 57 |
-
| :--- | :--- |
|
| 58 |
-
| `HF_TOKEN` | Your Write-access HF Token |
|
| 59 |
-
| `HF_USERNAME` | Your HF Username |
|
| 60 |
-
| `SPACE_NAME` | The name of your Space |
|
| 61 |
-
|
| 62 |
-
## 4. Summary of Secrets needed in Hugging Face Space
|
| 63 |
-
| Secret Name | Value |
|
| 64 |
-
| :--- | :--- |
|
| 65 |
-
| `API_KEY` | Your chosen API key |
|
| 66 |
-
| `DATABASE_URL` | Connection string to your database |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VERIFICATION_GUIDE.md
DELETED
|
@@ -1,44 +0,0 @@
|
|
| 1 |
-
# Project Verification Guide
|
| 2 |
-
|
| 3 |
-
Follow these steps to verify the entire project functionality.
|
| 4 |
-
|
| 5 |
-
## 1. Environment Setup
|
| 6 |
-
Ensure dependencies are installed:
|
| 7 |
-
```bash
|
| 8 |
-
pip install -r requirements.txt
|
| 9 |
-
```
|
| 10 |
-
|
| 11 |
-
## 2. Database Initialization
|
| 12 |
-
Initialize the database tables:
|
| 13 |
-
```bash
|
| 14 |
-
PYTHONPATH=. python scripts/create_db.py
|
| 15 |
-
```
|
| 16 |
-
|
| 17 |
-
## 3. Run the API
|
| 18 |
-
Start the FastAPI server (if not already running):
|
| 19 |
-
```bash
|
| 20 |
-
uvicorn app.main:app --reload
|
| 21 |
-
```
|
| 22 |
-
|
| 23 |
-
## 4. End-to-End Verification
|
| 24 |
-
Run the verification script to test the API and Database logging:
|
| 25 |
-
```bash
|
| 26 |
-
PYTHONPATH=. python scripts/verify_deployment.py
|
| 27 |
-
```
|
| 28 |
-
This script will:
|
| 29 |
-
1. Check the `/health` endpoint.
|
| 30 |
-
2. Send a prediction request to `/predict`.
|
| 31 |
-
3. Verify the response contains a prediction.
|
| 32 |
-
4. Query the database to ensure the prediction was logged.
|
| 33 |
-
|
| 34 |
-
## 5. Run Automated Tests
|
| 35 |
-
Execute the test suite to verify all components:
|
| 36 |
-
```bash
|
| 37 |
-
pytest
|
| 38 |
-
```
|
| 39 |
-
|
| 40 |
-
## 6. Docker Verification
|
| 41 |
-
Build the Docker image to ensure containerization works:
|
| 42 |
-
```bash
|
| 43 |
-
docker build -t ml-api .
|
| 44 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|