This is the repository for the labs/tutorials of a course about Machine Learning Operations (MLOps), ZHAW.
NOTE: Labs might still be in the process of being updated, please refresh right before the corresponding lab is touched in the lecture!
| Lab No. | Contents | Tools | Link |
|---|---|---|---|
| 1 | Deep Learning Recap | PyTorch, CNNs, Transformers | Lab 01 |
| 2 | Prompt engineering a chatbot | 🤗Transformers, Streamlit | Lab 02 |
| 3 | Experiment management and hyperparameter tuning | MLflow, Ray Tune | Lab 03 |
| 4 | CI/CD and testing for code and models | GitHub Actions, PyTest, DeepChecks (CML, SkyPilot) | Lab 04 |
| 5 | From notebooks to pipelines to batch processing | Ploomber, Airflow | Lab 05 |
| 6 | Data-centric MLOps | Git LFS, DVC, Albumentations, 🤗Diffusers | Lab 06 |
| 7 | Deploying and protecting machine learning models | MLServer, Alibi Detect | Lab 07 |
| Creating a (shared) VM in GCP | Google Cloud | GCP | |
| Vertex AI tutorial | Google cloud Vertex AI | VertexAI | |
| Example showing how to use python packages with Jupyter Notebooks | Jupyter | Sample |
We use conda environments to manage the lab dependencies. Every lab has its own conda environment. Install Anaconda, Miniconda or Mamba for your platform.
We further recommend Windows Users to use the Windows Subsystem for Linux (WSL) as some software we are using does not support Windows.
Finally, it is a good idea to install Docker Desktop as some of the labs contain parts that benefit from Docker (it is not a requirement, though).
Once you have conda installed, you can create an environment from a env.yaml file using the following command:
conda env create -f env.yamlThen, to enter the environment:
conda activate <environment name>So, for the first lab this command becomes:
conda activate mlops-lab-01Most labs will make use of Jupyter Notebooks, which you can either run locally or on Google Colab. There are of course many other ways to run them, and you are free to use whichever tool and setup you want, but we cannot guarantee compatibility.
Below we show you two ways of running the lab notebooks that are known to work.
We recommend beginning each lab by running the notebooks locally, and only switching to Colab for longer computations. Images sometimes do not render correctly in Colab, and some features might not work as expected.
To run notebooks locally, proceed as follows:
- Open a terminal and navigate to the lab directory (e.g.
cd lab01). - Activate the conda environment for this lab (see above e.g. e.g.
conda activate mlops-lab-01). - Run
jupyter lab. This will result in output similar to the following:
To access the server, open this file in a browser:
file:///some/long/path/here/jpserver-74325-open.html
Or copy and paste one of these URLs:
http://localhost:8888/lab?token=token
http://127.0.0.1:8888/lab?token=token- Click on or copy the link and past it in your browser.
- Now, click on the jupyter notebook of your liking.
- Clone or download this repository.
- Navigate your browser to colab.research.google.com.
- In the menu, select
File > Upload notebook
- Select the notebook you want to open.
- Once your notebook is open, add a code cell at the very top. You can do this, by hovering your cursor over the top of the notebook until the
CodeandTextbuttons appear as shown in the image below:
- In the code cell, add the following:
!git clone https://github_pat_[PAT]@github.com/MLOps-ZHAW/MLOps_Labs
%cd MLOps_Labs/[path/to/notebook]where [PAT] is a Github Access Token (looks like gitgub_pat_....., your lecturer will tell you), and you replace [path/to/notebook] with the path to the jupyter notebook you just opened. For instance, if you opened lab01a_01_tensor_tutorial.ipynb, the statement would become %cd MLOps_Labs/lab01.
