File size: 5,114 Bytes
fc00054 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | # Configuration Guide: Hugging Face & GitHub Setup
This guide shows you exactly where to configure your Hugging Face Space details and GitHub repository information.
---
## 1. Hugging Face Configuration
### Option A: Update `src/config.py` (Recommended for Local Testing)
Edit `/Users/ananttripathi/Desktop/mlops/src/config.py` and replace the placeholder values:
```python
# Lines 58-62 in src/config.py
HF_DATASET_REPO = os.getenv(
"HF_DATASET_REPO", "your-username/engine-maintenance-dataset" # <-- Replace "your-username"
)
HF_MODEL_REPO = os.getenv("HF_MODEL_REPO", "your-username/engine-maintenance-model") # <-- Replace
HF_SPACE_REPO = os.getenv("HF_SPACE_REPO", "your-username/engine-maintenance-space") # <-- Replace
```
**Example** (HF username: `ananttripathiak`, GitHub username: `ananttripathi`):
```python
HF_DATASET_REPO = os.getenv(
"HF_DATASET_REPO", "ananttripathiak/engine-maintenance-dataset"
)
HF_MODEL_REPO = os.getenv("HF_MODEL_REPO", "ananttripathiak/engine-maintenance-model")
HF_SPACE_REPO = os.getenv("HF_SPACE_REPO", "ananttripathiak/engine-maintenance-space")
```
### Option B: Set Environment Variables (For Local Testing)
Instead of editing `config.py`, you can export these in your terminal:
```bash
export HF_TOKEN="hf_your_token_here"
export HF_DATASET_REPO="your-username/engine-maintenance-dataset"
export HF_MODEL_REPO="your-username/engine-maintenance-model"
export HF_SPACE_REPO="your-username/engine-maintenance-space"
```
---
## 2. GitHub Repository Configuration
### A. GitHub Secrets (Required for GitHub Actions)
Go to your GitHub repository β **Settings** β **Secrets and variables** β **Actions** β **New repository secret**
Add these 4 secrets:
1. **`HF_TOKEN`**
- Value: Your Hugging Face access token (get it from https://huggingface.co/settings/tokens)
- Example: `hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`
2. **`HF_DATASET_REPO`**
- Value: Your Hugging Face dataset repo ID
- Example: `ananttripathiak/engine-maintenance-dataset`
3. **`HF_MODEL_REPO`**
- Value: Your Hugging Face model repo ID
- Example: `ananttripathiak/engine-maintenance-model`
4. **`HF_SPACE_REPO`**
- Value: Your Hugging Face Space repo ID
- Example: `ananttripathiak/engine-maintenance-space`
**Note:** The GitHub Actions workflow (`.github/workflows/pipeline.yml`) automatically reads these secrets. No code changes needed!
### B. Update README.md with Your GitHub Repo URL
Edit `/Users/ananttripathi/Desktop/mlops/README.md` and add your GitHub repository link:
```markdown
## GitHub Repository
- **Repository URL**: https://github.com/your-username/engine-predictive-maintenance
- **GitHub Actions**: https://github.com/your-username/engine-predictive-maintenance/actions
```
---
## 3. Quick Setup Checklist
- [ ] **Hugging Face Account**: Create account at https://huggingface.co
- [ ] **HF Access Token**: Generate at https://huggingface.co/settings/tokens (needs `write` permission)
- [ ] **Update `src/config.py`**: Replace `"username"` with your actual HF username
- [ ] **Create HF Repos** (optional - scripts will create them automatically):
- Dataset repo: `your-username/engine-maintenance-dataset`
- Model repo: `your-username/engine-maintenance-model`
- Space repo: `your-username/engine-maintenance-space`
- [ ] **GitHub Repository**: Create a new repo and push this `mlops` folder
- [ ] **GitHub Secrets**: Add the 4 secrets listed above in your GitHub repo settings
- [ ] **Test Locally**: Run `python src/data_register.py` to verify HF connection
---
## 4. Testing Your Configuration
### Test Local Configuration
```bash
cd /Users/ananttripathi/Desktop/mlops
source .venv/bin/activate
# Set your HF token (if not in config.py)
export HF_TOKEN="hf_your_token_here"
# Test data registration
python src/data_register.py
# Test data preparation
python src/data_prep.py
# Test model training
python src/train.py
# Test deployment
python src/deploy_to_hf.py
```
### Test GitHub Actions
1. Push your code to GitHub:
```bash
git add .
git commit -m "Initial commit: Predictive maintenance MLOps pipeline"
git push origin main
```
2. Go to your GitHub repo β **Actions** tab
3. You should see the "Predictive Maintenance Pipeline" workflow running
4. All 4 jobs should complete successfully (green checkmarks)
---
## 5. Where Each Configuration is Used
| Configuration | Used In | Purpose |
|--------------|---------|---------|
| `HF_DATASET_REPO` | `src/data_register.py`, `src/data_prep.py`, `src/train.py` | Dataset storage and retrieval |
| `HF_MODEL_REPO` | `src/train.py`, `src/inference.py`, `src/app.py` | Model storage and loading |
| `HF_SPACE_REPO` | `src/deploy_to_hf.py` | Streamlit app deployment |
| `HF_TOKEN` | All HF-related scripts | Authentication |
| GitHub Secrets | `.github/workflows/pipeline.yml` | CI/CD automation |
---
## Need Help?
- **Hugging Face Docs**: https://huggingface.co/docs/hub
- **GitHub Actions Docs**: https://docs.github.com/en/actions
- **GitHub Secrets**: https://docs.github.com/en/actions/security-guides/encrypted-secrets
|