Skip to content

Commit

Permalink
Merge pull request #61 from rdzotz/patch-3
Browse files Browse the repository at this point in the history
Handle Multiple Models in deployment
  • Loading branch information
tranguyen221 authored Jan 14, 2022
2 parents b9aaf3c + 5930339 commit 9aaa6b6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines/templates/deploy-model.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}} \
Expand Down
1 change: 1 addition & 0 deletions configuration/configuration-aml.variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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\"]'
15 changes: 10 additions & 5 deletions operation/execution/deploy_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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...')
Expand All @@ -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')
Expand All @@ -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,
Expand Down

0 comments on commit 9aaa6b6

Please sign in to comment.