File tree Expand file tree Collapse file tree 3 files changed +17
-9
lines changed
Expand file tree Collapse file tree 3 files changed +17
-9
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 @@ -10,8 +10,4 @@ COPY environment_setup/requirements.txt /setup/
1010
1111RUN apt-get update && apt-get install gcc -y && pip install --upgrade -r /setup/requirements.txt
1212
13- COPY environment_setup/python.sh /usr/local/sbin/python.sh
14- RUN rm /usr/local/bin/python && ln -s /usr/local/sbin/python.sh /usr/local/bin/python
15-
16-
1713CMD ["python" ]
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)
2839
2940run_id = response .json ()["Id" ]
3041print ("Pipeline run initiated " , run_id )
42+
You can’t perform that action at this time.
0 commit comments