Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-route instance count to resource config for Model Batch Deployment #34249

Merged
merged 4 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
unittest model batch deployment settings
  • Loading branch information
nemanjarajic committed Feb 16, 2024
commit 44c4c4ef22aca938c9f81555e23c940f111ed1d1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from pathlib import Path

import pytest
import yaml

from azure.ai.ml._schema._deployment.batch.model_batch_deployment import ModelBatchDeploymentSchema
from azure.ai.ml.constants._common import BASE_PATH_CONTEXT_KEY
from azure.ai.ml.constants._deployment import BatchDeploymentOutputAction
from azure.ai.ml.entities import BatchDeployment
from azure.ai.ml.entities._util import load_from_dict


def load_batch_deployment_entity_from_yaml(path: str, context={}) -> BatchDeployment:
"""batch deployment yaml -> batch deployment entity"""
with open(path, "r") as f:
cfg = yaml.safe_load(f)
context.update({BASE_PATH_CONTEXT_KEY: Path(path).parent})
deployment = load_from_dict(ModelBatchDeploymentSchema, cfg, context)
return deployment


@pytest.mark.unittest
@pytest.mark.production_experiences_test
class TestModelBatchDeploymentSchema:
def test_serialize_model_batch_deployment(self) -> None:
test_path = "./tests/test_configs/deployments/batch/model_batch_deployment.yaml"
mbd_entity = load_batch_deployment_entity_from_yaml(test_path)

assert mbd_entity
assert mbd_entity.environment == "AzureML-sklearn-1.0-ubuntu20.04-py38-cpu:33"
assert mbd_entity.compute == "cpu-cluster"
assert mbd_entity.model_deployment_settings.output_action == BatchDeploymentOutputAction.APPEND_ROW
assert mbd_entity.model_deployment_settings.output_file_name == "append_row.txt"
assert mbd_entity.model_deployment_settings.error_threshold == 10
assert mbd_entity.model_deployment_settings.mini_batch_size == 5
assert mbd_entity.model_deployment_settings.max_concurrency_per_instance == 5
assert mbd_entity.resources.instance_count == 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: blue
endpoint_name: myBatchEndpoint
model:
name: model-1
version: 5
path: ../model-1/model/sklearn_regression_model.pkl
code_configuration:
code: ../endpoint_scoring
scoring_script: ./main.py
environment: azureml:AzureML-sklearn-1.0-ubuntu20.04-py38-cpu:33
compute: "azureml:cpu-cluster"
settings:
instance_count: 2
retry_settings: #optional
max_retries: 3
timeout: 30
mini_batch_size: 5
logging_level: info #optional, default is info
error_threshold: 10 #optional, default is -1
output_action: append_row #optional, Allowed Values: append_row, summary_only
output_file_name: append_row.txt #optional
max_concurrency_per_instance: 5
environment_variables:
AZUREML_BE: bla