Setup Project 8

MLOps & Cloud Deployment Tooling Setup

Enable hardware nested virtualization components, install the Docker Engine container framework, initiate local MLflow experiment tracking servers, and create target cloud developer profiles.

Environment
Docker / MLflow / Cloud Platform
Difficulty
Intermediate (2/5)
Course Module
MLOps & Deployment
Deliverables
Docker run Logs & MLflow tracking Run
Nested Virtualization requirements: Running Docker container wrappers inside a VirtualBox virtual machine requires enabling Nested Virtualization in your VM settings. If the checkbox (Settings -> System -> Processor -> Enable Nested VT-x/AMD-V) is greyed out on your Windows Host, this guide details how to toggle this parameter using the VBoxManage tool command line in Windows.
1. System Architecture & Process Workflow

The diagram below displays the MLOps pipelines architecture. MLflow logs metrics and parameters locally to a metadata repository. Simultaneously, your Python application is packaged into a Docker container, creating an image loaded by local engine daemons or deployed directly to cloud platforms.

GUEST LINUX VM SANDBOX ENVIRONMENT App Code Log Run docker build MLflow Tracker (Port 5000) Params: learning_rate Metrics: accuracy, loss Docker Image api_service:latest Deploy Cloud VM Render / HF
2. Part 1: Step-by-Step Action Items & Key Execution Steps
STEP 1

Enable Nested Hardware Virtualization (Windows Host)

Toggle system processor register mappings via your local Windows Command Prompt to enable nested hypervisors.

Shutdown Linux VM -> Click Windows Start -> Search "cmd" -> Right-click "Command Prompt" -> Run as Administrator -> Enter command: C:\> "C:\Program Files\Oracle\VirtualBox\VBoxManage" modifyvm "Your_VM_Name" --nested-hw-virt on
This administrative command enables nested VT-x flags for your specific VM. Replace `"Your_VM_Name"` with the exact folder title of your VM.
STEP 2

Verify CPU settings inside VirtualBox GUI

Review VM CPU options inside the VirtualBox Settings dashboard before starting the VM.

Open VirtualBox Manager -> Select VM -> Click Settings -> Click System -> Click Processor tab -> Verify "Enable Nested VT-x/AMD-V" is checked -> Click OK
This graphical checklist step confirms that the nested hypervisor controller flag is active.
STEP 3

Boot Ubuntu VM and Register Docker GPG Keys

Open the shell terminal, configure certificate parameters, and fetch the security validation keys for Docker.

$ sudo apt update && sudo apt install -y ca-certificates curl gnupg $ sudo install -m 0755 -d /etc/apt/keyrings $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg $ sudo chmod a+r /etc/apt/keyrings/docker.gpg
This installs root certificates and imports Docker's secure encryption keys, protecting repository package signatures.
STEP 4

Register Docker Apt Repository Source

Add Docker's official package sources to your guest operating system's software lists.

$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
This creates a repository source file `docker.list` containing the download path matching your system's architecture.
STEP 5

Install Docker Engine and Compose Plugins

Refresh your repository indexes and install Docker's daemon engine and CLI utilities.

$ sudo apt update && sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
This downloads and configures the core container runtime environment on your local guest system.
STEP 6

Configure Non-Root User Docker Permissions

Add your user account to the system docker group to run containers without needing sudo prefixes.

$ sudo usermod -aG docker $USER && newgrp docker
This updates system access permissions and logs the current terminal session into the docker group, enabling direct container commands.
STEP 7

Test Docker Container Execution

Pull and run the official minimal test image to verify container execution works.

$ docker run hello-world
This pulls the lightweight test template and runs it. The terminal should display a "Hello from Docker!" success message.
STEP 8

Install MLflow in Conda Environment

Activate your course environment sandbox and install MLflow via pip packages.

$ conda activate ds_ai_ml && pip install mlflow
This action installs MLflow dependencies inside the virtual environment libraries directory.
STEP 9

Start Local MLflow Tracking Server

Launch the tracking server in the background and verify the dashboard inside Firefox.

$ mlflow server --host 127.0.0.1 --port 5000 &
This starts the dashboard server in the background (`&`). Open Firefox and browse to `http://127.0.0.1:5000` to verify the dashboard page loads.
STEP 10

Save and Run MLflow Diagnostic Script

Write a python script that logs mock parameters and run it to verify MLflow tracking.

$ nano ~/verify_mlops.py $ python ~/verify_mlops.py
This opens nano editor. Paste the verification script from Part 2, save, exit, and run it. The MLflow dashboard will register the training run parameters.
3. Operational Pipeline Architecture

The flowchart below outlines the MLOps setup pipeline. It details the steps from enabling nested virtualization and installing Docker CE to launching local tracking servers and logging mock metrics.

1. Nested VT Enable nested VT in host shell VBoxManage cmd 2. Install Docker Install docker-ce packages via apt apt-get install 3. Test Docker Configure groups and run hello-world docker run test 4. MLflow Init Start background tracking server mlflow server 5. Log Run Log dummy metrics and check dashboard verify_mlops.py
4. Part 2: Complete Deliverable Assets & Production Templates

To verify the MLflow tracking service operations, we will build a Python validation script. Below is a line-by-line explanation of the code, followed by the combined script.

Step-by-Step Code Construction

Lines 1 - 3

Import diagnostic modules

Include system, random utility, and MLflow library modules in the code script.

import mlflow import random import time
These imports check system paths and load the MLflow client interfaces alongside time delay engines.
Lines 4 - 7

Configure Tracking URI Location

Point the client program to the active local background server instance.

mlflow.set_tracking_uri("http://127.0.0.1:5000") mlflow.set_experiment("Environment_Setup_Diagnostics")
This maps connection addresses to port 5000 and registers an experiment name namespace inside the dashboard.
Lines 8 - 14

Log Run Parameters

Initialize a tracked run block, logging training parameters to the dashboard.

with mlflow.start_run(run_name="Setup_Verification_Run"): mlflow.log_param("optimizer_type", "Adam") mlflow.log_param("learning_rate", 0.001) mlflow.log_param("batch_size", 32)
This starts the active tracker session, recording static metadata values inside database tables on the server.
Lines 15 - 22

Log Progress Metrics

Simulate training progress, logging accuracy and loss values over 5 training steps.

for epoch in range(1, 6): loss_val = 0.5 / epoch + random.uniform(-0.02, 0.02) acc_val = 0.7 + (0.05 * epoch) + random.uniform(-0.01, 0.01) mlflow.log_metric("train_loss", loss_val, step=epoch) mlflow.log_metric("train_accuracy", acc_val, step=epoch) time.sleep(0.5)
This uses a loop to generate mock metrics, sending progress updates to the server to draw charts in the MLflow UI.
Lines 23 - 25

Finalize run logs

Output run details to the console to confirm that logs were saved successfully.

print("\nLocal MLOps run logged successfully to MLflow server!") print("Open http://127.0.0.1:5000 in your browser to verify.")
This prints confirmation logs, pointing you to the local dashboard portal.

Combined MLflow Diagnostic Script

Save the consolidated blocks above as ~/verify_mlops.py and execute it inside the active ds_ai_ml environment:

# verify_mlops.py - MLOps local tracking server verification script import mlflow import random import time def main(): print("=== MLOps & Experiment Tracking Diagnostics ===") # Bind database client connection to background server port mlflow.set_tracking_uri("http://127.0.0.1:5000") experiment_name = "Environment_Setup_Diagnostics" mlflow.set_experiment(experiment_name) print(f"Target MLflow Experiment namespace: '{experiment_name}'") # Begin logging session with mlflow.start_run(run_name="Setup_Verification_Run") as active_run: print("Logging parameters...") mlflow.log_param("optimizer_type", "Adam") mlflow.log_param("learning_rate", 0.001) mlflow.log_param("batch_size", 32) print("Logging step-by-step progress metrics...") for epoch in range(1, 6): # Calculate mock parameters loss_val = 0.5 / epoch + random.uniform(-0.02, 0.02) acc_val = 0.7 + (0.05 * epoch) + random.uniform(-0.01, 0.01) mlflow.log_metric("train_loss", loss_val, step=epoch) mlflow.log_metric("train_accuracy", acc_val, step=epoch) print(f" - Epoch {epoch}: loss={loss_val:.4f}, accuracy={acc_val:.4f}") time.sleep(0.2) print("\nLocal MLOps run logged successfully to MLflow server!") print("Open http://127.0.0.1:5000 in your browser to verify dashboard panels.") print("=== MLOps Setup Successfully Verified! ===") if __name__ == "__main__": main()
5. Deliverables Summary

Verify that the following configurations and outputs exist inside your project workspace.

Created Files / Templates

  • ~/verify_mlops.py - Verification python script file.

Verification Artifacts / Execution Proof

  • Terminal console output displaying correct Docker hello-world run strings.
  • Local MLflow UI dashboard accessible at http://127.0.0.1:5000.
  • Run metrics charts visible inside the MLflow experiment dashboard.
6. Closing Explanation: Why We Did This & What It Accomplishes

Architectural Intent & Operational Impact

Why We Did This

What This Accomplishes