Skip to the workspace
Pebellslearn by building
CI/CD for Machine Learning  ›  Capstone Project

CML: Model Reports in Pull Requests

CML 13 minCML is a tool that runs inside CI to post metrics, plots and comparisons as a comment on the pull request, so reviewers judge a model change by its results.

mlops / CML: Model Reports in Pull Requests

Explore each scene at your own pace.

01 · The rule

The rule

CML: Model Reports in Pull Requests

A green tick tells a reviewer that the churn pipeline ran. It does not tell them whether the new model is better. They could download the logs and dig for numbers, but they will not. CML (Continuous Machine Learning) brings the numbers to them: a comment on the pull request with metrics, the change against main, and plots.

The rule

Put the evidence where the decision is made.

The decision to merge happens on the pull request page, so the model's results should appear there. CML is a command-line tool, usually run inside GitHub Actions or GitLab CI, that turns a Markdown file into a pull request comment:

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0          # full history, so origin/main can be compared
      - uses: iterative/setup-cml@v2
      # ... setup-python, pip install, dvc pull as before ...
      - run: dvc repro
      - name: Report
        env:
          REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          echo "## Churn model report" > report.md
          dvc metrics diff origin/main --md >> report.md
          echo "![Confusion matrix](./confusion.png)" >> report.md
          cml comment create report.md

Step by step:

  • dvc repro trains and writes metrics.json and confusion.png.
  • dvc metrics diff origin/main --md prints a Markdown table of each metric on main, on this branch, and the difference. It needs main's history, which is why checkout uses fetch-depth: 0.
  • cml comment create posts report.md to the pull request, uploading the image it references. REPO_TOKEN gives it permission.

CML can also start cloud machines as temporary CI runners (cml runner launch), so a heavy training job can use a GPU that GitHub's standard runners do not have.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.