Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions IaC/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ module "mlflow" {
oauth_client_secret = var.oauth_client_secret
create_brand = var.create_brand
brand_name = var.brand_name
location = var.location
app_engine_location = var.app_engine_location
}

module "log_pusher" {
Expand Down
1 change: 0 additions & 1 deletion IaC/modules/mlflow/artifacts/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ variable "bucket_name" {
variable "bucket_location" {
description = "Location of the bucket."
type = string
default = "EUROPE-WEST1"
}
variable "versioning_enabled" {
description = "True if you want to version your bucket."
Expand Down
1 change: 0 additions & 1 deletion IaC/modules/mlflow/database/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ variable "database_version" {
variable "region" {
type = string
description = "Region of the database instance"
default = "europe-west1"
}
variable "size" {
type = string
Expand Down
6 changes: 3 additions & 3 deletions IaC/modules/mlflow/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
module "artifacts" {
source = "./artifacts"
bucket_name = var.artifacts_bucket_name
bucket_location = var.artifacts_bucket_location
bucket_location = var.location
number_of_version = var.artifacts_number_of_version
storage_class = var.artifacts_storage_class
}
Expand All @@ -33,7 +33,7 @@ module "database" {
source = "./database"
instance_prefix = var.db_instance_prefix
database_version = var.db_version
region = var.db_region
region = var.location
size = var.db_size
availability_type = var.db_availability_type
database_name = var.db_name
Expand All @@ -46,7 +46,7 @@ module "server" {
source = "./server"
mlflow_server = var.mlflow_server
create_default_service = var.create_default_service
location = var.server_location
app_engine_location = var.app_engine_location
docker_image_name = var.server_docker_image
env_variables = var.server_env_variables
db_private_ip = module.database.private_ip
Expand Down
2 changes: 1 addition & 1 deletion IaC/modules/mlflow/server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ data "google_project" "project" {
}

resource "google_app_engine_application" "app" {
location_id = var.location
location_id = var.app_engine_location
iap {
enabled = true
oauth2_client_id = var.oauth_client_id == "" ? google_iap_client.project_client[0].client_id : var.oauth_client_id
Expand Down
3 changes: 1 addition & 2 deletions IaC/modules/mlflow/server/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
variable "location" {
variable "app_engine_location" {
type = string
description = "Location to deploy your server"
default = "europe-west"
}
variable "docker_image_name" {
type = string
Expand Down
15 changes: 4 additions & 11 deletions IaC/modules/mlflow/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ variable "artifacts_bucket_name" {
description = "Name of the mlflow bucket created to store artifacts"
type = string
}
variable "artifacts_bucket_location" {
description = "Location of the mlflow artifact bucket deployed"
variable "location" {
description = "mlflow artifact bucket and data base location"
type = string
default = "EUROPE-WEST1"
}
variable "artifacts_number_of_version" {
description = "Number of file version kept in your artifacts bucket"
Expand Down Expand Up @@ -54,11 +53,6 @@ variable "db_version" {
type = string
default = "MYSQL_5_7"
}
variable "db_region" {
description = "Database region"
type = string
default = "europe-west1"
}
variable "db_size" {
description = "Database instance size"
type = string
Expand All @@ -82,10 +76,9 @@ variable "mlflow_server" {
description = "Name of the mlflow server deployed to app engine. If a service already have this name, it will be overwritten."
type = string
}
variable "server_location" {
description = "Location to deploy cloud run server"
variable "app_engine_location" {
description = "Location to deploy app engine server"
type = string
default = "europe-west"
}
variable "server_docker_image" {
description = "Docker image name of your mlflow server"
Expand Down
2 changes: 1 addition & 1 deletion IaC/prerequesites/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module "services" {
module "bucket_backend" {
source = "./../modules/mlflow/artifacts"
bucket_name = var.backend_bucket
bucket_location = var.backend_bucket_location
bucket_location = var.location
number_of_version = var.backend_bucket_number_of_version
storage_class = var.backend_bucket_storage_class
storage_uniform = var.storage_uniform
Expand Down
5 changes: 2 additions & 3 deletions IaC/prerequesites/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ variable "backend_bucket" {
description = "Name of the terraform backend"
type = string
}
variable "backend_bucket_location" {
description = "Location of the bucket."
variable "location" {
description = "Location of the backend bucket."
type = string
default = "EUROPE-WEST1"
}
variable "versioning_enabled" {
description = "True if you want to version your bucket."
Expand Down
8 changes: 8 additions & 0 deletions IaC/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,11 @@ variable "brand_name" {
default = ""
description = "Name of the brand if it exists"
}
variable "app_engine_location" {
description = "Location to deploy app engine server"
type = string
}
variable "location" {
description = "mlflow artifact bucket and data base location"
type = string
}
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ destroy-terraform:
@echo

.PHONY: pre-requisites
pre-requisites: init-config set-project
pre-requisites: init-config set-project set-location
@echo "Setting up your GCP project..."
@source vars && cd IaC/prerequesites && terraform init $(OUTPUT_SUPPRESSOR) && terraform apply $(AUTO_APPROVE) $(OUTPUT_SUPPRESSOR)
@echo "Done"
Expand Down Expand Up @@ -103,6 +103,15 @@ set-project:
@chmod +x ./bin/set_project.sh
@cd bin && ./set_project.sh

.PHONY: set-location
set-location:
@chmod +x ./bin/set_location.sh
@cd bin && ./set_location.sh

.PHONY: get-uri
get-uri:
@chmod +x ./bin/get-uri.sh
@cd bin && ./get-uri.sh

#################
# MISC #
Expand All @@ -129,10 +138,10 @@ dependencies-checks:
@cd bin && ./check_dependencies.sh

.PHONY: goodbye
goodbye:
goodbye: get-uri
@echo
@echo "Congratulations, you successfully deployed MLFlow on your project! 🎉"
@source vars && echo "The web app is available at https://mlflow-dot-$${TF_VAR_project_id}.ew.r.appspot.com (You may have trouble connecting for a few minutes after the deployment, while IAP gets setup)"
@source vars && echo "The web app is available at https://mlflow-dot-$${APP_DEFAULT_URI} (You may have trouble connecting for a few minutes after the deployment, while IAP gets setup)"
@echo "To push your first experiment, take a look at the bottom of the readme for an example."


Expand Down
8 changes: 8 additions & 0 deletions bin/get-uri.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -e

APP_DESCRIBE=$(gcloud --format json app describe)
APP_DEFAULT_URI=$(echo "$APP_DESCRIBE" | jq -r '.defaultHostname')

./save_var.sh APP_DEFAULT_URI "$APP_DEFAULT_URI"
39 changes: 39 additions & 0 deletions bin/set_location.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

set -e

echo
echo "In which region do you want to deploy MLFlow ?"
echo

APP_REGIONS_LIST=$(gcloud --format json app regions list)
APP_REGIONS_NAMES=$(echo "$APP_REGIONS_LIST" | jq -r '.[].region')

counter=1
for REGION in $APP_REGIONS_NAMES
do
echo [$((counter++))] "$REGION"
done

MAX_CHOICE=$((counter - 1))
read -p 'Please enter your numeric choice: ' NUMERIC_CHOICE

while echo "$NUMERIC_CHOICE" | grep -vqE "^\-?[0-9]+$" || (( NUMERIC_CHOICE < 1 )) || (( NUMERIC_CHOICE > MAX_CHOICE ))
do
read -p "Please enter a value between 1 and $MAX_CHOICE: " NUMERIC_CHOICE
done
echo

APP_ENGINE_REGION="$(echo "$APP_REGIONS_LIST" | jq -r --argjson NUMERIC_CHOICE "$(( NUMERIC_CHOICE - 1 ))" '.[$NUMERIC_CHOICE].region')"

#locations europe-west1 and us-central1 are called europe-west and us-central in APP Engine commands
if [ $APP_ENGINE_REGION == 'europe-west' ];
then REGION='europe-west1'
elif [ $APP_ENGINE_REGION == 'us-central' ];
then REGION='us-central1'
else
REGION=$APP_ENGINE_REGION
fi

./save_var.sh TF_VAR_location "$REGION"
./save_var.sh TF_VAR_app_engine_location "$APP_ENGINE_REGION"