Skip to content

Commit d591386

Browse files
authored
Merge pull request #5500 from v-albemi/deploy-pipelines
Freshness Edit: Azure ML Pipelines
2 parents deba16b + 835de19 commit d591386

File tree

3 files changed

+49
-46
lines changed

3 files changed

+49
-46
lines changed

articles/machine-learning/includes/machine-learning-sdk-v1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ ms.date: 04/22/2022
66
ms.author: sgilley
77
---
88

9-
**APPLIES TO:** :::image type="icon" source="../media/yes.png" border="false"::: [Python SDK azureml **v1**](/python/api/overview/azure/ml/?view=azure-ml-py&preserve-view=true)
9+
**APPLIES TO:** :::image type="icon" source="../media/yes.png" border="false"::: [Azure Machine Learning SDK v1 for Python](/python/api/overview/azure/ml/?view=azure-ml-py&preserve-view=true)

articles/machine-learning/v1/how-to-deploy-pipelines.md

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Publish ML pipelines
2+
title: Publish ML Pipelines
33
titleSuffix: Azure Machine Learning
44
description: Run machine learning workflows with machine learning pipelines and the Azure Machine Learning SDK for Python.
55
services: machine-learning
@@ -8,9 +8,11 @@ ms.subservice: mlops
88
author: lgayhardt
99
ms.author: lagayhar
1010
ms.reviewer: zhanxia
11-
ms.date: 10/21/2021
11+
ms.date: 06/18/2025
1212
ms.topic: how-to
1313
ms.custom: UpdateFrequency5, sdkv1, devx-track-python
14+
15+
#customer intent: As a machine learning engineer, I want to publish a machine learning pipeline so that I can share it.
1416
---
1517

1618
# Publish machine learning pipelines
@@ -19,23 +21,23 @@ ms.custom: UpdateFrequency5, sdkv1, devx-track-python
1921

2022
[!INCLUDE [v1 deprecation](../includes/sdk-v1-deprecation.md)]
2123

22-
This article will show you how to share a machine learning pipeline with your colleagues or customers.
24+
This article describes how to share a machine learning pipeline with your colleagues or customers.
2325

24-
Machine learning pipelines are reusable workflows for machine learning tasks. One benefit of pipelines is increased collaboration. You can also version pipelines, allowing customers to use the current model while you're working on a new version.
26+
Machine learning pipelines are reusable workflows for machine learning tasks. One benefit of pipelines is increased collaboration. You can also version pipelines to enable customers to use the current model while you're working on a new version.
2527

2628
## Prerequisites
2729

28-
* Create an [Azure Machine Learning workspace](../quickstart-create-resources.md) to hold all your pipeline resources
30+
* Create an [Azure Machine Learning workspace](../quickstart-create-resources.md) to contain your pipeline resources.
2931

30-
* [Configure your development environment](how-to-configure-environment.md) to install the Azure Machine Learning SDK, or use an [Azure Machine Learning compute instance](../concept-compute-instance.md) with the SDK already installed
32+
* [Configure your development environment](how-to-configure-environment.md) by installing the Azure Machine Learning SDK, or use an [Azure Machine Learning compute instance](../concept-compute-instance.md) that already has the SDK installed.
3133

32-
* Create and run a machine learning pipeline, such as by following [Tutorial: Build an Azure Machine Learning pipeline for batch scoring](../tutorial-pipeline-batch-scoring-classification.md). For other options, see [Create and run machine learning pipelines with Azure Machine Learning SDK](./how-to-create-machine-learning-pipelines.md)
34+
* Create and run a machine learning pipeline. One way to meet this requirement is to complete [Tutorial: Build an Azure Machine Learning pipeline for batch scoring](../tutorial-pipeline-batch-scoring-classification.md). For other options, see [Create and run machine learning pipelines with Azure Machine Learning SDK](./how-to-create-machine-learning-pipelines.md).
3335

3436
## Publish a pipeline
3537

36-
Once you have a pipeline up and running, you can publish a pipeline so that it runs with different inputs. For the REST endpoint of an already published pipeline to accept parameters, you must configure your pipeline to use `PipelineParameter` objects for the arguments that will vary.
38+
After you have a running pipeline, you can publish it so that it runs with different inputs. For the REST endpoint of a published pipeline to accept parameters, you must configure your pipeline to use `PipelineParameter` objects for the arguments that will vary.
3739

38-
1. To create a pipeline parameter, use a [PipelineParameter](/python/api/azureml-pipeline-core/azureml.pipeline.core.graph.pipelineparameter) object with a default value.
40+
1. To create a pipeline parameter, use a [PipelineParameter](/python/api/azureml-pipeline-core/azureml.pipeline.core.graph.pipelineparameter) object with a default value:
3941

4042
```python
4143
from azureml.pipeline.core.graph import PipelineParameter
@@ -45,7 +47,7 @@ Once you have a pipeline up and running, you can publish a pipeline so that it r
4547
default_value=10)
4648
```
4749

48-
2. Add this `PipelineParameter` object as a parameter to any of the steps in the pipeline as follows:
50+
1. Add the `PipelineParameter` object as a parameter to any of the steps in the pipeline, as shown here:
4951

5052
```python
5153
compareStep = PythonScriptStep(
@@ -57,7 +59,7 @@ Once you have a pipeline up and running, you can publish a pipeline so that it r
5759
source_directory=project_folder)
5860
```
5961

60-
3. Publish this pipeline that will accept a parameter when invoked.
62+
1. Publish this pipeline, which will accept a parameter when invoked:
6163

6264
```python
6365
published_pipeline1 = pipeline_run1.publish_pipeline(
@@ -66,18 +68,18 @@ Once you have a pipeline up and running, you can publish a pipeline so that it r
6668
version="1.0")
6769
```
6870

69-
4. After you publish your pipeline, you can check it in the UI. Pipeline ID is the unique identified of the published pipeline.
71+
1. After you publish your pipeline, you can check it in the UI. **Pipeline ID** is the unique identifier of the published pipeline.
7072

71-
:::image type="content" source="./media/how-to-deploy-pipelines/published-pipeline-detail.png" alt-text="Screenshot showing published pipeline detail." lightbox= "./media/how-to-deploy-pipelines/published-pipeline-detail.png":::
73+
:::image type="content" source="./media/how-to-deploy-pipelines/published-pipeline-detail.png" alt-text="Screenshot showing details of the published pipeline." lightbox= "./media/how-to-deploy-pipelines/published-pipeline-detail.png":::
7274

7375
## Run a published pipeline
7476

75-
All published pipelines have a REST endpoint. With the pipeline endpoint, you can trigger a run of the pipeline from any external systems, including non-Python clients. This endpoint enables "managed repeatability" in batch scoring and retraining scenarios.
77+
All published pipelines have a REST endpoint. By using the pipeline endpoint, you can trigger a run of the pipeline from external systems, including non-Python clients. This endpoint enables managed repeatability in batch scoring and retraining scenarios.
7678

7779
> [!IMPORTANT]
78-
> If you are using Azure role-based access control (Azure RBAC) to manage access to your pipeline, [set the permissions for your pipeline scenario (training or scoring)](../how-to-assign-roles.md#common-scenarios).
80+
> If you use Azure role-based access control (RBAC) to manage access to your pipeline, [set the permissions for your pipeline scenario (training or scoring)](../how-to-assign-roles.md#common-scenarios).
7981
80-
To invoke the run of the preceding pipeline, you need a Microsoft Entra authentication header token. Getting such a token is described in the [AzureCliAuthentication class](/python/api/azureml-core/azureml.core.authentication.azurecliauthentication) reference and in the [Authentication in Azure Machine Learning](https://aka.ms/pl-restep-auth) notebook.
82+
To invoke the run of the preceding pipeline, you need a Microsoft Entra authentication header token. The process for getting a token is described in the [AzureCliAuthentication class](/python/api/azureml-core/azureml.core.authentication.azurecliauthentication) reference and in the [Authentication in Azure Machine Learning](https://aka.ms/pl-restep-auth) notebook.
8183

8284
```python
8385
from azureml.pipeline.core import PublishedPipeline
@@ -89,19 +91,19 @@ response = requests.post(published_pipeline1.endpoint,
8991
"ParameterAssignments": {"pipeline_arg": 20}})
9092
```
9193

92-
The `json` argument to the POST request must contain, for the `ParameterAssignments` key, a dictionary containing the pipeline parameters and their values. In addition, the `json` argument may contain the following keys:
94+
The `json` argument to the POST request must contain, for the `ParameterAssignments` key, a dictionary that contains the pipeline parameters and their values. In addition, the `json` argument can contain the following keys:
9395

9496
| Key | Description |
9597
| --- | --- |
96-
| `ExperimentName` | The name of the experiment associated with this endpoint |
97-
| `Description` | Freeform text describing the endpoint |
98-
| `Tags` | Freeform key-value pairs that can be used to label and annotate requests |
99-
| `DataSetDefinitionValueAssignments` | Dictionary used for changing datasets without retraining (see discussion below) |
100-
| `DataPathAssignments` | Dictionary used for changing datapaths without retraining (see discussion below) |
98+
| `ExperimentName` | The name of the experiment associated with the endpoint. |
99+
| `Description` | Freeform text that describes the endpoint. |
100+
| `Tags` | Freeform key-value pairs that can be used to label and annotate requests. |
101+
| `DataSetDefinitionValueAssignments` | A dictionary that's used for changing datasets without retraining. (See the discussion later in this article.) |
102+
| `DataPathAssignments` | A dictionary that's used for changing datapaths without retraining. (See the discussion later in this article.) |
101103

102-
### Run a published pipeline using C#
104+
### Run a published pipeline by using C#
103105

104-
The following code shows how to call a pipeline asynchronously from C#. The partial code snippet just shows the call structure and isn't part of a Microsoft sample. It doesn't show complete classes or error handling.
106+
The following code shows how to call a pipeline asynchronously from C#. The partial code snippet just shows the call structure. It doesn't show complete classes or error handling. It isn't part of a Microsoft sample.
105107

106108
```csharp
107109
[DataContract]
@@ -138,7 +140,7 @@ using (HttpClient client = new HttpClient())
138140
string auth_key = "your-auth-key";
139141
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", auth_key);
140142

141-
// submit the job
143+
// Submit the job
142144
var requestPayload = JsonConvert.SerializeObject(submitPipelineRunRequest);
143145
var httpContent = new StringContent(requestPayload, Encoding.UTF8, "application/json");
144146
var submitResponse = await client.PostAsync(RestEndpoint, httpContent).ConfigureAwait(false);
@@ -154,9 +156,9 @@ using (HttpClient client = new HttpClient())
154156
}
155157
```
156158

157-
### Run a published pipeline using Java
159+
### Run a published pipeline by using Java
158160

159-
The following code shows a call to a pipeline that requires authentication (see [Set up authentication for Azure Machine Learning resources and workflows](how-to-setup-authentication.md)). If your pipeline is deployed publicly, you don't need the calls that produce `authKey`. The partial code snippet doesn't show Java class and exception-handling boilerplate. The code uses `Optional.flatMap` for chaining together functions that may return an empty `Optional`. The use of `flatMap` shortens and clarifies the code, but note that `getRequestBody()` swallows exceptions.
161+
The following code shows a call to a pipeline that requires authentication. (See [Set up authentication for Azure Machine Learning resources and workflows](how-to-setup-authentication.md).) If your pipeline is deployed publicly, you don't need the calls that produce `authKey`. The partial code snippet doesn't show Java class and exception-handling boilerplate. The code uses `Optional.flatMap` for chaining together functions that might return an empty `Optional`. The use of `flatMap` shortens and clarifies the code, but note that `getRequestBody()` swallows exceptions.
160162

161163
```java
162164
import java.net.URI;
@@ -182,7 +184,7 @@ Optional<String> authBody = getRequestBody(client, tokenAuthenticationRequest);
182184
Optional<String> authKey = authBody.flatMap(body -> Optional.of(gson.fromJson(body, AuthenticationBody.class).access_token));
183185
Optional<HttpRequest> scoringRequest = authKey.flatMap(key -> Optional.of(scoringRequest(key, scoringUri, dataToBeScored)));
184186
Optional<String> scoringResult = scoringRequest.flatMap(req -> getRequestBody(client, req));
185-
// ... etc (`scoringResult.orElse()`) ...
187+
// ... etc. (`scoringResult.orElse()`) ...
186188

187189
static HttpRequest tokenAuthenticationRequest(String tenantId, String clientId, String clientSecret, String resourceManagerUrl)
188190
{
@@ -238,9 +240,9 @@ class AuthenticationBody {
238240
}
239241
```
240242

241-
### Changing datasets and datapaths without retraining
243+
### Change datasets and datapaths without retraining
242244

243-
You might want to train and inference on different datasets and datapaths. For instance, you may wish to train on a smaller dataset but inference on the complete dataset. You switch datasets with the `DataSetDefinitionValueAssignments` key in the request's `json` argument. You switch datapaths with `DataPathAssignments`. The technique for both is similar:
245+
You might want to train and inference on different datasets and datapaths. For example, you might want to train on a smaller dataset but inference on the complete dataset. You can switch datasets by using the `DataSetDefinitionValueAssignments` key in the request's `json` argument. You can switch datapaths by using `DataPathAssignments`. The technique is similar for both:
244246

245247
1. In your pipeline definition script, create a `PipelineParameter` for the dataset. Create a `DatasetConsumptionConfig` or `DataPath` from the `PipelineParameter`:
246248

@@ -250,19 +252,19 @@ You might want to train and inference on different datasets and datapaths. For i
250252
tabular_ds_consumption = DatasetConsumptionConfig("tabular_dataset", tabular_pipeline_param)
251253
```
252254

253-
1. In your ML script, access the dynamically specified dataset using `Run.get_context().input_datasets`:
255+
1. In your machine learning script, access the dynamically specified dataset by using `Run.get_context().input_datasets`:
254256

255257
```python
256258
from azureml.core import Run
257259

258260
input_tabular_ds = Run.get_context().input_datasets['tabular_dataset']
259261
dataframe = input_tabular_ds.to_pandas_dataframe()
260-
# ... etc ...
262+
# ... etc. ...
261263
```
262264

263-
Notice that the ML script accesses the value specified for the `DatasetConsumptionConfig` (`tabular_dataset`) and not the value of the `PipelineParameter` (`tabular_ds_param`).
265+
Notice that the machine learning script accesses the value specified for `DatasetConsumptionConfig` (`tabular_dataset`) and not the value of `PipelineParameter` (`tabular_ds_param`).
264266

265-
1. In your pipeline definition script, set the `DatasetConsumptionConfig` as a parameter to the `PipelineScriptStep`:
267+
1. In your pipeline definition script, set `DatasetConsumptionConfig` as a parameter to `PipelineScriptStep`:
266268

267269
```python
268270
train_step = PythonScriptStep(
@@ -294,11 +296,11 @@ You might want to train and inference on different datasets and datapaths. For i
294296
}}}})
295297
```
296298

297-
The notebooks [Showcasing Dataset and PipelineParameter](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-showcasing-dataset-and-pipelineparameter.ipynb) and [Showcasing DataPath and PipelineParameter](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-showcasing-datapath-and-pipelineparameter.ipynb) have complete examples of this technique.
299+
The notebooks [Showcasing Dataset and PipelineParameter](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-showcasing-dataset-and-pipelineparameter.ipynb) and [Showcasing DataPath and PipelineParameter](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-showcasing-datapath-and-pipelineparameter.ipynb) include complete examples of this technique.
298300

299301
## Create a versioned pipeline endpoint
300302

301-
You can create a Pipeline Endpoint with multiple published pipelines behind it. This technique gives you a fixed REST endpoint as you iterate on and update your ML pipelines.
303+
You can create a pipeline endpoint that has multiple published pipelines behind it. This technique gives you a fixed REST endpoint as you iterate on and update your machine learning pipelines.
302304

303305
```python
304306
from azureml.pipeline.core import PipelineEndpoint
@@ -325,7 +327,7 @@ run_id = pipeline_endpoint_by_name.submit("PipelineEndpointExperiment", pipeline
325327
print(run_id)
326328
```
327329

328-
The same can be accomplished using the REST API:
330+
You can accomplish the same thing by using the REST API:
329331

330332
```python
331333
rest_endpoint = pipeline_endpoint_by_name.endpoint
@@ -344,27 +346,28 @@ You can also run a published pipeline from the studio:
344346

345347
1. [View your workspace](../how-to-manage-workspace.md#find-a-workspace).
346348

347-
1. On the left, select **Endpoints**.
349+
1. In the left menu, select **Endpoints**.
350+
351+
1. Select **Pipeline endpoints**:
348352

349-
1. On the top, select **Pipeline endpoints**.
350-
![list of machine learning published pipelines](../media/how-to-create-your-first-pipeline/pipeline-endpoints.png)
353+
:::image type="content" source="../media/how-to-create-your-first-pipeline/pipeline-endpoints.png" alt-text="Screenshot that shows the list of published endpoints." lightbox ="../media/how-to-create-your-first-pipeline/pipeline-endpoints.png":::
351354

352355
1. Select a specific pipeline to run, consume, or review results of previous runs of the pipeline endpoint.
353356

354357
## Disable a published pipeline
355358

356-
To hide a pipeline from your list of published pipelines, you disable it, either in the studio or from the SDK:
359+
To hide a pipeline from your list of published pipelines, you disable it, either in the studio or via the SDK:
357360

358361
```python
359362
# Get the pipeline by using its ID from Azure Machine Learning studio
360363
p = PublishedPipeline.get(ws, id="068f4885-7088-424b-8ce2-eeb9ba5381a6")
361364
p.disable()
362365
```
363366

364-
You can enable it again with `p.enable()`. For more information, see [PublishedPipeline class](/python/api/azureml-pipeline-core/azureml.pipeline.core.publishedpipeline) reference.
367+
You can enable it again by using `p.enable()`. For more information, see the [PublishedPipeline class](/python/api/azureml-pipeline-core/azureml.pipeline.core.publishedpipeline) reference.
365368

366369
## Next steps
367370

368-
- Use [these Jupyter notebooks on GitHub](https://aka.ms/aml-pipeline-readme) to explore machine learning pipelines further.
369-
- See the SDK reference help for the [azureml-pipelines-core](/python/api/azureml-pipeline-core/azureml.pipeline.core) package and the [azureml-pipelines-steps](/python/api/azureml-pipeline-steps/azureml.pipeline.steps) package.
370-
- See the [how-to](how-to-debug-pipelines.md) for tips on debugging and troubleshooting pipelines.
371+
- Use [these Jupyter notebooks on GitHub](https://aka.ms/aml-pipeline-readme) to further explore machine learning pipelines.
372+
- See the SDK reference for the [azureml-pipelines-core](/python/api/azureml-pipeline-core/azureml.pipeline.core) package and the [azureml-pipelines-steps](/python/api/azureml-pipeline-steps/azureml.pipeline.steps) package.
373+
- For tips on debugging and troubleshooting pipelines, see [How to debug pipelines](how-to-debug-pipelines.md) .
-89.2 KB
Loading

0 commit comments

Comments
 (0)