From cc326289c07a1df2202662db006a07c911dc11ab Mon Sep 17 00:00:00 2001 From: Reuben Zotz-Wilson Date: Thu, 13 Jan 2022 11:51:46 +0100 Subject: [PATCH 1/3] deploy_model.py to deal with multiple models Added some logic to deal with either a single or multiple models in the input to deploy_model --- operation/execution/deploy_model.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/operation/execution/deploy_model.py b/operation/execution/deploy_model.py index fe16864..e561740 100644 --- a/operation/execution/deploy_model.py +++ b/operation/execution/deploy_model.py @@ -7,11 +7,16 @@ from aml_utils import config, workspace, deployment +import json -def main(model_name, service_name, compute_config_file, environment_path, aks_target_name=None): + +def main(model_names, service_name, compute_config_file, environment_path, aks_target_name=None): ws = workspace.retrieve_workspace() - model = Model(ws, name=model_name) # TODO: support for more than 1 model? + models = [] + for name in model_names: + models.append(Model(ws, name=name)) + print(f"model_name: {name}") # Get repo root path, every other path will be relative to this base_path = config.get_root_path() @@ -32,7 +37,7 @@ def main(model_name, service_name, compute_config_file, environment_path, aks_ta service = deployment.launch_deployment( ws, service_name=service_name, - models=[model], + models=models, deployment_params=deployment_params ) print(f'Waiting for deployment of {service.name} to finish...') @@ -41,7 +46,7 @@ def main(model_name, service_name, compute_config_file, environment_path, aks_ta def parse_args(args_list=None): parser = argparse.ArgumentParser() - parser.add_argument('--model-name', type=str, required=True) + parser.add_argument('--model-names', type=json.loads, required=True) parser.add_argument('--config-path', type=str, required=True) parser.add_argument('--env-path', type=str, required=True) parser.add_argument('--service-name', type=str, default='webservice') @@ -53,7 +58,7 @@ def parse_args(args_list=None): args = parse_args() main( - model_name=args.model_name, + model_name=args.model_names, service_name=args.service_name, compute_config_file=args.config_path, environment_path=args.env_path, From d7ddef8118508efb7226db1286744e95bc259e45 Mon Sep 17 00:00:00 2001 From: Reuben Zotz-Wilson Date: Thu, 13 Jan 2022 12:13:18 +0100 Subject: [PATCH 2/3] Dealing with multiple models Added a working structure to accept multiple models into a single deployment workflow --- configuration/configuration-aml.variables.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/configuration/configuration-aml.variables.yml b/configuration/configuration-aml.variables.yml index aab47d1..f6ec0ea 100644 --- a/configuration/configuration-aml.variables.yml +++ b/configuration/configuration-aml.variables.yml @@ -30,3 +30,4 @@ variables: AML_REALTIMEINFERENCE_ENV_PATH: $(AML_BATCHINFERENCE_ENV_PATH) AKS_COMPUTE: aks-compute AML_WEBSERVICE: webservice + AML_MODELS: '[\"$(AML_MODEL_NAME)\",\"some-other-model\"]' From 5930339e9737e5b888147957c8c75d821ecf0fac Mon Sep 17 00:00:00 2001 From: Reuben Zotz-Wilson Date: Thu, 13 Jan 2022 12:20:13 +0100 Subject: [PATCH 3/3] changed template to accepted concat of model names Added input of AML_MODELS and changed the name of the deploy.py inputs to reflect change from model_name to model_names --- azure-pipelines/templates/deploy-model.template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/templates/deploy-model.template.yml b/azure-pipelines/templates/deploy-model.template.yml index aaf8e08..4be6097 100644 --- a/azure-pipelines/templates/deploy-model.template.yml +++ b/azure-pipelines/templates/deploy-model.template.yml @@ -50,7 +50,7 @@ jobs: artifactName: ${{parameters.artifactName}} deploymentScript: operation/execution/deploy_model.py scriptArguments: | - --model-name $(AML_MODEL_NAME) \ + --model-names $(AML_MODELS) \ --config-path configuration/compute/${{parameters.environment}}-realtimeinference-webservice-${{parameters.deploymentType}}.yml \ --env-path $(AML_REALTIMEINFERENCE_ENV_PATH) \ --service-name ${{parameters.webserviceName}} \