Skip to content

Commit f58e0df

Browse files
author
j-so
committed
Merge branch 'master' into jenns/splitpipeline
2 parents cd450ec + 9056285 commit f58e0df

File tree

4 files changed

+68
-53
lines changed

4 files changed

+68
-53
lines changed

.pipelines/diabetes_regression-variables-template.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Pipeline template that defines common runtime environment variables.
22
variables:
3-
43
# Source Config
5-
# The directory containing the scripts for training, evaluating, and registering the model
4+
# The directory containing the scripts for training, evaluating, and registering the model
65
- name: SOURCES_DIR_TRAIN
76
value: diabetes_regression
87
# The path to the model training script under SOURCES_DIR_TRAIN
@@ -23,7 +22,7 @@ variables:
2322
value: mlopspython
2423
- name: DATASET_NAME
2524
value: diabetes_ds
26-
# Uncomment DATASTORE_NAME if you have configured non default datastore to point to your data
25+
# Uncomment DATASTORE_NAME if you have configured non default datastore to point to your data
2726
# - name: DATASTORE_NAME
2827
# value: datablobstore
2928
- name: DATASET_VERSION
@@ -50,16 +49,16 @@ variables:
5049
# The name for the (docker/webapp) scoring image
5150
- name: IMAGE_NAME
5251
value: "diabetestrained"
53-
52+
5453
# Optional. Used by a training pipeline with R on Databricks
5554
- name: DB_CLUSTER_ID
5655
value: ""
5756

5857
# These are the default values set in ml_service\util\env_variables.py. Uncomment and override if desired.
59-
# Set to false to disable the evaluation step in the ML pipeline and register the newly trained model unconditionally.
58+
# Set to false to disable the evaluation step in the ML pipeline and register the newly trained model unconditionally.
6059
# - name: RUN_EVALUATION
6160
# value: "true"
62-
# Set to false to register the model regardless of the outcome of the evaluation step in the ML pipeline.
61+
# Set to false to register the model regardless of the outcome of the evaluation step in the ML pipeline.
6362
# - name: ALLOW_RUN_CANCEL
6463
# value: "true"
6564

docs/getting_started.md

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
21
# Getting Started with MLOpsPython <!-- omit in toc -->
32

4-
This guide shows how to get MLOpsPython working with a sample ML project ***diabetes_regression***. The project creates a linear regression model to predict diabetes and has CI/CD DevOps practices enabled for model training and serving when these steps are completed in this getting started guide.
3+
This guide shows how to get MLOpsPython working with a sample ML project **_diabetes_regression_**. The project creates a linear regression model to predict diabetes and has CI/CD DevOps practices enabled for model training and serving when these steps are completed in this getting started guide.
54

6-
If you would like to bring your own model code to use this template structure, follow the [custom model](custom_model.md) guide. We recommend completing this getting started guide with the diabetes model through ACI deployment first to ensure everything is working in your environment before converting the template to use your own model code.
5+
If you would like to bring your own model code to use this template structure, follow the [custom model](custom_model.md) guide. We recommend completing this getting started guide with the diabetes model through ACI deployment first to ensure everything is working in your environment before converting the template to use your own model code.
76

87
- [Setting up Azure DevOps](#setting-up-azure-devops)
98
- [Install the Azure Machine Learning extension](#install-the-azure-machine-learning-extension)
@@ -46,13 +45,13 @@ We recommend using the [repository template](https://github.com/microsoft/MLOpsP
4645

4746
## Create a Variable Group for your Pipeline
4847

49-
MLOpsPython requires some variables to be set before you can run any pipelines. You'll need to create a *variable group* in Azure DevOps to store values that are reused across multiple pipelines or pipeline stages. Either store the values directly in [Azure DevOps](https://docs.microsoft.com/en-us/azure/devops/pipelines/library/variable-groups?view=azure-devops&tabs=designer#create-a-variable-group) or connect to an Azure Key Vault in your subscription. Check out the [Add & use variable groups](https://docs.microsoft.com/en-us/azure/devops/pipelines/library/variable-groups?view=azure-devops&tabs=yaml#use-a-variable-group) documentation to learn more about how to create a variable group and link it to your pipeline.
48+
MLOpsPython requires some variables to be set before you can run any pipelines. You'll need to create a _variable group_ in Azure DevOps to store values that are reused across multiple pipelines or pipeline stages. Either store the values directly in [Azure DevOps](https://docs.microsoft.com/en-us/azure/devops/pipelines/library/variable-groups?view=azure-devops&tabs=designer#create-a-variable-group) or connect to an Azure Key Vault in your subscription. Check out the [Add & use variable groups](https://docs.microsoft.com/en-us/azure/devops/pipelines/library/variable-groups?view=azure-devops&tabs=yaml#use-a-variable-group) documentation to learn more about how to create a variable group and link it to your pipeline.
5049

5150
Navigate to **Library** in the **Pipelines** section as indicated below:
5251

5352
![Library Variable Groups](./images/library_variable_groups.png)
5453

55-
Create a variable group named **``devopsforai-aml-vg``**. The YAML pipeline definitions in this repository refer to this variable group by name.
54+
Create a variable group named **`devopsforai-aml-vg`**. The YAML pipeline definitions in this repository refer to this variable group by name.
5655

5756
The variable group should contain the following required variables. **Azure resources that don't exist yet will be created in the [Provisioning resources using Azure Pipelines](#provisioning-resources-using-azure-pipelines) step below.**
5857

@@ -80,7 +79,7 @@ More variables are available for further tweaking, but the above variables are a
8079

8180
**WORKSPACE_NAME** is used for creating the Azure Machine Learning Workspace. You can provide an existing Azure ML Workspace here if you've got one.
8281

83-
**AZURE_RM_SVC_CONNECTION** is used by the [Azure Pipeline]((../environment_setup/iac-create-environment-pipeline.yml)) in Azure DevOps that creates the Azure ML workspace and associated resources through Azure Resource Manager. You'll create the connection in a [step below](#create-an-azure-devops-service-connection-for-the-azure-resource-manager).
82+
**AZURE_RM_SVC_CONNECTION** is used by the [Azure Pipeline](../environment_setup/iac-create-environment-pipeline.yml) in Azure DevOps that creates the Azure ML workspace and associated resources through Azure Resource Manager. You'll create the connection in a [step below](#create-an-azure-devops-service-connection-for-the-azure-resource-manager).
8483

8584
**WORKSPACE_SVC_CONNECTION** is used to reference a [service connection for the Azure ML workspace](#create-an-azure-devops-azure-ml-workspace-service-connection). You'll create the connection after [provisioning the workspace](#provisioning-resources-using-azure-pipelines) in the [Create an Azure DevOps Service Connection for the Azure ML Workspace](#create-an-azure-devops-service-connection-for-the-azure-ml-workspace) section below.
8685

@@ -92,11 +91,11 @@ The easiest way to create all required Azure resources (Resource Group, Azure ML
9291

9392
### Create an Azure DevOps Service Connection for the Azure Resource Manager
9493

95-
The [IaC provisioning pipeline]((../environment_setup/iac-create-environment-pipeline.yml)) requires an **Azure Resource Manager** [service connection](https://docs.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=azure-devops&tabs=yaml#create-a-service-connection).
94+
The [IaC provisioning pipeline](../environment_setup/iac-create-environment-pipeline.yml) requires an **Azure Resource Manager** [service connection](https://docs.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=azure-devops&tabs=yaml#create-a-service-connection).
9695

9796
![Create service connection](./images/create-rm-service-connection.png)
9897

99-
Leave the **``Resource Group``** field empty.
98+
Leave the **`Resource Group`** field empty.
10099

101100
**Note:** Creating the Azure Resource Manager service connection scope requires 'Owner' or 'User Access Administrator' permissions on the subscription.
102101
You'll also need sufficient permissions to register an application with your Azure AD tenant, or you can get the ID and secret of a service principal from your Azure AD Administrator. That principal must have 'Contributor' permissions on the subscription.
@@ -144,7 +143,7 @@ These pipelines use a Docker container on the Azure Pipelines agents to accompli
144143

145144
### Set up the Model CI, training, evaluation, and registration pipeline
146145

147-
In your Azure DevOps project, create and run a new build pipeline based on the [diabetes_regression-ci.yml](../.pipelines/diabetes_regression-ci.yml)
146+
In your Azure DevOps project, create and run a new build pipeline based on the [diabetes_regression-ci.yml](../.pipelines/diabetes_regression-ci.yml)
148147
pipeline definition in your forked repository.
149148

150149
If you plan to use the release deployment pipeline (in the next section), you will need to rename this pipeline to `Model-Train-Register-CI`.
@@ -175,15 +174,15 @@ The pipeline stages are summarized below:
175174

176175
- Linting (code quality analysis)
177176
- Unit tests and code coverage analysis
178-
- Build and publish *ML Training Pipeline* in an *ML Workspace*
177+
- Build and publish _ML Training Pipeline_ in an _ML Workspace_
179178

180179
#### Train model
181180

182-
- Determine the ID of the *ML Training Pipeline* published in the previous stage.
183-
- Trigger the *ML Training Pipeline* and waits for it to complete.
181+
- Determine the ID of the _ML Training Pipeline_ published in the previous stage.
182+
- Trigger the _ML Training Pipeline_ and waits for it to complete.
184183
- This is an **agentless** job. The CI pipeline can wait for ML pipeline completion for hours or even days without using agent resources.
185-
- Determine if a new model was registered by the *ML Training Pipeline*.
186-
- If the model evaluation determines that the new model doesn't perform any better than the previous one, the new model won't register and the *ML Training Pipeline* will be **canceled**. In this case, you'll see a message in the 'Train Model' job under the 'Determine if evaluation succeeded and new model is registered' step saying '**Model was not registered for this run.**'
184+
- Determine if a new model was registered by the _ML Training Pipeline_.
185+
- If the model evaluation determines that the new model doesn't perform any better than the previous one, the new model won't register and the _ML Training Pipeline_ will be **canceled**. In this case, you'll see a message in the 'Train Model' job under the 'Determine if evaluation succeeded and new model is registered' step saying '**Model was not registered for this run.**'
187186
- See [evaluate_model.py](../diabetes_regression/evaluate/evaluate_model.py#L118) for the evaluation logic.
188187
- [Additional Variables and Configuration](#additional-variables-and-configuration) for configuring this and other behavior.
189188

@@ -249,7 +248,9 @@ MLOpsPython also can deploy to [Azure Kubernetes Service](https://azure.microsof
249248

250249
Creating a cluster on Azure Kubernetes Service is out of scope of this tutorial, but you can find set up information on the [Quickstart: Deploy an Azure Kubernetes Service (AKS) cluster using the Azure portal](https://docs.microsoft.com/en-us/azure/aks/kubernetes-walkthrough-portal#create-an-aks-cluster) page.
251250

252-
**Note:** If your target deployment environment is a Kubernetes cluster and you want to implement Canary and/or A/B testing deployment strategies, check out this [tutorial](./canary_ab_deployment.md).
251+
> **_Note_**
252+
>
253+
> If your target deployment environment is a Kubernetes cluster and you want to implement Canary and/or A/B testing deployment strategies, check out this [tutorial](./canary_ab_deployment.md).
253254
254255
Keep the Azure Container Instances deployment active because it's a lightweight way to validate changes before deploying to Azure Kubernetes Service.
255256

@@ -260,7 +261,7 @@ In the Variables tab, edit your variable group (`devopsforai-aml-vg`). In the va
260261
| AKS_COMPUTE_NAME | aks |
261262
| AKS_DEPLOYMENT_NAME | mlops-aks |
262263

263-
Set **AKS_COMPUTE_NAME** to the *Compute name* of the Inference Cluster that references the Azure Kubernetes Service cluster in your Azure ML Workspace.
264+
Set **AKS_COMPUTE_NAME** to the _Compute name_ of the Inference Cluster that references the Azure Kubernetes Service cluster in your Azure ML Workspace.
264265

265266
After successfully deploying to Azure Container Instances, the next stage will deploy the model to Kubernetes and run a smoke test.
266267

@@ -296,18 +297,18 @@ Make sure your webapp has the credentials to pull the image from the Azure Conta
296297

297298
The build pipeline also supports building and publishing Azure ML pipelines using R to train a model. You can enable it by changing the `build-train-script` pipeline variable to either of the following values:
298299

299-
* `diabetes_regression_build_train_pipeline_with_r.py` to train a model with R on Azure ML Compute. You'll also need to uncomment (include) the `r-essentials` Conda packages in the environment definition YAML `diabetes_regression/conda_dependencies.yml`.
300-
* `diabetes_regression_build_train_pipeline_with_r_on_dbricks.py` to train a model with R on Databricks. You'll need to manually create a Databricks cluster and attach it to the Azure ML Workspace as a compute resource. Set the DB_CLUSTER_ID and DATABRICKS_COMPUTE_NAME variables in your variable group.
300+
- `diabetes_regression_build_train_pipeline_with_r.py` to train a model with R on Azure ML Compute. You'll also need to uncomment (include) the `r-essentials` Conda packages in the environment definition YAML `diabetes_regression/conda_dependencies.yml`.
301+
- `diabetes_regression_build_train_pipeline_with_r_on_dbricks.py` to train a model with R on Databricks. You'll need to manually create a Databricks cluster and attach it to the Azure ML Workspace as a compute resource. Set the DB_CLUSTER_ID and DATABRICKS_COMPUTE_NAME variables in your variable group.
301302

302303
Example ML pipelines using R have a single step to train a model. They don't demonstrate how to evaluate and register a model. The evaluation and registering techniques are shown only in the Python implementation.
303304

304305
### Observability and Monitoring
305306

306307
You can explore aspects of model observability in the solution, such as:
307308

308-
* **Logging**: Navigate to the Application Insights instance linked to the Azure ML Portal, then go to the Logs (Analytics) pane. The following sample query correlates HTTP requests with custom logs generated in `score.py`. This can be used, for example, to analyze query duration vs. scoring batch size:
309+
- **Logging**: Navigate to the Application Insights instance linked to the Azure ML Portal, then go to the Logs (Analytics) pane. The following sample query correlates HTTP requests with custom logs generated in `score.py`. This can be used, for example, to analyze query duration vs. scoring batch size:
309310

310-
```
311+
```sql
311312
let Traceinfo=traces
312313
| extend d=parse_json(tostring(customDimensions.Content))
313314
| project workspace=customDimensions.["Workspace Name"],
@@ -321,17 +322,17 @@ You can explore aspects of model observability in the solution, such as:
321322
| project-away id1
322323
```
323324

324-
* **Distributed tracing**: The smoke test client code sets an HTTP `traceparent` header (per the [W3C Trace Context proposed specification](https://www.w3.org/TR/trace-context-1)), and the `score.py` code logs the header. The query above shows how to surface this value. You can adapt it to your tracing framework.
325-
* **Monitoring**: You can use [Azure Monitor for containers](https://docs.microsoft.com/en-us/azure/azure-monitor/insights/container-insights-overview) to monitor the Azure ML scoring containers' performance.
325+
- **Distributed tracing**: The smoke test client code sets an HTTP `traceparent` header (per the [W3C Trace Context proposed specification](https://www.w3.org/TR/trace-context-1)), and the `score.py` code logs the header. The query above shows how to surface this value. You can adapt it to your tracing framework.
326+
- **Monitoring**: You can use [Azure Monitor for containers](https://docs.microsoft.com/en-us/azure/azure-monitor/insights/container-insights-overview) to monitor the Azure ML scoring containers' performance.
326327

327328
### Clean up the example resources
328329

329330
To remove the resources created for this project, use the [/environment_setup/iac-remove-environment-pipeline.yml](../environment_setup/iac-remove-environment-pipeline.yml) definition or you can just delete the resource group in the [Azure Portal](https://portal.azure.com).
330331

331332
## Next Steps: Integrating your project
332333

333-
* The [custom model](custom_model.md) guide includes information on bringing your own code to this repository template.
334-
* Consider using [Azure Pipelines self-hosted agents](https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/agents?view=azure-devops&tabs=browser#install) to speed up your Azure ML pipeline execution. The Docker container image for the Azure ML pipeline is sizable, and having it cached on the agent between runs can trim several minutes from your runs.
334+
- The [custom model](custom_model.md) guide includes information on bringing your own code to this repository template.
335+
- Consider using [Azure Pipelines self-hosted agents](https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/agents?view=azure-devops&tabs=browser#install) to speed up your Azure ML pipeline execution. The Docker container image for the Azure ML pipeline is sizable, and having it cached on the agent between runs can trim several minutes from your runs.
335336

336337
### Additional Variables and Configuration
337338

@@ -341,7 +342,7 @@ There are more variables used in the project. They're defined in two places: one
341342

342343
For using Azure Pipelines, all other variables are stored in the file `.pipelines/diabetes_regression-variables-template.yml`. Using the default values as a starting point, adjust the variables to suit your requirements.
343344

344-
In that folder, you'll also find the `parameters.json` file that we recommend using to provide parameters for training, evaluation, and scoring scripts. The sample parameter that `diabetes_regression` uses is the ridge regression [*alpha* hyperparameter](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Ridge.html). We don't provide any serializers for this config file.
345+
In that folder, you'll also find the `parameters.json` file that we recommend using to provide parameters for training, evaluation, and scoring scripts. The sample parameter that `diabetes_regression` uses is the ridge regression [_alpha_ hyperparameter](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Ridge.html). We don't provide any serializers for this config file.
345346

346347
#### Local configuration
347348

environment_setup/arm-templates/cloud-environment.json

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@
4545
"acr": {
4646
"type": "string",
4747
"defaultValue": "[concat(toLower(parameters('baseName')),'amlcr')]"
48+
},
49+
"sku": {
50+
"type": "string",
51+
"defaultValue": "basic",
52+
"allowedValues": [
53+
"basic",
54+
"enterprise"
55+
],
56+
"metadata": {
57+
"description": "Specifies the sku, also referred as 'edition' of the Azure Machine Learning workspace."
58+
}
4859
}
4960
},
5061
"variables": {
@@ -92,7 +103,8 @@
92103
"name": "standard",
93104
"family": "A"
94105
},
95-
"accessPolicies": []
106+
"accessPolicies": [
107+
]
96108
}
97109
},
98110
{
@@ -131,13 +143,17 @@
131143
"identity": {
132144
"type": "systemAssigned"
133145
},
146+
"sku": {
147+
"tier": "[parameters('sku')]",
148+
"name": "[parameters('sku')]"
149+
},
134150
"properties": {
135151
"friendlyName": "[variables('amlWorkspaceName')]",
136152
"keyVault": "[resourceId('Microsoft.KeyVault/vaults',variables('keyVaultName'))]",
137153
"applicationInsights": "[resourceId('Microsoft.Insights/components',variables('applicationInsightsName'))]",
138154
"containerRegistry": "[resourceId('Microsoft.ContainerRegistry/registries',variables('containerRegistryName'))]",
139155
"storageAccount": "[resourceId('Microsoft.Storage/storageAccounts/',variables('storageAccountName'))]"
140156
}
141-
}
157+
}
142158
]
143159
}

0 commit comments

Comments
 (0)