Welcome to this tutorial!
This repository contains code, exercises and explanations to help you turn a notebook solution into an operational machine learning application.
All the information can be found in the /exercises
folder. If you feel like there is something missing, or you're getting stuck on a technical problem, try and find a solution with your neighbour! Still can't figure it out? Ask the host!
Before we get started, we need to make sure you have access to a coding environment and have all necessary dependencies installed, so you can edit and run the code.
- Make sure you have Docker installed and running
- (optional) Fork this repository so you can make changes to it. This will be useful if you want to work on the bonus CI/CD exercise.
There are two options you may choose from:
- Using your own editor (e.g. VSCode)
- Using Github Codespaces
These are the steps to get started with your own editor (e.g. VSCode):
- Open a terminal
- Clone the repository
git clone https://github.com/ykerus/mlops-tutorial.git
- Open this folder (the cloned repo) in your editor
- Open a terminal in this folder
- Continue setting up in the "Installing dependencies" section below
These are the steps to get started with GitHub Codespaces:
- Navigate to this repository on GitHub.
- Click on the "Code" button on the right above the folder structure
- Select "Codespaces"
- Click on "Open Codespaces on main"
- Wait until your environment is set up (this may take a while) and your terminal is ready
- Wait a little bit longer, as a another setup step will run automatically
- The setup is done when you you can run
docker
in a terminal and get a list of commands - Once done, add port 8080 to the "Ports" section of the Codespaces window
- Continue setting up in the "Installing dependencies" section below
Note: In Codespaces, you are working within a Docker container which is running on Github's servers. However, since we'll be covering containerization in this tutorial, we need to be able to create containers, within a container! If this does not work for you, make sure your Docker application is running by opening it locally, and then select "Rebuild container" from the command pallette, which you can open with CMD/CTRL + SHIFT + P. This may help. If it doesn't, we recommend using your own editor instead of Codespaces (see section above).
Assuming you've set up your editor with one of the above options, install the necessary dependencies as follows:
- Create a virtual environment
python -m venv .venv
- Activate the environment
source .venv/bin/activate
- Install the dependencies
pip install -e ".[notebook]"
Not working? Double check in which folder you are running this in. It should contain pyproject.toml
and setup.cfg
.
- Install the environment as kernel so we can use it in Jupyter
ipython kernel install --name ".venv" --user
- Check if all went well:
python -c "import turbine_power"
No ouput? Good!
Getting a ModuleNotFoundError
? Not good... Double check if you went through all the steps above, check with your neighbours, or ask the host.
Note: If you're getting installation errors, consider switching to Codespaces if you're working in your own editor.
- Now your environment should be ready! Make sure, in all of the following, that you are running code within this environment (
.venv
). That means, if you create a new terminal, make sure to runsource .venv/bin/activate
again. That also means, if you run a notebook, select.venv
as the kernel.
Note: You may have to install the kernel first, depending on which editor you use. In the above instructions, we are assuming a VSCode environment, in which this is not necessary.
Find the exercises in the /exercises
folder. Start with the first notebook and go from there!