From 640c0a60d5d861817053385461ad03ba6931ed2a Mon Sep 17 00:00:00 2001 From: Jose Medina Gomez Date: Thu, 10 Nov 2022 15:10:14 -0500 Subject: [PATCH 01/21] initial ADO pipeline forlder creation for SDK --- .../deploy-model-training-pipeline.yml | 73 +++++++++++++++++++ .../deploy-online-endpoint-pipeline.yml | 61 ++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml create mode 100644 nlp/python-sdk-v2/mlops/devops-pipelines/deploy-online-endpoint-pipeline.yml diff --git a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml new file mode 100644 index 0000000..3b09fe5 --- /dev/null +++ b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml @@ -0,0 +1,73 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +variables: +- ${{ if eq(variables['Build.SourceBranchName'], 'main') }}: + # 'main' branch: PRD environment + - template: ../../config-infra-prod.yml +- ${{ if ne(variables['Build.SourceBranchName'], 'main') }}: + # 'develop' or feature branches: DEV environment + - template: ../../config-infra-dev.yml +- name: version + value: aml-cli-v2 + + +trigger: +- none + +pool: + vmImage: ubuntu-20.04 + + +resources: + repositories: + - repository: mlops-templates # Template Repo + name: Azure/mlops-templates # need to change org name from "Azure" to your own org + endpoint: github-connection # need to set up and hardcode + type: github + ref: main + +stages: +- stage: DeployTrainingPipeline + displayName: Deploy Training Pipeline + jobs: + - job: DeployTrainingPipeline + steps: + - checkout: self + path: s/ + - checkout: mlops-templates + path: s/templates/ + - template: templates/${{ variables.version }}/install-az-cli.yml@mlops-templates + - template: templates/${{ variables.version }}/install-aml-cli.yml@mlops-templates + - template: templates/${{ variables.version }}/connect-to-workspace.yml@mlops-templates + - template: templates/${{ variables.version }}/create-compute.yml@mlops-templates + parameters: + cluster_name: cpu-cluster + size: STANDARD_DS3_V2 + min_instances: 0 + max_instances: 1 + cluster_tier: dedicated + - template: templates/${{ variables.version }}/create-compute.yml@mlops-templates + parameters: + cluster_name: cpu-cluster-lg + size: Standard_D14_v2 + min_instances: 0 + max_instances: 1 + cluster_tier: dedicated + - template: templates/${{ variables.version }}/create-compute.yml@mlops-templates + parameters: + cluster_name: gpu-cluster + size: Standard_NV6 + min_instances: 0 + max_instances: 1 + cluster_tier: dedicated + - template: templates/${{ variables.version }}/register-environment.yml@mlops-templates + parameters: + build_type: conda + environment_name: nlp_summarization_train + environment_file: mlops/azureml/train/train-env.yml + - template: templates/${{ variables.version }}/run-pipeline.yml@mlops-templates + parameters: + pipeline_file: mlops/azureml/train/pipeline.yml + experiment_name: $(environment)_nlp_summarization_$(Build.SourceBranchName) + display_name: $(environment)_nlp_summarization_$(Build.BuildID) diff --git a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-online-endpoint-pipeline.yml b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-online-endpoint-pipeline.yml new file mode 100644 index 0000000..2cc4a5b --- /dev/null +++ b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-online-endpoint-pipeline.yml @@ -0,0 +1,61 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +variables: +- ${{ if eq(variables['Build.SourceBranchName'], 'main') }}: + # 'main' branch: PRD environment + - template: ../../config-infra-prod.yml +- ${{ if ne(variables['Build.SourceBranchName'], 'main') }}: + # 'develop' or feature branches: DEV environment + - template: ../../config-infra-dev.yml +- name: version + value: aml-cli-v2 +- name: endpoint_name + value: nlp-online-$(namespace)$(postfix)$(environment) +- name: endpoint_type + value: online + + +trigger: +- none + +pool: + vmImage: ubuntu-20.04 + + +resources: + repositories: + - repository: mlops-templates # Template Repo + name: Azure/mlops-templates # need to change org name from "Azure" to your own org + endpoint: github-connection # need to set up and hardcode + type: github + ref: main + +stages: +- stage: CreateOnlineEndpoint + displayName: Create/Update Online Endpoint + jobs: + - job: DeployOnlineEndpoint + steps: + - checkout: self + path: s/ + - checkout: mlops-templates + path: s/templates/ + - template: templates/${{ variables.version }}/install-az-cli.yml@mlops-templates + - template: templates/${{ variables.version }}/install-aml-cli.yml@mlops-templates + - template: templates/${{ variables.version }}/connect-to-workspace.yml@mlops-templates + - template: templates/${{ variables.version }}/create-endpoint.yml@mlops-templates + parameters: + endpoint_file: mlops/azureml/deploy/online/online-endpoint.yml + - template: templates/${{ variables.version }}/create-deployment.yml@mlops-templates + parameters: + deployment_name: nlp-summarization-online-dp + deployment_file: mlops/azureml/deploy/online/online-deployment.yml + - template: templates/${{ variables.version }}/allocate-traffic.yml@mlops-templates + parameters: + traffic_allocation: nlp-summarization-online-dp=100 + - template: templates/${{ variables.version }}/test-deployment.yml@mlops-templates + parameters: + deployment_name: nlp-summarization-online-dp + sample_request: data/nlp-summarization-request.json + request_type: json From c3f819a95f23ec9275e016f07f330e8f6d366cd3 Mon Sep 17 00:00:00 2001 From: jomedinagomez Date: Thu, 10 Nov 2022 15:17:29 -0500 Subject: [PATCH 02/21] modified_filename for pipeline modified_filename --- .../mlops/devops-pipelines/deploy-model-training-pipeline.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml index 3b09fe5..a38e99b 100644 --- a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml +++ b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml @@ -68,6 +68,6 @@ stages: environment_file: mlops/azureml/train/train-env.yml - template: templates/${{ variables.version }}/run-pipeline.yml@mlops-templates parameters: - pipeline_file: mlops/azureml/train/pipeline.yml + pipeline_file: mlops/azureml/train/pipeline-train.py experiment_name: $(environment)_nlp_summarization_$(Build.SourceBranchName) - display_name: $(environment)_nlp_summarization_$(Build.BuildID) + display_name: $(environment)_nlp_summarization_$(Build.BuildID) \ No newline at end of file From 55553e341cf905ac15ba4ae819ff4823835a3303 Mon Sep 17 00:00:00 2001 From: jomedinagomez Date: Thu, 10 Nov 2022 15:20:26 -0500 Subject: [PATCH 03/21] modifying value for version --- .../mlops/devops-pipelines/deploy-model-training-pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml index a38e99b..8f386bd 100644 --- a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml +++ b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml @@ -9,7 +9,7 @@ variables: # 'develop' or feature branches: DEV environment - template: ../../config-infra-dev.yml - name: version - value: aml-cli-v2 + value: python-sdk trigger: From 6e72bf3a6d5b23deac6e4d61fc0a677a41555e3b Mon Sep 17 00:00:00 2001 From: jomedinagomez Date: Thu, 10 Nov 2022 15:25:46 -0500 Subject: [PATCH 04/21] adding additional references --- .../devops-pipelines/deploy-model-training-pipeline.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml index 8f386bd..3a3cc63 100644 --- a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml +++ b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml @@ -9,7 +9,7 @@ variables: # 'develop' or feature branches: DEV environment - template: ../../config-infra-dev.yml - name: version - value: python-sdk + value: python-sdk-v2 trigger: @@ -22,10 +22,10 @@ pool: resources: repositories: - repository: mlops-templates # Template Repo - name: Azure/mlops-templates # need to change org name from "Azure" to your own org + name: jomedinagomez/mlops-templates # need to change org name from "Azure" to your own org endpoint: github-connection # need to set up and hardcode type: github - ref: main + ref: main-dec31 stages: - stage: DeployTrainingPipeline From 8265c2da1f77856dab3621933b5ad971a4f3bf13 Mon Sep 17 00:00:00 2001 From: jomedinagomez Date: Thu, 10 Nov 2022 16:46:40 -0500 Subject: [PATCH 05/21] Create train-env.yml --- nlp/python-sdk-v2/mlops/azureml/train-env.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 nlp/python-sdk-v2/mlops/azureml/train-env.yml diff --git a/nlp/python-sdk-v2/mlops/azureml/train-env.yml b/nlp/python-sdk-v2/mlops/azureml/train-env.yml new file mode 100644 index 0000000..fce1dd6 --- /dev/null +++ b/nlp/python-sdk-v2/mlops/azureml/train-env.yml @@ -0,0 +1,6 @@ + +$schema: https://azuremlschemas.azureedge.net/latest/environment.schema.json +name: nlp_summarization_train +version: mlopsv2-july2022 +build: + path: ../../../data-science/environments/training/ From fbd6227848373b86e94bb96358e108757d63c254 Mon Sep 17 00:00:00 2001 From: jomedinagomez Date: Thu, 10 Nov 2022 16:56:11 -0500 Subject: [PATCH 06/21] Update deploy-model-training-pipeline.yml --- .../mlops/devops-pipelines/deploy-model-training-pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml index 3a3cc63..e9f665b 100644 --- a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml +++ b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml @@ -25,7 +25,7 @@ resources: name: jomedinagomez/mlops-templates # need to change org name from "Azure" to your own org endpoint: github-connection # need to set up and hardcode type: github - ref: main-dec31 + ref: nlp-dec31 stages: - stage: DeployTrainingPipeline From cc2eba43e400e276498e3fe303b2b9c2f1f0030c Mon Sep 17 00:00:00 2001 From: jomedinagomez Date: Thu, 10 Nov 2022 21:10:04 -0500 Subject: [PATCH 07/21] Update pipeline-train.py --- .../mlops/azureml/pipeline-train.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/nlp/python-sdk-v2/mlops/azureml/pipeline-train.py b/nlp/python-sdk-v2/mlops/azureml/pipeline-train.py index 293f3b3..c328a81 100644 --- a/nlp/python-sdk-v2/mlops/azureml/pipeline-train.py +++ b/nlp/python-sdk-v2/mlops/azureml/pipeline-train.py @@ -19,19 +19,19 @@ def get_config_parger(parser: argparse.ArgumentParser = None): group.add_argument( "--subscription_id", type=str, - required=True, + required=False, help="Subscription ID", ) group.add_argument( "--resource_group", type=str, - required=True, + required=False, help="Resource group name", ) group.add_argument( "--workspace_name", type=str, - required=True, + required=False, help="Workspace name", ) group.add_argument( @@ -129,14 +129,6 @@ def connect_to_aml(args): print( "Could not find config.json, using config.yaml refs to Azure ML workspace instead." ) - - # tries to connect using cli args if provided else using config.yaml - ml_client = MLClient( - subscription_id=args.subscription_id, - resource_group_name=args.resource_group, - workspace_name=args.workspace_name, - credential=credential, - ) return ml_client @@ -396,4 +388,4 @@ def main(): if __name__ == "__main__": - main() + main() \ No newline at end of file From c73e8f471f96a4d000f0efee8eaaa77a27ac0ab3 Mon Sep 17 00:00:00 2001 From: jomedinagomez Date: Thu, 10 Nov 2022 21:11:43 -0500 Subject: [PATCH 08/21] Update deploy-model-training-pipeline.yml --- .../mlops/devops-pipelines/deploy-model-training-pipeline.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml index e9f665b..bfb21f8 100644 --- a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml +++ b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml @@ -69,5 +69,4 @@ stages: - template: templates/${{ variables.version }}/run-pipeline.yml@mlops-templates parameters: pipeline_file: mlops/azureml/train/pipeline-train.py - experiment_name: $(environment)_nlp_summarization_$(Build.SourceBranchName) - display_name: $(environment)_nlp_summarization_$(Build.BuildID) \ No newline at end of file + experiment_name: $(environment)_nlp_summarization_$(Build.SourceBranchName) \ No newline at end of file From 7e228ba9c25773072beed2c25274210db6dedbd4 Mon Sep 17 00:00:00 2001 From: jomedinagomez Date: Thu, 10 Nov 2022 21:59:17 -0500 Subject: [PATCH 09/21] adding train subfolder to azureml --- nlp/python-sdk-v2/mlops/azureml/{ => train}/pipeline-train.py | 0 nlp/python-sdk-v2/mlops/azureml/{ => train}/register-env.py | 0 nlp/python-sdk-v2/mlops/azureml/{ => train}/train-env.yml | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename nlp/python-sdk-v2/mlops/azureml/{ => train}/pipeline-train.py (100%) rename nlp/python-sdk-v2/mlops/azureml/{ => train}/register-env.py (100%) rename nlp/python-sdk-v2/mlops/azureml/{ => train}/train-env.yml (100%) diff --git a/nlp/python-sdk-v2/mlops/azureml/pipeline-train.py b/nlp/python-sdk-v2/mlops/azureml/train/pipeline-train.py similarity index 100% rename from nlp/python-sdk-v2/mlops/azureml/pipeline-train.py rename to nlp/python-sdk-v2/mlops/azureml/train/pipeline-train.py diff --git a/nlp/python-sdk-v2/mlops/azureml/register-env.py b/nlp/python-sdk-v2/mlops/azureml/train/register-env.py similarity index 100% rename from nlp/python-sdk-v2/mlops/azureml/register-env.py rename to nlp/python-sdk-v2/mlops/azureml/train/register-env.py diff --git a/nlp/python-sdk-v2/mlops/azureml/train-env.yml b/nlp/python-sdk-v2/mlops/azureml/train/train-env.yml similarity index 100% rename from nlp/python-sdk-v2/mlops/azureml/train-env.yml rename to nlp/python-sdk-v2/mlops/azureml/train/train-env.yml From 58d4cdeb5bcc732f2720ab1170e58319337a6269 Mon Sep 17 00:00:00 2001 From: jomedinagomez Date: Thu, 10 Nov 2022 22:09:56 -0500 Subject: [PATCH 10/21] Update requirements.txt --- .../data-science/environments/training/requirements.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nlp/python-sdk-v2/data-science/environments/training/requirements.txt b/nlp/python-sdk-v2/data-science/environments/training/requirements.txt index 7446a74..0a825e1 100644 --- a/nlp/python-sdk-v2/data-science/environments/training/requirements.txt +++ b/nlp/python-sdk-v2/data-science/environments/training/requirements.txt @@ -16,3 +16,6 @@ psutil==5.9.0 # for unit testing pytest==7.1.2 + +# for azure ml SDK v2 +azure-ai-ml==1.1.0 \ No newline at end of file From 54a7c9849ee1525cd826a3345bc3ea653585cbba Mon Sep 17 00:00:00 2001 From: jomedinagomez Date: Fri, 11 Nov 2022 01:16:19 -0500 Subject: [PATCH 11/21] using original pipeline-train.py --- .../mlops/azureml/train/pipeline-train.py | 14 +++++++++++--- .../deploy-model-training-pipeline.yml | 5 ++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/nlp/python-sdk-v2/mlops/azureml/train/pipeline-train.py b/nlp/python-sdk-v2/mlops/azureml/train/pipeline-train.py index c328a81..02dd68a 100644 --- a/nlp/python-sdk-v2/mlops/azureml/train/pipeline-train.py +++ b/nlp/python-sdk-v2/mlops/azureml/train/pipeline-train.py @@ -19,19 +19,19 @@ def get_config_parger(parser: argparse.ArgumentParser = None): group.add_argument( "--subscription_id", type=str, - required=False, + required=True, help="Subscription ID", ) group.add_argument( "--resource_group", type=str, - required=False, + required=True, help="Resource group name", ) group.add_argument( "--workspace_name", type=str, - required=False, + required=True, help="Workspace name", ) group.add_argument( @@ -129,6 +129,14 @@ def connect_to_aml(args): print( "Could not find config.json, using config.yaml refs to Azure ML workspace instead." ) + + # tries to connect using cli args if provided else using config.yaml + ml_client = MLClient( + subscription_id=args.subscription_id, + resource_group_name=args.resource_group, + workspace_name=args.workspace_name, + credential=credential, + ) return ml_client diff --git a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml index bfb21f8..075ebee 100644 --- a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml +++ b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml @@ -69,4 +69,7 @@ stages: - template: templates/${{ variables.version }}/run-pipeline.yml@mlops-templates parameters: pipeline_file: mlops/azureml/train/pipeline-train.py - experiment_name: $(environment)_nlp_summarization_$(Build.SourceBranchName) \ No newline at end of file + experiment_name: $(environment)_nlp_summarization_$(Build.SourceBranchName) + resource_group: $(resource_group) + workspace_name: $(aml_workspace) + subscription_id: $(ado_service_connection_aml_ws) \ No newline at end of file From 257421b71898c13135b36f1c26e6671a036af63f Mon Sep 17 00:00:00 2001 From: jomedinagomez Date: Fri, 11 Nov 2022 01:46:47 -0500 Subject: [PATCH 12/21] Update deploy-model-training-pipeline.yml --- .../devops-pipelines/deploy-model-training-pipeline.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml index 075ebee..bfb21f8 100644 --- a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml +++ b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml @@ -69,7 +69,4 @@ stages: - template: templates/${{ variables.version }}/run-pipeline.yml@mlops-templates parameters: pipeline_file: mlops/azureml/train/pipeline-train.py - experiment_name: $(environment)_nlp_summarization_$(Build.SourceBranchName) - resource_group: $(resource_group) - workspace_name: $(aml_workspace) - subscription_id: $(ado_service_connection_aml_ws) \ No newline at end of file + experiment_name: $(environment)_nlp_summarization_$(Build.SourceBranchName) \ No newline at end of file From 8b3774f1f82623209e5d2acb502bdc30aefe5bc5 Mon Sep 17 00:00:00 2001 From: jomedinagomez Date: Fri, 11 Nov 2022 09:49:55 -0500 Subject: [PATCH 13/21] adding new reference to src Adjusting code to find src directory because created a new folder for train under azureml --- nlp/python-sdk-v2/mlops/azureml/train/pipeline-train.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nlp/python-sdk-v2/mlops/azureml/train/pipeline-train.py b/nlp/python-sdk-v2/mlops/azureml/train/pipeline-train.py index 02dd68a..b980cd2 100644 --- a/nlp/python-sdk-v2/mlops/azureml/train/pipeline-train.py +++ b/nlp/python-sdk-v2/mlops/azureml/train/pipeline-train.py @@ -143,7 +143,7 @@ def connect_to_aml(args): def build_components(args): """Builds the components for the pipeline.""" DATA_SCIENCE_FOLDER = os.path.join( - os.path.dirname(os.path.abspath(__file__)), "..", "..", "data-science", "src" + os.path.dirname(os.path.abspath(__file__)), "..","..", "..", "data-science", "src" ) prep_finetuning_dataset = command( From 64ff3185d2bd15537a0eb41e8734ad6e08e483f2 Mon Sep 17 00:00:00 2001 From: jomedinagomez Date: Wed, 30 Nov 2022 08:46:28 -0500 Subject: [PATCH 14/21] Update pipeline-train.py --- .../mlops/azureml/train/pipeline-train.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/nlp/python-sdk-v2/mlops/azureml/train/pipeline-train.py b/nlp/python-sdk-v2/mlops/azureml/train/pipeline-train.py index b980cd2..28198ec 100644 --- a/nlp/python-sdk-v2/mlops/azureml/train/pipeline-train.py +++ b/nlp/python-sdk-v2/mlops/azureml/train/pipeline-train.py @@ -8,6 +8,7 @@ from azure.ai.ml import MLClient from azure.ai.ml import command from azure.ai.ml import Input, Output from azure.ai.ml import dsl, Input, Output +import json def get_config_parger(parser: argparse.ArgumentParser = None): @@ -16,22 +17,28 @@ def get_config_parger(parser: argparse.ArgumentParser = None): parser = argparse.ArgumentParser(description=__doc__) group = parser.add_argument_group("Azure ML references") + group.add_argument( + "--config_location", + type=str, + required=False, + help="Subscription ID", + ) group.add_argument( "--subscription_id", type=str, - required=True, + required=False, help="Subscription ID", ) group.add_argument( "--resource_group", type=str, - required=True, + required=False, help="Resource group name", ) group.add_argument( "--workspace_name", type=str, - required=True, + required=False, help="Workspace name", ) group.add_argument( @@ -123,7 +130,7 @@ def connect_to_aml(args): # Get a handle to workspace try: # ml_client to connect using local config.json - ml_client = MLClient.from_config(credential=credential) + ml_client = ml_client = MLClient.from_config(credential, path='config.json') except Exception as ex: print( From 07b7c918a85a6a942416893a648a46df6dcbacab Mon Sep 17 00:00:00 2001 From: jomedinagomez Date: Wed, 30 Nov 2022 09:25:31 -0500 Subject: [PATCH 15/21] Update deploy-model-training-pipeline.yml --- .../devops-pipelines/deploy-model-training-pipeline.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml index bfb21f8..900e3c6 100644 --- a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml +++ b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml @@ -37,9 +37,9 @@ stages: path: s/ - checkout: mlops-templates path: s/templates/ - - template: templates/${{ variables.version }}/install-az-cli.yml@mlops-templates - - template: templates/${{ variables.version }}/install-aml-cli.yml@mlops-templates - - template: templates/${{ variables.version }}/connect-to-workspace.yml@mlops-templates + - template: templates/aml-cli-v2/install-az-cli.yml@mlops-templates + - template: templates/aml-cli-v2/install-aml-cli.yml@mlops-templates + - template: templates/aml-cli-v2/connect-to-workspace.yml@mlops-templates - template: templates/${{ variables.version }}/create-compute.yml@mlops-templates parameters: cluster_name: cpu-cluster From 16dc0616776052d47b6299c7cc33869352974c63 Mon Sep 17 00:00:00 2001 From: jomedinagomez Date: Wed, 30 Nov 2022 09:39:41 -0500 Subject: [PATCH 16/21] Update pipeline-train.py --- nlp/python-sdk-v2/mlops/azureml/train/pipeline-train.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/nlp/python-sdk-v2/mlops/azureml/train/pipeline-train.py b/nlp/python-sdk-v2/mlops/azureml/train/pipeline-train.py index 28198ec..bc39bc3 100644 --- a/nlp/python-sdk-v2/mlops/azureml/train/pipeline-train.py +++ b/nlp/python-sdk-v2/mlops/azureml/train/pipeline-train.py @@ -8,8 +8,6 @@ from azure.ai.ml import MLClient from azure.ai.ml import command from azure.ai.ml import Input, Output from azure.ai.ml import dsl, Input, Output -import json - def get_config_parger(parser: argparse.ArgumentParser = None): """Builds the argument parser for the script.""" From b20d7dab3a8db6d59e9a2a9eeeb812794eeaa824 Mon Sep 17 00:00:00 2001 From: jomedinagomez Date: Wed, 30 Nov 2022 11:25:12 -0500 Subject: [PATCH 17/21] Update requirements.txt --- .../environments/training/requirements.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nlp/aml-cli-v2/data-science/environments/training/requirements.txt b/nlp/aml-cli-v2/data-science/environments/training/requirements.txt index 7446a74..d2760ad 100644 --- a/nlp/aml-cli-v2/data-science/environments/training/requirements.txt +++ b/nlp/aml-cli-v2/data-science/environments/training/requirements.txt @@ -16,3 +16,13 @@ psutil==5.9.0 # for unit testing pytest==7.1.2 + +# for azure ml SDK v2 +azure-ai-ml==1.1.0 +azure-common==1.1.28 +azure-core==1.26.1 +azure-identity==1.10.0 +azure-mgmt-core==1.3.0 +azure-storage-blob==12.14.1 +azure-storage-file-datalake==12.9.1 +azure-storage-file-share==12.7.0 \ No newline at end of file From 287c701754d8b87311e634d322e01ff29bfa67e2 Mon Sep 17 00:00:00 2001 From: jomedinagomez Date: Wed, 30 Nov 2022 13:53:59 -0500 Subject: [PATCH 18/21] Delete register-env.py --- .../mlops/azureml/train/register-env.py | 123 ------------------ 1 file changed, 123 deletions(-) delete mode 100644 nlp/python-sdk-v2/mlops/azureml/train/register-env.py diff --git a/nlp/python-sdk-v2/mlops/azureml/train/register-env.py b/nlp/python-sdk-v2/mlops/azureml/train/register-env.py deleted file mode 100644 index d469752..0000000 --- a/nlp/python-sdk-v2/mlops/azureml/train/register-env.py +++ /dev/null @@ -1,123 +0,0 @@ -"""MLOps v2 NLP Python SDK register environment script.""" -import os -import argparse -import traceback - -# Azure ML sdk v2 imports -from azure.identity import DefaultAzureCredential, InteractiveBrowserCredential -from azure.ai.ml import MLClient -from azure.ai.ml.entities import Environment, BuildContext -from azure.core.exceptions import ResourceExistsError - - -def get_config_parger(parser: argparse.ArgumentParser = None): - """Builds the argument parser for the script.""" - if parser is None: - parser = argparse.ArgumentParser(description=__doc__) - - parser.add_argument( - "--subscription_id", - type=str, - required=True, - help="Subscription ID", - ) - parser.add_argument( - "--resource_group", - type=str, - required=True, - help="Resource group name", - ) - parser.add_argument( - "--workspace_name", - type=str, - required=True, - help="Workspace name", - ) - parser.add_argument( - "--exists_ok", - default=False, - action="store_true", - help="if True, will not fail if environment already exists", - ) - - parser.add_argument( - "--environment_name", - default="nlp_summarization_train", - type=str, - ) - parser.add_argument( - "--environment_version", - default="mlopsv2-july2022", - type=str, - ) - parser.add_argument( - "--environment_context_path", - default=os.path.join( - os.path.dirname(__file__), - "..", - "..", - "data-science", - "environments", - "training", - ), - type=str, - ) - return parser - - -def connect_to_aml(args): - """Connect to Azure ML workspace using provided cli arguments.""" - try: - credential = DefaultAzureCredential() - # Check if given credential can get token successfully. - credential.get_token("https://management.azure.com/.default") - except Exception as ex: - # Fall back to InteractiveBrowserCredential in case DefaultAzureCredential not work - credential = InteractiveBrowserCredential() - - # Get a handle to workspace - try: - # ml_client to connect using local config.json - ml_client = MLClient.from_config(credential=credential) - - except Exception as ex: - print( - "Could not find config.json, using config.yaml refs to Azure ML workspace instead." - ) - - # tries to connect using cli args if provided else using config.yaml - ml_client = MLClient( - subscription_id=args.subscription_id, - resource_group_name=args.resource_group, - workspace_name=args.workspace_name, - credential=credential, - ) - return ml_client - - -def main(): - """Main entry point for the script.""" - parser = get_config_parger() - args, _ = parser.parse_known_args() - ml_client = connect_to_aml(args) - - custom_env = Environment( - name=args.environment_name, - build=BuildContext(path=args.environment_context_path), - tags={"project": "mlopsv2", "url": "https://github.com/Azure/mlops-v2"}, - version=args.environment_version, - ) - - try: - custom_env_create_job = ml_client.environments.create_or_update(custom_env) - print( - f"Environment with name {custom_env_create_job.name} is registered to workspace, the environment version is {custom_env_create_job.version}" - ) - except ResourceExistsError as ex: - print(f"Failed to create environment: {traceback.format_exc()}") - if not args.exists_ok: - raise - - -if __name__ == "__main__": - main() From 4d25f840e33d801038e0fdc621053f630381517a Mon Sep 17 00:00:00 2001 From: jomedinagomez Date: Thu, 1 Dec 2022 09:49:56 -0500 Subject: [PATCH 19/21] Update deploy-model-training-pipeline.yml --- .../mlops/devops-pipelines/deploy-model-training-pipeline.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml index 900e3c6..1a871e9 100644 --- a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml +++ b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml @@ -22,10 +22,10 @@ pool: resources: repositories: - repository: mlops-templates # Template Repo - name: jomedinagomez/mlops-templates # need to change org name from "Azure" to your own org + name: Azure/mlops-templates # need to change org name from "Azure" to your own org endpoint: github-connection # need to set up and hardcode type: github - ref: nlp-dec31 + ref: main-dec31 #use in reference stages: - stage: DeployTrainingPipeline From 0e57a42e8758c7268adb2bd6974c3d0c953e1073 Mon Sep 17 00:00:00 2001 From: jomedinagomez Date: Thu, 1 Dec 2022 10:50:15 -0500 Subject: [PATCH 20/21] Update deploy-model-training-pipeline.yml --- .../devops-pipelines/deploy-model-training-pipeline.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml index 1a871e9..ddbf41f 100644 --- a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml +++ b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-model-training-pipeline.yml @@ -25,7 +25,7 @@ resources: name: Azure/mlops-templates # need to change org name from "Azure" to your own org endpoint: github-connection # need to set up and hardcode type: github - ref: main-dec31 #use in reference + ref: main-dec31 stages: - stage: DeployTrainingPipeline @@ -63,9 +63,8 @@ stages: cluster_tier: dedicated - template: templates/${{ variables.version }}/register-environment.yml@mlops-templates parameters: - build_type: conda + build_type: docker environment_name: nlp_summarization_train - environment_file: mlops/azureml/train/train-env.yml - template: templates/${{ variables.version }}/run-pipeline.yml@mlops-templates parameters: pipeline_file: mlops/azureml/train/pipeline-train.py From 70694f9dfedd96e23829c64e3a2d7ec43d84213f Mon Sep 17 00:00:00 2001 From: jomedinagomez Date: Thu, 1 Dec 2022 10:51:34 -0500 Subject: [PATCH 21/21] Delete deploy-online-endpoint-pipeline.yml --- .../deploy-online-endpoint-pipeline.yml | 61 ------------------- 1 file changed, 61 deletions(-) delete mode 100644 nlp/python-sdk-v2/mlops/devops-pipelines/deploy-online-endpoint-pipeline.yml diff --git a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-online-endpoint-pipeline.yml b/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-online-endpoint-pipeline.yml deleted file mode 100644 index 2cc4a5b..0000000 --- a/nlp/python-sdk-v2/mlops/devops-pipelines/deploy-online-endpoint-pipeline.yml +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -variables: -- ${{ if eq(variables['Build.SourceBranchName'], 'main') }}: - # 'main' branch: PRD environment - - template: ../../config-infra-prod.yml -- ${{ if ne(variables['Build.SourceBranchName'], 'main') }}: - # 'develop' or feature branches: DEV environment - - template: ../../config-infra-dev.yml -- name: version - value: aml-cli-v2 -- name: endpoint_name - value: nlp-online-$(namespace)$(postfix)$(environment) -- name: endpoint_type - value: online - - -trigger: -- none - -pool: - vmImage: ubuntu-20.04 - - -resources: - repositories: - - repository: mlops-templates # Template Repo - name: Azure/mlops-templates # need to change org name from "Azure" to your own org - endpoint: github-connection # need to set up and hardcode - type: github - ref: main - -stages: -- stage: CreateOnlineEndpoint - displayName: Create/Update Online Endpoint - jobs: - - job: DeployOnlineEndpoint - steps: - - checkout: self - path: s/ - - checkout: mlops-templates - path: s/templates/ - - template: templates/${{ variables.version }}/install-az-cli.yml@mlops-templates - - template: templates/${{ variables.version }}/install-aml-cli.yml@mlops-templates - - template: templates/${{ variables.version }}/connect-to-workspace.yml@mlops-templates - - template: templates/${{ variables.version }}/create-endpoint.yml@mlops-templates - parameters: - endpoint_file: mlops/azureml/deploy/online/online-endpoint.yml - - template: templates/${{ variables.version }}/create-deployment.yml@mlops-templates - parameters: - deployment_name: nlp-summarization-online-dp - deployment_file: mlops/azureml/deploy/online/online-deployment.yml - - template: templates/${{ variables.version }}/allocate-traffic.yml@mlops-templates - parameters: - traffic_allocation: nlp-summarization-online-dp=100 - - template: templates/${{ variables.version }}/test-deployment.yml@mlops-templates - parameters: - deployment_name: nlp-summarization-online-dp - sample_request: data/nlp-summarization-request.json - request_type: json