MLOps: Deploying to SageMaker with MLflow

deploying_to_sagemaker.png

This article will walk through the steps to deploy a model to Amazon SageMaker. The prerequisites for this article is that you have trained and saved your machine learning model to your MLflow Model Registry. If you haven’t already completed these steps you can follow my previous article to see exactly how this is done here.

In this article we will:

The code in this article can be found in the following repo.

Running MLflow

MLflow is a platform-agnostic machine learning lifecycle management tool that will help you track experiments and share and deploy models.

To run an MLflow server locally, open a terminal window, activate the virtual environment you created earlier, and run the following command:

mlflow server --host 127.0.0.1 --port 5001

Once running, the terminal output will look something like the following:

Screenshot 2025-09-25 at 10.03.31.png

If you see the above output in your terminal you can navigate to http://127.0.0.1:5001 in your web browser to open MLflow's user interface.

By default, MLflow stores (typically large) artifacts for each run such as model weights (e.g. a pickled scikit-learn model), images (e.g. PNGs), model and data files (e.g. Parquet files) in a local ./mlruns directory. This is referred to as the artifact store. Metadata like parameters, metrics, and tags are stored is stored in the backend store. The backend store can store data in databases as well. You can configure the locations of your artifact store and backend store with the the following commands

mlflow server --host 127.0.0.1 --port 5001 \\
--backend-store-uri sqlite:///mydb.sqlite \\
--artifacts-destination s3://my-bucket

How MLflow deployments work