This commit is contained in:
Sabrina Smai 2020-11-05 16:11:24 -08:00 коммит произвёл GitHub
Родитель a71dd3346b
Коммит c9828ab409
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 25 добавлений и 7 удалений

Просмотреть файл

@ -11,6 +11,7 @@ resources:
variables:
- group: kubeflow-azdo-sample
- group: kubeflow-iac
pool:
vmImage: ubuntu-latest
@ -28,7 +29,9 @@ stages:
displayName: 'Use Python 3.7'
- script: |
pip install requests --upgrade
pip3 install adal --upgrade
displayName: Install Python Dependencies
# - download: ci
# condition: and(succeeded(), eq(variables['Build.Reason'], 'ResourceTrigger'))
# artifact: kubeflow_run
@ -47,20 +50,32 @@ stages:
fi
name: "get_run_id"
displayName: "Get run id"
- script: |
export MLFLOW_TOKEN=$(python code/utils/azure_auth.py \
--tenant $(AZ_TENANT_ID) \
--service_principal $(AZ_CLIENT_ID) \
--sp_secret $(AZ_CLIENT_SECRET) 2>&1 >/dev/null)
#echo "::set-env name=MLFLOW_TOKEN::$MLFLOW_TOKEN"
echo "##vso[task.setvariable variable=MLFLOW_TOKEN]$MLFLOW_TOKEN"
displayName: "Get Token"
- task: Bash@3
inputs:
targetType: 'inline'
script: |
set -euxo pipefail
cd "$(Build.SourcesDirectory)/code/seldon"
mlflow_run_id=`curl -d '{"experiment_ids":['$(MLFLOW_EXPERIMENT)'],"filter":"tags.external_run_id='\'''$(RUN_ID)''\''"}' $(KF_ENDPOINT_ASYNC)/mlflow/api/2.0/preview/mlflow/runs/search | jq -r '.runs[0].info.run_id'`
curl -L '$(KF_ENDPOINT_ASYNC)/mlflow/get-artifact?path=model/data/model.h5&run_uuid='$mlflow_run_id > model.h5
curl -H "Authorization: Bearer $(MLFLOW_TOKEN) " -d '{"experiment_ids":['$(MLFLOW_EXPERIMENT)'],"filter":"tags.external_run_id='\'''$(RUN_ID)''\''"}' $(KF_ENDPOINT)mlflow/api/2.0/preview/mlflow/runs/search | jq -r '.runs[0].info.run_id'
mlflow_run_id=$(curl -H "Authorization: Bearer $(MLFLOW_TOKEN) " -d '{"experiment_ids":['$(MLFLOW_EXPERIMENT)'],"filter":"tags.external_run_id='\'''$(RUN_ID)''\''"}' $(KF_ENDPOINT)mlflow/api/2.0/preview/mlflow/runs/search | jq -r '.runs[0].info.run_id')
echo $mlflow_run_id
curl -L '$(KF_ENDPOINT)mlflow/get-artifact?path=model/data/model.h5&run_uuid='$mlflow_run_id > model.h5
set +x
echo "##vso[task.setvariable variable=MLFLOW_RUN_ID]$mlflow_run_id"
mkdir -p $(Pipeline.Workspace)/variables
echo "$mlflow_run_id" > $(Pipeline.Workspace)/variables/MLFLOW_RUN_ID
echo "$MLFLOW_TOKEN" > $(Pipeline.Workspace)/variables/MLFLOW_TOKEN
echo "##vso[task.setvariable variable=MLFLOW_RUN_ID]$mlflow_run_id"
displayName: Download model
- template: build-container-template.yml
parameters:
@ -69,10 +84,11 @@ stages:
containerReferences: '$(Build.SourcesDirectory)/code/seldon'
acr: $(ACR_NAME)
repository: 'mexicanfood/mlflowproject2'
taskname: 'mlflowproject2_container'
- script: |
set -euxo pipefail
body=`curl $(KF_ENDPOINT_ASYNC)/mlflow/ajax-api/2.0/preview/mlflow/model-versions/search?filter=run_id%3D%27$(MLFLOW_RUN_ID)%27 | jq '.model_versions[0] | {name: .name, version: .version, stage: $stage}' --arg stage Staging --compact-output`
curl -d $body $(KF_ENDPOINT_ASYNC)/mlflow/ajax-api/2.0/preview/mlflow/model-versions/transition-stage
body=`curl -H "Authorization: Bearer $(MLFLOW_TOKEN) " $(KF_ENDPOINT)mlflow/ajax-api/2.0/preview/mlflow/model-versions/search?filter=run_id%3D%27$MLFLOW_RUN_ID%27 | jq '.model_versions[0] | {name: .name, version: .version, stage: $stage}' --arg stage Staging --compact-output`
curl -H "Authorization: Bearer $(MLFLOW_TOKEN) " -d $body $(KF_ENDPOINT)mlflow/ajax-api/2.0/preview/mlflow/model-versions/transition-stage
displayName: "Promote model to Staging"
- task: HelmDeploy@0
displayName: Deploy to SeldonCore
@ -85,6 +101,7 @@ stages:
chartType: 'FilePath'
chartPath: '$(Build.SourcesDirectory)/code/seldon/chart'
releaseName: 'mexicanfood'
# taskname: 'build_push_mexicanfood_mlflowproject2'
arguments: '--set=image.tag=$(build_push_mexicanfood_mlflowproject2.IMAGE_TAG)'
- publish: $(Pipeline.Workspace)/variables
artifact: variables
@ -102,8 +119,9 @@ stages:
- script: |
set -euxo pipefail
MLFLOW_RUN_ID=`cat $(Pipeline.Workspace)/variables/MLFLOW_RUN_ID`
body=`curl $(KF_ENDPOINT_ASYNC)/mlflow/ajax-api/2.0/preview/mlflow/model-versions/search?filter=run_id%3D%27$MLFLOW_RUN_ID%27 | jq '.model_versions[0] | {name: .name, version: .version, stage: $stage}' --arg stage Production --compact-output`
curl -d $body $(KF_ENDPOINT_ASYNC)/mlflow/ajax-api/2.0/preview/mlflow/model-versions/transition-stage
MLFLOW_TOKEN=`cat $(Pipeline.Workspace)/variables/MLFLOW_TOKEN`
body=`curl -H "Authorization: Bearer $MLFLOW_TOKEN " $(KF_ENDPOINT)mlflow/ajax-api/2.0/preview/mlflow/model-versions/search?filter=run_id%3D%27$MLFLOW_RUN_ID%27 | jq '.model_versions[0] | {name: .name, version: .version, stage: $stage}' --arg stage Production --compact-output`
curl -H "Authorization: Bearer $MLFLOW_TOKEN " -d $body $(KF_ENDPOINT)mlflow/ajax-api/2.0/preview/mlflow/model-versions/transition-stage
displayName: "Promote model to Production"
- task: AzureCLI@1
displayName: Run deploy script