This repository accompanies the blog post on how to set up serverless MLflow experiment tracking infrastructure using Google Cloud Run and Pulumi. You can find the full article on LinkedIn.
The following prerequisites are required to deploy the experiment tracking infrastructure to Google Cloud:
- Pulumi for provisioning the infrastructure, plus
- Node.js for the Pulumi TypeScript runtime
- Docker for building and testing the MLflow container image
- Google Cloud SDK for access to Google Cloud Platform (make sure to follow the authorization guide)
- Optionally: Python (at least 3.9) for the MLflow example experiments
Additionally, you need a Google Cloud Platform account and access to a project (with appropriate permissions). If you do not have an account already, you can get $300 in free credits when you sign up.
In case you are creating a new Google Cloud project, you need to manually enable the Compute Engine API in Cloud Console before you can provision the rest of the infrastructure using Pulumi.
After you have cloned this repository, open a terminal inside the working copy.
First, we select the dev
Pulumi stack and set two configuration variables for the Pulumi GCP provider based on your GCP setup:
$ pulumi stack select dev
$ pulumi config gcp:project "<your GCP project ID>"
$ pulumi config gcp:region "europe-west3" # change as desired
Then, we are ready to provision the infrastructure:
$ pulumi up
After the operation completes (this will take a few minutes), you can examine the stack outputs to obtain the MLflow service URL and authentication credentials:
$ pulumi stack output --show-secrets
The blog post walks you through a small ML experiment that makes use of the deployed MLflow experiment tracking server.
This repository contains the source code of the example (demo.py
) and its Python package requirements (requirements.txt
).
Execute the following commands to set up a Python virtual environment with the prerequisite packages, obtain MLflow user credentials from the Pulumi stack outputs, and run the ML experiment code:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
export MLFLOW_TRACKING_URI=$(pulumi stack output serviceUrl)
export MLFLOW_TRACKING_USERNAME=$(pulumi stack output adminUsername)
export MLFLOW_TRACKING_PASSWORD=$(pulumi stack output --show-secrets adminPassword)
python demo.py
Please see the blog post for additional explanations of the code and its results.