📚 সমস্ত অধ্যায় দেখুন
অধ্যায়/ফেজ 7 · Phase 7 · MLOps
7.3২৫ মিনিট পড়া45 / 68

CI/CD pipeline

CI/CD

GitHub Actions দিয়ে automation।

Hook — Push করলেই Deploy

Code push → test → train/eval → build image → deploy — সব automatic। CI/CD ছাড়া প্রতি release manual, slow, ভুল-প্রবণ।

CI vs CD

  • CI — Continuous Integration: প্রতি commit এ test/lint/build।
  • CD — Continuous Delivery/Deployment: auto প্রস্তুত/মোতায়েন।
  • CT — Continuous Training (MLOps): data এলে retrain।

Code — GitHub Actions Pipeline

.github/workflows/ci.yml
name: CI

on:
  push:    { branches: [main] }
  pull_request: { branches: [main] }

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with: { python-version: "3.11", cache: "pip" }
      - run: pip install -r requirements.txt -r requirements-dev.txt
      - run: ruff check .
      - run: pytest -q --cov=src --cov-report=xml
      - uses: codecov/codecov-action@v4

  docker:
    needs: test
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/main'
    steps:
      - uses: actions/checkout@v4
      - uses: docker/setup-buildx-action@v3
      - uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKER_USER }}
          password: ${{ secrets.DOCKER_TOKEN }}
      - uses: docker/build-push-action@v6
        with:
          push: true
          tags: myorg/iris-api:${{ github.sha }},myorg/iris-api:latest
          cache-from: type=gha
          cache-to: type=gha,mode=max

ML-Specific Checks

  • Data validation (Great Expectations, pandera)।
  • Model performance test — minimum accuracy threshold।
  • Regression test — golden dataset।
  • Schema test — feature shape ও type।
  • Drift comparison vs prod baseline।
test_model.py
def test_accuracy_threshold(model, X_test, y_test):
    acc = model.score(X_test, y_test)
    assert acc >= 0.92, f"Accuracy {acc} below threshold"

def test_no_nan(model, X_sample):
    pred = model.predict(X_sample)
    assert not np.isnan(pred).any()

Deployment Strategies

  • Blue-Green — দুটো env, traffic switch।
  • Canary — অল্প traffic নতুন version, ধীরে বাড়াও।
  • Shadow — production traffic copy, prediction compare।
  • A/B test — দুই model ভাগ করে compare।
  • Rollback strategy আগে থেকে ঠিক করো।

Infrastructure as Code

  • Terraform — multi-cloud declarative।
  • Pulumi — IaC in Python/TS।
  • Kubernetes manifests / Helm chart।
  • GitOps — ArgoCD, Flux।

Best Practices

  • Secret manager (GitHub Secrets, Vault, AWS SM)।
  • Branch protection + required check।
  • Semantic versioning + changelog।
  • Fast feedback (<10 min CI)।
  • Reproducible build — pinned dependency।

Summary

এক নজরে

CI/CD = test → build → deploy automation। ML এ data/model check যোগ করো, canary/blue-green দিয়ে safely roll out।