JadHADDAD92 / mlflow-server

MLflow Tracking Server with basic auth deployed in AWS App Runner.

Home Page:https://gallery.ecr.aws/t9j8s4z8/mlflow

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MLflow using AWS App Runner

This project deploys an MLflow instance with basic auth (username/password) in AWS App Runner.

Architecture

Amazon ECR

Amazon Elastic Container Registry (ECR) is a fully managed container registry that makes it easy to store, manage, share, and deploy your container images and artifacts anywhere.

App Runner

AWS App Runner is a fully managed service that makes it easy for developers to quickly deploy containerized web applications and APIs, at scale and with no prior infrastructure experience required. Start with your source code or a container image.

Amazon S3

Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance.

Amazon RDS

Amazon Relational Database Service (Amazon RDS) makes it easy to set up, operate, and scale a relational database in the cloud. Amazon RDS provides six familiar database engines to choose from, including Amazon Aurora, PostgreSQL, MySQL, MariaDB, Oracle Database, and SQL Server.

Environment Variables

The environment variables below are required to deploy this project.

Variable Description Default
PORT Port for the MLflow server 80
MLFLOW_ARTIFACT_URI S3 Bucket URI for MLflow's artifact store "./mlruns"
MLFLOW_BACKEND_URI SQLAlchemy database uri (if provided, the other variables MLFLOW_DB_* are ignored)
MLFLOW_DB_DIALECT Database dialect (e.g. postgresql, mysql+pymysql, sqlite) "mysql+pymysql"
MLFLOW_DB_USERNAME Backend store username "mlflow"
MLFLOW_DB_PASSWORD Backend store password "mlflow"
MLFLOW_DB_HOST Backend store host
MLFLOW_DB_PORT Backend store port 3306
MLFLOW_DB_DATABASE Backend store database "mlflow"
MLFLOW_TRACKING_USERNAME Username for MLflow UI and API "mlflow"
MLFLOW_TRACKING_PASSWORD Password for MLflow UI and API "mlflow"

Using your deployed MLflow

You can access the MLflow UI in your App Runner URL: https://XXXXXXXXX.aws-region.awsapprunner.com/

Also, you can track your experiments using MLflow API.

import os
import mlflow

os.environ["MLFLOW_TRACKING_URI"] = "https://XXXXXXXXX.aws-region.awsapprunner.com/"
os.environ["MLFLOW_EXPERIMENT_NAME"] = "amazing-experiment"
os.environ["MLFLOW_TRACKING_USERNAME"] = "user"
os.environ["MLFLOW_TRACKING_PASSWORD"] = "pass"

# AWS AK/SK are required to upload artifacts to S3 Bucket
os.environ["AWS_ACCESS_KEY_ID"] = "AWS_ACCESS_KEY"
os.environ["AWS_SECRET_ACCESS_KEY"] = "AWS_SECRET_KEY"

SEED = 1993

mlflow.start_run()
mlflow.log_param("seed", SEED)
mlflow.end_run()

How to deploy MLflow with auth

In this section, we'll walk through deploying this MLflow docker image with basic authentication.

This project provides a terraform stack that can be easily used to deploy the MLflow server with basic authentication.

NOTE: This project is not intended to be used for production deployments. It is intended to be used for testing and development.

Prerequisites

You'll need to have the following installed:

Deploying MLflow

To deploy MLflow, you'll need to:

  1. Create an AWS account if you don't already have one.

  2. Configure AWS CLI to use your AWS account.

  3. Clone the repository: github.com/DougTrajano/mlflow-server

  4. Open mlflow-server/terraform folder.

cd mlflow-server/terraform
  1. Run the following command to create all the required resources:
terraform init
terraform apply -var mlflow_username="USERNAME-HERE" -var mlflow_password="PASSWORD-HERE"
  1. Type "yes" when prompted to continue.

This will create the following resources:

  • An S3 bucket for storing MLflow artifacts.
  • An IAM role and policy for the MLflow server connect to the S3 bucket.
  • An RDS database instance (MySQL) for storing MLflow metadata.
  • A service in App Runner to run MLflow Tracking Server.

Next features

References

About

MLflow Tracking Server with basic auth deployed in AWS App Runner.

https://gallery.ecr.aws/t9j8s4z8/mlflow

License:Apache License 2.0


Languages

Language:HCL 81.0%Language:Shell 12.3%Language:Dockerfile 6.7%