File tree Expand file tree Collapse file tree 3 files changed +17
-6
lines changed Expand file tree Collapse file tree 3 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ Add a command line step **Run Training Pipeline** with the following script:
127127``` bash
128128docker run -v $( System.DefaultWorkingDirectory) /_ci-build/mlops-pipelines/ml_service/pipelines:/pipelines \
129129-w=/pipelines -e MODEL_NAME=$MODEL_NAME -e EXPERIMENT_NAME=$EXPERIMENT_NAME \
130- -e TENANT_ID=$TENANT_ID -e SP_APP_ID=$SP_APP_ID -e SP_APP_SECRET=$SP_APP_SECRET \
130+ -e TENANT_ID=$TENANT_ID -e SP_APP_ID=$SP_APP_ID -e SP_APP_SECRET=$( SP_APP_SECRET) \
131131mcr.microsoft.com/mlops/python:latest python run_train_pipeline.py
132132```
133133
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ trigger:
1515
1616variables :
1717 containerRegistry : $[coalesce(variables['acrServiceConnection'], 'acrconnection')]
18- imageName : $[coalesce(variables['agentImageName'], 'public/mlops/mlopspython ')]
18+ imageName : $[coalesce(variables['agentImageName'], 'public/mlops/python ')]
1919
2020steps :
2121 - task : Docker@2
Original file line number Diff line number Diff line change 22import os
33import json
44import requests
5- from azureml . core . authentication import AzureCliAuthentication
5+ from azure . common . credentials import ServicePrincipalCredentials
66
77
8+ tenant_id = os .environ .get ("TENANT_ID" )
9+ app_id = os .environ .get ("SP_APP_ID" )
10+ app_secret = os .environ .get ("SP_APP_SECRET" )
11+
812try :
913 with open ("train_pipeline.json" ) as f :
1014 train_pipeline_json = json .load (f )
1519experiment_name = os .environ .get ("EXPERIMENT_NAME" )
1620model_name = os .environ .get ("MODEL_NAME" )
1721
18- cli_auth = AzureCliAuthentication ()
19- token = cli_auth .get_authentication_header ()
22+ credentials = ServicePrincipalCredentials (
23+ client_id = app_id ,
24+ secret = app_secret ,
25+ tenant = tenant_id
26+ )
27+
28+ token = credentials .token ['access_token' ]
29+ print ("token" , token )
30+ auth_header = {"Authorization" : "Bearer " + token }
2031
2132rest_endpoint = train_pipeline_json ["rest_endpoint" ]
2233
2334response = requests .post (
24- rest_endpoint , headers = token ,
35+ rest_endpoint , headers = auth_header ,
2536 json = {"ExperimentName" : experiment_name ,
2637 "ParameterAssignments" : {"model_name" : model_name }}
2738)
You can’t perform that action at this time.
0 commit comments