First model to experment MLOps, CI CD and several other Operative featuers
]You can set up a completely free CI/CD pipeline for your ML model using GitHub Actions, and it's a great way to automate testing, training, and deployment without paying for third-party services.
Here’s a step-by-step guide to set up CI/CD for your ML project:
- Pre-requisites: A GitHub repository with your ML model code.
Docker or Python-based project (e.g., requirements.txt, Dockerfile, etc.).
Optional: Deployment target (e.g., Hugging Face, AWS S3, Google Cloud, etc.).
- Basic Folder Structure Example: bash Copy Edit /my-ml-project │ ├── .github/workflows/ci-cd.yml # GitHub Actions pipeline ├── requirements.txt # Python dependencies ├── train.py # Model training script ├── test_model.py # Tests for model ├── model.pkl # Trained model artifact (after training) └── README.md
- Create GitHub Actions Workflow: Create a file at:
bash Copy Edit .github/workflows/ci-cd.yml Minimal Example: yaml Copy Edit name: ML CI/CD Pipeline
on: [push, pull_request]
jobs: build-test-train: runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
- name: Run unit tests
run: |
pytest test_model.py
- name: Train model
run: |
python train.py
- name: Upload model artifact
uses: actions/upload-artifact@v4
with:
name: trained-model
path: model.pkl
- Explanation: ✅ Trigger: Runs on every push or pull_request. ✅ Steps:
Checks out the repo.
Sets up Python.
Installs dependencies from requirements.txt.
Runs unit tests (pytest recommended).
Trains the ML model.
Uploads the trained model as an artifact (you can later download it from GitHub).
- Optional: Add Deployment (Free Options) You can extend this pipeline to deploy:
To Hugging Face Hub (free)
To GitHub Pages (for models with frontends)
To Google Drive/S3 (via CLI)
Or use Streamlit Community Cloud to deploy ML apps for free.
Example for Hugging Face deployment:
yaml Copy Edit - name: Upload to Hugging Face Hub run: | pip install huggingface_hub python upload_to_huggingface.py # script using huggingface_hub APIs 6. Free Tier Limits: GitHub Actions (free plan):
2000 mins/month for public + private repos.
Unlimited for public repos.
Ubuntu runners are free.
- (Optional) Notify on Failure: Add Slack/Email notifications for CI/CD failures:
yaml Copy Edit - name: Notify via Slack uses: slackapi/slack-github-action@v1.24.0 with: payload: '{"text":"CI/CD Pipeline Failed 😢"}'