Skip to content

Commit cf0ace5

Browse files
authored
Improve code coverage deployment and endpoint e2e tests (Azure#39842)
* unskip deployment and endpoint e2e tests * update online deployment config setup * fix online deployment e2e tests * fix test mlclient issue * fix failing tests * fix failing tests * unskip endpoint test * update recordings * add deployment update test * update recordings * recording updated * update recordings * update deployment * update recordings * update recordings * reformat code * update recordings * remove unnecessary file * update recordings
1 parent 5ec17cc commit cf0ace5

File tree

13 files changed

+136
-290
lines changed

13 files changed

+136
-290
lines changed

sdk/ml/azure-ai-ml/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/ml/azure-ai-ml",
5-
"Tag": "python/ml/azure-ai-ml_8d69a348d2"
5+
"Tag": "python/ml/azure-ai-ml_57e03d7d64"
66
}

sdk/ml/azure-ai-ml/tests/environment/unittests/test_env_entity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ def test_anonymous_environment_version_changes_with_inference_config(self):
127127

128128
assert env_no_inference_config.name == env_no_inference_config.name == ANONYMOUS_ENV_NAME
129129
assert env_no_inference_config.version != env_with_inference_config.version
130-
assert env_no_inference_config.version == "00b3749100a718714b17f57de1ae61fa"
131-
assert env_with_inference_config.version == "935315c7d8de8e0972f0460960727a17"
130+
assert env_no_inference_config.version == "25484232c6e5bfb2c6e1dc5d38fb9fa5"
131+
assert env_with_inference_config.version == "b181e0fef2ad76757e2f78317c10cb2b"
132132

133133
def test_ipp_environment(self) -> None:
134134
# test through deserializing REST instead of using real IP assets

sdk/ml/azure-ai-ml/tests/online_services/e2etests/test_online_deployment.py

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,19 @@
44
from devtools_testutils import AzureRecordedTestCase
55

66
from azure.ai.ml import MLClient, load_online_deployment, load_online_endpoint
7-
from azure.ai.ml.constants import AssetTypes
8-
from azure.ai.ml.entities import ManagedOnlineDeployment, ManagedOnlineEndpoint, Model
7+
from azure.ai.ml.entities import ManagedOnlineDeployment, ManagedOnlineEndpoint, Model, CodeConfiguration, Environment
98

109

1110
@pytest.mark.e2etest
11+
@pytest.mark.usefixtures("recorded_test", "mock_asset_name", "mock_component_hash", "mock_code_hash")
1212
@pytest.mark.production_experiences_test
1313
class TestOnlineDeployment(AzureRecordedTestCase):
14-
@pytest.mark.skip(
15-
reason="Tests failing in internal automation due to lack of quota. Cannot record or run in live mode."
16-
)
17-
def test_online_deployment(
14+
def test_online_deployment_create(
1815
self, client: MLClient, rand_online_name: Callable[[], str], rand_online_deployment_name: Callable[[], str]
1916
) -> None:
2017
endpoint_yaml = "tests/test_configs/deployments/online/simple_online_endpoint_mir.yaml"
2118
deployment_yaml = "tests/test_configs/deployments/online/online_deployment_1.yaml"
22-
name = rand_online_name("name")
19+
name = rand_online_name("endpoint_name")
2320
endpoint = load_online_endpoint(endpoint_yaml)
2421
endpoint.name = name
2522

@@ -53,7 +50,42 @@ def test_online_deployment(
5350
finally:
5451
client.online_endpoints.begin_delete(name=endpoint.name)
5552

56-
@pytest.mark.skip(reason="Known failure")
53+
def test_online_deployment_update(
54+
self, client: MLClient, rand_online_name: Callable[[], str], rand_online_deployment_name: Callable[[], str]
55+
) -> None:
56+
endpoint_yaml = "tests/test_configs/deployments/online/simple_online_endpoint_mir.yaml"
57+
deployment_yaml = "tests/test_configs/deployments/online/online_deployment_1.yaml"
58+
endpoint = load_online_endpoint(endpoint_yaml)
59+
endpoint_name = rand_online_name("endpoint-name")
60+
endpoint.name = endpoint_name
61+
deployment = load_online_deployment(deployment_yaml)
62+
deployment_name = rand_online_deployment_name("deployment_name")
63+
deployment.name = deployment_name
64+
deployment.endpoint_name = endpoint_name
65+
66+
# create a endpoint
67+
client.online_endpoints.begin_create_or_update(endpoint).result()
68+
69+
try:
70+
# create a deployment
71+
client.online_deployments.begin_create_or_update(deployment).result()
72+
dep = client.online_deployments.get(name=deployment.name, endpoint_name=endpoint.name)
73+
assert dep.name == deployment.name
74+
75+
deps = client.online_deployments.list(endpoint_name=endpoint.name)
76+
deps = list(deps)
77+
assert len(deps) == 1
78+
assert deps[0].name == deployment.name
79+
80+
dep.instance_count = 3
81+
updated_deploymwnt = client.online_deployments.begin_create_or_update(dep).result()
82+
assert updated_deploymwnt.instance_count == 3
83+
84+
except Exception as ex:
85+
raise ex
86+
finally:
87+
client.online_endpoints.begin_delete(name=endpoint.name)
88+
5789
def test_online_deployment_skip_script_validation(
5890
self, client: MLClient, rand_online_name: Callable[[], str], rand_online_deployment_name: Callable[[], str]
5991
) -> None:
@@ -74,21 +106,31 @@ def test_online_deployment_skip_script_validation(
74106
# create a blue deployment
75107
model = Model(
76108
name="test-model",
77-
version="4",
78-
path="tests/test_configs/deployments/sklearn-diabetes/model",
79-
type=AssetTypes.MLFLOW_MODEL,
109+
path="tests/test_configs/deployments/model-1/model",
80110
description="my sample mlflow model",
81111
)
82112

113+
code_config = CodeConfiguration(
114+
code="tests/test_configs/deployments/model-1/onlinescoring/",
115+
scoring_script="score.py",
116+
)
117+
118+
environment = Environment(
119+
conda_file="tests/test_configs/deployments/model-1/environment/conda.yml",
120+
image="mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu20.04:latest",
121+
)
122+
83123
blue_deployment = ManagedOnlineDeployment(
84124
name=online_deployment_name,
85125
endpoint_name=online_endpoint_name,
126+
code_configuration=code_config,
127+
environment=environment,
86128
model=model,
87-
instance_type="Standard_F4s_v2",
129+
instance_type="Standard_DS3_v2",
88130
instance_count=1,
89131
)
90132

91-
client.online_deployments.begin_create_or_update(blue_deployment).result()
133+
client.online_deployments.begin_create_or_update(blue_deployment, skip_script_validation=True).result()
92134
except Exception as ex:
93135
raise ex
94136
finally:

0 commit comments

Comments
 (0)