MLOps Engineer: Productionizing Machine Learning Workloads.Part 2

Part 2.

William Aaron
3 min readJan 1, 2024

Link to Part 1 : https://medium.com/@waaron.icloud/mlops-engineer-productionizing-machine-learning-workloads-1eccb513ee0a

Creating a Compute for Code Development

In this segment, you’ll establish a compute instance to kickstart your development journey. Each subsequent section will guide you through the process of creating these essential resources within your Azure Machine Learning Service (AMLS) workspace, employing MLOps as Code.

On your Terminal, execute the following.

az ml compute create \
— name amlcomputeinstance01 \
— size STANDARD_D3_V2 \
— type ComputeInstance \
— resource-group aml-dev-rg \
— workspace-name aml-ws

Integrating AMLS with VSCODE

Once your Compute Instance VM for computing is set up, you can utilize it for coding in either R or Python. Notably, you have the flexibility to code in Jupyter, JupyterLab, Visual Studio Code (VSCode), or a terminal. Jupyter and JupyterLab serve as integrated development environments (IDEs) for Python coding, while VS Code, recommended by Microsoft, supports scripting in both R and Python, along with numerous other languages.

In this segment, we’ll kick off by Integrating your VSCODE with your AMLS by establishing a connection to your AMLS workspace.

  1. Download and install VS Code at https://code.visualstudio.com/download.
  2. From within VS Code, click on the EXTENSIONS icon (Ctrl + Shift + x), search for Azure Machine Learning, and select Install:

3. Log in to your Azure account by pressing Ctrl + Shift + P and entering the following command:
>Azure: Sign In
A new browser window will open for you to provide your credentials and complete the sign-in process.

5. Select your default workspace through the command palette (Ctrl + Shift + P) and enter:
>Azure ML: Set Default Workspace
Follow the prompts to choose your subscription and workspace settings.

6. Navigate to the Azure icon (Shift + Alt + A), and access the MACHINE LEARNING section.
7. In the Machine Learning section of the Azure icon, right-click as depicted below and choose Connect for our compute instance.

8. Upon execution, a fresh instance of VS Code will be initiated on your local machine. Within this new VS Code instance, you’ll observe the user directory.

9. Create a new file devcode.ipynb

10. Choose your Python interpreter from the top-right corner by clicking on “Select Kernel.” Opt for the “azureml_py310_sdkv2” kernel.

11. Once you’ve chosen the interpreter, proceed to create a print statement.

import os

directory_path = os.getcwd()

print(“My current directory is :” + directory_path)

To run this code, click the play button to the left of the cell (Ctrl + Enter). Keep in mind that the provided Python code will display the current working directory. The execution occurs on the compute instance, as evidenced by the printed directory path.

Saving the notebook within VS Code will store the notebook in your Azure Machine Learning Service (AMLS) workspace.

In this segment, you’ve installed VS Code, the AML VS Code extension, and established a connection to your compute instance within your Azure Machine Learning Service (AMLS) workspace for code execution. VS Code offers IntelliSense, code running and debugging capabilities, and seamless Git integration. The amalgamation of these features, coupled with integration into your AMLS workspace, positions VS Code as the optimal choice for development.

--

--