You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Azure CLI ml extension (v2)](how-to-configure-cli.md)
56
56
57
57
For more information, see the guide on [how to prepare your system to deploy online endpoints](how-to-deploy-online-endpoints.md#prepare-your-system).
58
58
59
-
The examples in this article are based on code samples contained in the [azureml-examples](https://github.com/azure/azureml-examples) repository. To run the commands locally without having to copy/paste YAML and other files, clone the repo and then change directories to the `cli` directory in the repo:
59
+
The examples in this article are based on code samples contained in the [azureml-examples](https://github.com/azure/azureml-examples)GitHub repository. To run the commands locally without having to copy/paste YAML and other files, clone the repo and then change directories to the *azureml-examples/cli* directory in the repo:
If you haven't already set the defaults for the Azure CLI, save your default settings. To avoid passing in the values for your subscription, workspace, and resource group multiple times, use the following commands. Replace the following parameters with values for your specific configuration:
@@ -80,27 +79,28 @@ az configure --defaults workspace=<workspace> group=<resource-group> location=<l
For more information, see the guide on [how to prepare your system to deploy online endpoints](how-to-deploy-online-endpoints.md#prepare-your-system).
94
94
95
-
The examples in this article can be found in the [Debug online endpoints locally in Visual Studio Code](https://github.com/Azure/azureml-examples/blob/main/sdk/python/endpoints/online/managed/debug-online-endpoints-locally-in-visual-studio-code.ipynb)notebook within the[azureml-examples](https://github.com/azure/azureml-examples) repository. To run the code locally, clone the repo and then change directories to the notebook's parent directory `sdk/endpoints/online/managed`.
95
+
The examples in this article can be found in the Jupyter notebook called [Debug online endpoints locally in Visual Studio Code](https://github.com/Azure/azureml-examples/blob/main/sdk/python/endpoints/online/managed/debug-online-endpoints-locally-in-visual-studio-code.ipynb) within the[azureml-examples](https://github.com/azure/azureml-examples) repository. To run the code locally, clone the repo and then change directories to the notebook's parent directory *sdk/endpoints/online/managed*.
Open the Jupyter notebook and import the required modules:
104
104
105
105
```python
106
106
from azure.ai.ml import MLClient
@@ -112,25 +112,25 @@ from azure.ai.ml.entities import (
112
112
Environment,
113
113
)
114
114
from azure.identity import DefaultAzureCredential
115
-
```
115
+
```
116
116
117
-
Set up variables for the workspace and endpoint:
117
+
Set up variables for the workspace and endpoint:
118
118
119
-
```python
119
+
```python
120
120
subscription_id ="<SUBSCRIPTION_ID>"
121
121
resource_group ="<RESOURCE_GROUP>"
122
122
workspace_name ="<AML_WORKSPACE_NAME>"
123
123
124
124
endpoint_name ="<ENDPOINT_NAME>"
125
-
```
125
+
```
126
126
127
-
---
127
+
---
128
128
129
129
## Launch development container
130
130
131
131
# [Azure CLI](#tab/cli)
132
132
133
-
Azure Machine Learning local endpoints use Docker and VS Code development containers (dev container) to build and configure a local debugging environment. With dev containers, you can take advantage of VS Code features from inside a Docker container. For more information on dev containers, see [Create a development container](https://code.visualstudio.com/docs/remote/create-dev-container).
133
+
Azure Machine Learning local endpoints use Docker and VS Code development containers (dev containers) to build and configure a local debugging environment. With dev containers, you can take advantage of VS Code features from inside a Docker container. For more information on dev containers, see [Create a development container](https://code.visualstudio.com/docs/remote/create-dev-container).
134
134
135
135
To debug online endpoints locally in VS Code, use the `--vscode-debug` flag when creating or updating and Azure Machine Learning online deployment. The following command uses a deployment example from the examples repo:
136
136
@@ -144,7 +144,7 @@ az ml online-deployment create --file endpoints/online/managed/sample/blue-deplo
144
144
A Docker image is built locally. Any environment configuration or model file errors are surfaced at this stage of the process.
145
145
146
146
> [!NOTE]
147
-
> The first time you launch a new or updated dev container it can take several minutes.
147
+
> The first time you launch a new or updated dev container, it can take several minutes.
148
148
149
149
Once the image successfully builds, your dev container opens in a VS Code window.
150
150
@@ -158,22 +158,21 @@ You'll use a few VS Code extensions to debug your deployments in the dev contain
158
158
> [!IMPORTANT]
159
159
> Before starting your debug session, make sure that the VS Code extensions have finished installing in your dev container.
160
160
161
-
162
161
# [Python](#tab/python)
163
162
164
163
Azure Machine Learning local endpoints use Docker and VS Code development containers (dev container) to build and configure a local debugging environment. With dev containers, you can take advantage of VS Code features from inside a Docker container. For more information on dev containers, see [Create a development container](https://code.visualstudio.com/docs/remote/create-dev-container).
165
164
166
-
Get a handle to the workspace:
165
+
Get a handle to the workspace:
167
166
168
-
```python
167
+
```python
169
168
credential = DefaultAzureCredential()
170
169
ml_client = MLClient(
171
170
credential,
172
171
subscription_id=subscription_id,
173
172
resource_group_name=resource_group,
174
173
workspace_name=workspace_name,
175
174
)
176
-
```
175
+
```
177
176
178
177
To debug online endpoints locally in VS Code, set the `vscode-debug` and `local` flags when creating or updating an Azure Machine Learning online deployment. The following code mirrors a deployment example from the examples repo:
179
178
@@ -199,41 +198,38 @@ You'll use a few VS Code extensions to debug your deployments in the dev contain
199
198
> [!IMPORTANT]
200
199
> Before starting your debug session, make sure that the VS Code extensions have finished installing in your dev container.
201
200
202
-
---
203
-
204
-
205
-
206
201
---
207
202
208
203
## Start debug session
209
204
210
205
Once your environment is set up, use the VS Code debugger to test and debug your deployment locally.
211
206
212
-
1. Open your scoring script in Visual Studio Code.
207
+
1. Open your scoring script in VS Code.
213
208
214
209
> [!TIP]
215
-
> The score.py script used by the endpoint deployed earlier is located at `azureml-samples/cli/endpoints/online/managed/sample/score.py` in the repository you cloned. However, the steps in this guide work with any scoring script.
210
+
> The *score.py* script used by the endpoint deployed earlier is located at *azureml-samples/cli/endpoints/online/managed/sample/score.py* in the repository you cloned. However, the steps in this guide work with any scoring script.
216
211
217
212
1. Set a breakpoint anywhere in your scoring script.
218
213
219
214
- To debug startup behavior, place your breakpoint(s) inside the `init` function.
220
215
- To debug scoring behavior, place your breakpoint(s) inside the `run` function.
221
216
222
217
1. Select the VS Code Job view.
223
-
1. In the Run and Debug dropdown, select **AzureML: Debug Local Endpoint** to start debugging your endpoint locally.
218
+
219
+
1. In the **Run and Debug** dropdown, select **AzureML: Debug Local Endpoint** to start debugging your endpoint locally.
224
220
225
221
In the **Breakpoints** section of the Run view, check that:
:::image type="content" source="media/how-to-debug-managed-online-endpoints-visual-studio-code/configure-debug-profile.png" alt-text="Screenshot showing how to configure Azure Machine Learning Debug Local Environment debug profile" lightbox="media/how-to-debug-managed-online-endpoints-visual-studio-code/configure-debug-profile.png":::
231
227
232
-
1. Select the play icon next to the Run and Debug dropdown to start your debugging session.
228
+
1. Select the play icon next to the **Run and Debug** dropdown to start your debugging session.
233
229
234
230
At this point, any breakpoints in your `init` function are caught. Use the debug actions to step through your code. For more information on debug actions, see the [debug actions guide](https://code.visualstudio.com/Docs/editor/debugging#_debug-actions).
235
231
236
-
For more information on the VS Code debugger, see [Debugging in VS Code](https://code.visualstudio.com/Docs/editor/debugging)
232
+
For more information on the VS Code debugger, see [Debugging in VS Code](https://code.visualstudio.com/Docs/editor/debugging).
237
233
238
234
## Debug your endpoint
239
235
@@ -283,7 +279,6 @@ In this case, `<REQUEST-FILE>` is a JSON file that contains input data samples f
283
279
284
280
At this point, any breakpoints in your `run` function are caught. Use the debug actions to step through your code. For more information on debug actions, see the [debug actions guide](https://code.visualstudio.com/Docs/editor/debugging#_debug-actions).
285
281
286
-
287
282
# [Python](#tab/python)
288
283
289
284
Now that your application is running in the debugger, try making a prediction to debug your scoring script.
@@ -334,9 +329,7 @@ In this case, `<REQUEST-FILE>` is a JSON file that contains input data samples f
334
329
335
330
At this point, any breakpoints in your `run` function are caught. Use the debug actions to step through your code. For more information on debug actions, see the [debug actions guide](https://code.visualstudio.com/Docs/editor/debugging#_debug-actions).
336
331
337
-
338
-
---
339
-
332
+
---
340
333
341
334
## Edit your endpoint
342
335
@@ -346,13 +339,13 @@ As you debug and troubleshoot your application, there are scenarios where you ne
346
339
347
340
To apply changes to your code:
348
341
349
-
1. Update your code
342
+
1. Update your code.
350
343
1. Restart your debug session using the `Developer: Reload Window` command in the command palette. For more information, see the [command palette documentation](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette).
351
344
352
345
> [!NOTE]
353
346
> Since the directory containing your code and endpoint assets is mounted onto the dev container, any changes you make in the dev container are synced with your local file system.
354
347
355
-
For more extensive changes involving updates to your environment and endpoint configuration, use the `ml` extension `update` command. Doing so will trigger a full image rebuild with your changes.
348
+
For more extensive changes involving updates to your environment and endpoint configuration, use the `ml` extension `update` command. Doing so triggers a full image rebuild with your changes.
356
349
357
350
```azurecli
358
351
az ml online-deployment update --file<DEPLOYMENT-YAML-SPECIFICATION-FILE>--local --vscode-debug
@@ -366,23 +359,21 @@ As you debug and troubleshoot your application, there are scenarios where you ne
366
359
367
360
To apply changes to your code:
368
361
369
-
1. Update your code
362
+
1. Update your code.
370
363
1. Restart your debug session using the `Developer: Reload Window` command in the command palette. For more information, see the [command palette documentation](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette).
371
364
372
365
> [!NOTE]
373
366
> Since the directory containing your code and endpoint assets is mounted onto the dev container, any changes you make in the dev container are synced with your local file system.
374
367
375
-
For more extensive changes involving updates to your environment and endpoint configuration, use your `MLClient`'s `online_deployments.update` module/method. Doing so will trigger a full image rebuild with your changes.
368
+
For more extensive changes involving updates to your environment and endpoint configuration, use your `MLClient`'s `online_deployments.update` module/method. Doing so triggers a full image rebuild with your changes.
0 commit comments