liveBook · Manning

Deployment pipeline

As explained in Machine Learning Platform Engineering

Continuous integration is a software-development practice that automatically builds and verifies changes as they are integrated into a shared codebase.

A deployment pipeline automates steps that move software or models toward production. For ML, it can retrain and deliver models as new data arrives; for application code, it can test changes, build an image, and trigger deployment. section 2.5.2 section 3.4.1

A GitLab CI pipeline for a FastAPI application uses three stages:

Listing 3.13 GitLab CI example
image: docker:20.10.16
variables:
  DOCKER_TLS_CERTDIR: "/certs"
stages:    #1
  - test
  - build
  - update
services:    #2
  - docker:20.10.16-dind    #3
test_code:    #4
    stage: test
    image:
      name: python:3.10
    script:
      - echo "testing code"
      - pip install -r $CI_PROJECT_DIR/requirements.txt
      - pytest $CI_PROJECT_DIR/

build_image:    #5
    stage: build
    script:
      - echo "building docker image"
      - cd $CI_PROJECT_DIR
      - echo ${CI_COMMIT_SHA:0:8}
      - docker build . -t varunmallya/hello-joker:${CI_COMMIT_SHA:0:8}
      - docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}
      - docker push varunmallya/hello-joker:${CI_COMMIT_SHA:0:8}
 update_helm_chart:    #6
    stage: update
    image:
      name: python:3.10
    script:
      - apt-get update && apt-get install git
      - git clone 
https://${GITLAB_USER_NAME}:${GITLAB_ACCESS_TOKEN}@\
gitlab.com/learn-mlops/gitlab-ci-example.git  #7
      - cd $CI_PROJECT_DIR
      - wget 
https://github.com/mikefarah/yq/releases/download/v4.2.0/\
yq_linux_amd64 -O /usr/bin/yq && chmod +x /usr/bin/yq  #8
      - git config --global user.email "${GITLAB_USER_EMAIL}"
      - git config --global user.name "${GITLAB_USER_NAME}"
      - yq e -i ".image.tag |= "${CI_COMMIT_SHA:0:8}"" \
        hello-joker/values.yaml  #9
      - git add hello-joker/values.yaml
      - git commit -m "[skip ci]Update helm chart"    #10
      - git push https://${GITLAB_USER_NAME}:\
        ${GITLAB_ACCESS_TOKEN}@gitlab.com/learn-mlops/\
        gitlab-ci-example.git HEAD:main  #11

The configuration shows the stages, jobs, images, and scripts used to automate testing, image building, and chart updates. section 3.4.1

How Machine Learning Platform Engineering covers it

How deep it goes
Explains three GitLab CI stages and their jobs, and identifies modular components, validation, monitoring, and triggers for ML pipelines.
Examples
Uses a FastAPI application pipeline that tests Python code, builds and pushes a Docker image, and updates a Helm chart.
What it assumes
Assumes a GitLab repository and requires a Docker runtime and Docker Hub for the demonstrated image-build workflow.
What you can do after
Build a GitLab CI configuration that tests code, publishes a Docker image, and updates a Helm chart.
How it connects
Connects continuous integration with Docker, Helm, unit testing, continuous delivery, model validation, and pipeline monitoring.

Also explained in

Compare how 30 books explain deployment pipeline →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning Platform Engineering. The section links point to the parts of the book it draws on.