In this lab, you will learn how to implement Continuous Integration (CI) and Continuous Deployment (CD) processes using a Makefile and the Click test runner. You will perform linting, formatting, refactoring, and testing on a Python script to ensure its quality and functionality.
By the end of this lab, you will:
- Understand the importance of CI/CD processes in MLOps.
- Learn how to use a Makefile for automating linting, formatting, refactoring, and testing.
- Gain experience in writing tests for command-line tools using the Click test runner.
Before you begin, watch the videos and read the resources in this module to familiarize yourself with CI/CD, Makefiles, and the Click test runner. These materials will help you navigate through the lab tasks and achieve the desired outcomes.
- Source the virtual environment:
source /home/coder/venv/bin/activate
- Run the following steps of the Makefile:
make lint
make format
make refactor
make test
Reflection Question: Why does refactor
combine lint
and format
?
- Run the following command-line tool and then write a test for it using the Click test runner:
- Write a test for the
add_cli
functionality of themain.py
function in thetest_main.py
test file. - Use the test for
./main.py --help
as a guide.
- Write a test for the
Reflection Question: How could you use this style of testing to build MLOps tools quickly?
You can view this lab in GitHub here: Coursera-MLOPs-Foundations-Lab-1-CICD