Skip to content

Commit 57e0492

Browse files
adding allowed_instance_types and Schema shortlink (#44387)
* adding allowed_instance_types and Schema shortlink * pylint fix and changelog update * changelog update
1 parent de53a2e commit 57e0492

File tree

12 files changed

+110
-89
lines changed

12 files changed

+110
-89
lines changed

sdk/ml/azure-ai-ml/CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- Ensuring that azureml-dataprep-rslex is only installed for PyPy below 3.10 and CPython below 3.13.
1515
- Adding support for Python 3.14.
1616
- Dropping support for Python 3.7 and 3.8.
17+
- Update the deployment template parameter `allowed_instance_type` -> `allowed_instance_types`
1718

1819
## 1.30.0 (2025-10-29)
1920

@@ -40,10 +41,12 @@
4041
- `ml_client.deployment_templates.restore()`
4142

4243
### Bugs Fixed
44+
4345
- Fix for registry resource group passed to OnlineEndpointOperations when model is in registry in different resource group compared to workspace.
4446
- Set defaults for min_instances, max_instances, idle_time_before_scale_down in AmlCompute
4547

4648
### Other Changes
49+
4750
- v2 component types are now case insensitive
4851

4952
## 1.28.1 (2025-07-08)
@@ -767,4 +770,4 @@
767770

768771
### Features Added
769772

770-
- First preview.
773+
- First preview.

sdk/ml/azure-ai-ml/azure/ai/ml/_restclient/v2024_04_01_dataplanepreview/models/_models.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ class DeploymentTemplate(msrest.serialization.Model):
228228
:vartype liveness_probe: ~azure.mgmt.machinelearningservices.models.ProbeSettings
229229
:ivar readiness_probe: Readiness probe settings.
230230
:vartype readiness_probe: ~azure.mgmt.machinelearningservices.models.ProbeSettings
231-
:ivar allowed_instance_type: Required. List of allowed instance types for the deployment.
232-
:vartype allowed_instance_type: list[str]
231+
:ivar allowed_instance_types: Required. List of allowed instance types for the deployment.
232+
:vartype allowed_instance_types: list[str]
233233
:ivar default_instance_type: Required. Default instance type for the deployment.
234234
:vartype default_instance_type: str
235235
:ivar instance_count: Required. Number of instances for the deployment.
@@ -245,7 +245,7 @@ class DeploymentTemplate(msrest.serialization.Model):
245245
'system_data': {'readonly': True},
246246
'deployment_template_type': {'required': True},
247247
'environment_id': {'required': True},
248-
'allowed_instance_type': {'required': True},
248+
'allowed_instance_types': {'required': True},
249249
'default_instance_type': {'required': True},
250250
'instance_count': {'required': True},
251251
}
@@ -265,7 +265,7 @@ class DeploymentTemplate(msrest.serialization.Model):
265265
'request_settings': {'key': 'requestSettings', 'type': 'OnlineRequestSettings'},
266266
'liveness_probe': {'key': 'livenessProbe', 'type': 'ProbeSettings'},
267267
'readiness_probe': {'key': 'readinessProbe', 'type': 'ProbeSettings'},
268-
'allowed_instance_type': {'key': 'allowedInstanceType', 'type': '[str]'},
268+
'allowed_instance_types': {'key': 'allowedInstanceTypes', 'type': '[str]'},
269269
'default_instance_type': {'key': 'defaultInstanceType', 'type': 'str'},
270270
'instance_count': {'key': 'instanceCount', 'type': 'int'},
271271
'scoring_path': {'key': 'scoringPath', 'type': 'str'},
@@ -304,8 +304,8 @@ def __init__(
304304
:paramtype liveness_probe: ~azure.mgmt.machinelearningservices.models.ProbeSettings
305305
:keyword readiness_probe: Readiness probe settings.
306306
:paramtype readiness_probe: ~azure.mgmt.machinelearningservices.models.ProbeSettings
307-
:keyword allowed_instance_type: Required. List of allowed instance types for the deployment.
308-
:paramtype allowed_instance_type: list[str]
307+
:keyword allowed_instance_types: Required. List of allowed instance types for the deployment.
308+
:paramtype allowed_instance_types: list[str]
309309
:keyword default_instance_type: Required. Default instance type for the deployment.
310310
:paramtype default_instance_type: str
311311
:keyword instance_count: Required. Number of instances for the deployment.
@@ -330,7 +330,7 @@ def __init__(
330330
self.request_settings = kwargs.get('request_settings', None)
331331
self.liveness_probe = kwargs.get('liveness_probe', None)
332332
self.readiness_probe = kwargs.get('readiness_probe', None)
333-
self.allowed_instance_type = kwargs['allowed_instance_type']
333+
self.allowed_instance_types = kwargs['allowed_instance_types']
334334
self.default_instance_type = kwargs['default_instance_type']
335335
self.instance_count = kwargs['instance_count']
336336
self.scoring_path = kwargs.get('scoring_path', None)

sdk/ml/azure-ai-ml/azure/ai/ml/_restclient/v2024_04_01_dataplanepreview/models/_models_py3.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ class DeploymentTemplate(msrest.serialization.Model):
247247
:vartype liveness_probe: ~azure.mgmt.machinelearningservices.models.ProbeSettings
248248
:ivar readiness_probe: Readiness probe settings.
249249
:vartype readiness_probe: ~azure.mgmt.machinelearningservices.models.ProbeSettings
250-
:ivar allowed_instance_type: Required. List of allowed instance types for the deployment.
251-
:vartype allowed_instance_type: list[str]
250+
:ivar allowed_instance_types: Required. List of allowed instance types for the deployment.
251+
:vartype allowed_instance_types: list[str]
252252
:ivar default_instance_type: Required. Default instance type for the deployment.
253253
:vartype default_instance_type: str
254254
:ivar instance_count: Required. Number of instances for the deployment.
@@ -264,7 +264,7 @@ class DeploymentTemplate(msrest.serialization.Model):
264264
'system_data': {'readonly': True},
265265
'deployment_template_type': {'required': True},
266266
'environment_id': {'required': True},
267-
'allowed_instance_type': {'required': True},
267+
'allowed_instance_types': {'required': True},
268268
'default_instance_type': {'required': True},
269269
'instance_count': {'required': True},
270270
}
@@ -284,7 +284,7 @@ class DeploymentTemplate(msrest.serialization.Model):
284284
'request_settings': {'key': 'requestSettings', 'type': 'OnlineRequestSettings'},
285285
'liveness_probe': {'key': 'livenessProbe', 'type': 'ProbeSettings'},
286286
'readiness_probe': {'key': 'readinessProbe', 'type': 'ProbeSettings'},
287-
'allowed_instance_type': {'key': 'allowedInstanceType', 'type': '[str]'},
287+
'allowed_instance_types': {'key': 'allowedInstanceTypes', 'type': '[str]'},
288288
'default_instance_type': {'key': 'defaultInstanceType', 'type': 'str'},
289289
'instance_count': {'key': 'instanceCount', 'type': 'int'},
290290
'scoring_path': {'key': 'scoringPath', 'type': 'str'},
@@ -296,7 +296,7 @@ def __init__(
296296
*,
297297
deployment_template_type: str,
298298
environment_id: str,
299-
allowed_instance_type: List[str],
299+
allowed_instance_types: List[str],
300300
default_instance_type: str,
301301
instance_count: int,
302302
stage: Optional[str] = "Development",
@@ -341,8 +341,8 @@ def __init__(
341341
:paramtype liveness_probe: ~azure.mgmt.machinelearningservices.models.ProbeSettings
342342
:keyword readiness_probe: Readiness probe settings.
343343
:paramtype readiness_probe: ~azure.mgmt.machinelearningservices.models.ProbeSettings
344-
:keyword allowed_instance_type: Required. List of allowed instance types for the deployment.
345-
:paramtype allowed_instance_type: list[str]
344+
:keyword allowed_instance_types: Required. List of allowed instance types for the deployment.
345+
:paramtype allowed_instance_types: list[str]
346346
:keyword default_instance_type: Required. Default instance type for the deployment.
347347
:paramtype default_instance_type: str
348348
:keyword instance_count: Required. Number of instances for the deployment.
@@ -367,7 +367,7 @@ def __init__(
367367
self.request_settings = request_settings
368368
self.liveness_probe = liveness_probe
369369
self.readiness_probe = readiness_probe
370-
self.allowed_instance_type = allowed_instance_type
370+
self.allowed_instance_types = allowed_instance_types
371371
self.default_instance_type = default_instance_type
372372
self.instance_count = instance_count
373373
self.scoring_path = scoring_path

sdk/ml/azure-ai-ml/azure/ai/ml/_schema/_deployment/template/deployment_template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class DeploymentTemplateSchema(PathAwareSchema):
4444
readiness_probe = NestedField(ProbeSettingsSchema)
4545
instance_count = fields.Int()
4646
model_mount_path = fields.Str()
47-
allowed_instance_type = fields.Str()
47+
allowed_instance_types = fields.Str()
4848
default_instance_type = fields.Str()
4949
environment = UnionField(
5050
[

sdk/ml/azure-ai-ml/azure/ai/ml/constants/_common.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ class YAMLRefDocLinks:
532532
FEATURE_STORE_ENTITY = "https://aka.ms/ml-cli-v2-featurestore-entity-yaml-reference"
533533
HUB = "https://aka.ms/ml-cli-v2-workspace-hub-entity-yaml-reference"
534534
CAPABILITY_HOST = "https://aka.ms/ml-cli-v2-capability-host-yaml-reference"
535+
DEPLOYMENT_TEMPLATE = "https://aka.ms/ml-cli-v2-deployment-template-yaml-reference"
535536

536537

537538
class YAMLRefDocSchemaNames:
@@ -588,6 +589,8 @@ class YAMLRefDocSchemaNames:
588589
"""Job Schedule."""
589590
CAPABILITY_HOST = "CapabilityHost"
590591
"""Capability host."""
592+
DEPLOYMENT_TEMPLATE = "DeploymentTemplate"
593+
"""Deployment template."""
591594

592595

593596
class DockerTypes:

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_deployment/deployment_template.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def __init__( # pylint: disable=too-many-locals
6969
code_configuration: Optional[Dict[str, Any]] = None,
7070
environment_variables: Optional[Dict[str, str]] = None,
7171
app_insights_enabled: Optional[bool] = None,
72-
allowed_instance_type: Optional[str] = None,
72+
allowed_instance_types: Optional[str] = None,
7373
default_instance_type: Optional[str] = None, # Handle default instance type
7474
scoring_port: Optional[int] = None,
7575
scoring_path: Optional[str] = None,
@@ -99,7 +99,7 @@ def __init__( # pylint: disable=too-many-locals
9999
self.code_configuration = code_configuration
100100
self.environment_variables = environment_variables
101101
self.app_insights_enabled = app_insights_enabled
102-
self.allowed_instance_type = allowed_instance_type
102+
self.allowed_instance_types = allowed_instance_types
103103
self.default_instance_type = default_instance_type
104104
self.scoring_port = scoring_port
105105
self.scoring_path = scoring_path
@@ -362,7 +362,9 @@ def get_value(source, key, default=None):
362362
)
363363

364364
# Extract additional fields
365-
allowed_instance_type = get_value(properties, "allowedInstanceType") or get_value(obj, "allowed_instance_type")
365+
allowed_instance_types = get_value(properties, "allowedInstanceTypes") or get_value(
366+
obj, "allowed_instance_types"
367+
)
366368
scoring_port = get_value(properties, "scoringPort") or get_value(obj, "scoring_port")
367369
scoring_path = get_value(properties, "scoringPath") or get_value(obj, "scoring_path")
368370
model_mount_path = get_value(properties, "modelMountPath") or get_value(obj, "model_mount_path")
@@ -387,12 +389,12 @@ def get_value(source, key, default=None):
387389
except (ValueError, SyntaxError):
388390
environment_variables = {}
389391

390-
# Parse allowed_instance_type if it's a string
391-
if isinstance(allowed_instance_type, str):
392+
# Parse allowed_instance_types if it's a string
393+
if isinstance(allowed_instance_types, str):
392394
try:
393-
allowed_instance_type = ast.literal_eval(allowed_instance_type)
395+
allowed_instance_types = ast.literal_eval(allowed_instance_types)
394396
except (ValueError, SyntaxError):
395-
allowed_instance_type = None
397+
allowed_instance_types = None
396398

397399
# Convert request_settings to OnlineRequestSettings object using the built-in conversion method
398400
request_settings_obj = OnlineRequestSettings._from_rest_object(request_settings) if request_settings else None
@@ -434,7 +436,7 @@ def get_value(source, key, default=None):
434436
environment_variables=environment_variables,
435437
app_insights_enabled=get_value(obj, "app_insights_enabled"), # May not be present in this API format
436438
deployment_template_type=deployment_template_type, # Include deployment template type
437-
allowed_instance_type=allowed_instance_type, # Include allowed instance types
439+
allowed_instance_types=allowed_instance_types, # Include allowed instance types
438440
scoring_port=scoring_port, # Include scoring port
439441
scoring_path=scoring_path, # Include scoring path
440442
model_mount_path=model_mount_path, # Include model mount path
@@ -466,7 +468,7 @@ def get_value(source, key, default=None):
466468
"code_configuration": get_value(obj, "code_configuration"),
467469
"app_insights_enabled": get_value(obj, "app_insights_enabled"),
468470
"deployment_template_type": deployment_template_type,
469-
"allowed_instance_type": allowed_instance_type,
471+
"allowed_instance_types": allowed_instance_types,
470472
"scoring_port": scoring_port,
471473
"scoring_path": scoring_path,
472474
"model_mount_path": model_mount_path,
@@ -564,15 +566,15 @@ def _to_rest_object(self) -> dict:
564566
result["appInsightsEnabled"] = self.app_insights_enabled # type: ignore
565567

566568
# Handle allowed instance types - convert string to array format for API
567-
if hasattr(self, "allowed_instance_type") and self.allowed_instance_type:
568-
if isinstance(self.allowed_instance_type, str):
569+
if hasattr(self, "allowed_instance_types") and self.allowed_instance_types:
570+
if isinstance(self.allowed_instance_types, str):
569571
# Convert space-separated string to array
570-
instance_types_array = self.allowed_instance_type.split()
571-
elif isinstance(self.allowed_instance_type, list):
572-
instance_types_array = self.allowed_instance_type
572+
instance_types_array = self.allowed_instance_types.split()
573+
elif isinstance(self.allowed_instance_types, list):
574+
instance_types_array = self.allowed_instance_types
573575
else:
574-
instance_types_array = [str(self.allowed_instance_type)]
575-
result["allowedInstanceType"] = instance_types_array # type: ignore[assignment]
576+
instance_types_array = [str(self.allowed_instance_types)]
577+
result["allowedInstanceTypes"] = instance_types_array # type: ignore[assignment]
576578

577579
return result
578580

@@ -637,8 +639,8 @@ def _to_dict(self) -> Dict:
637639
result["readinessProbe"] = readiness_dict # type: ignore[assignment]
638640

639641
# Add instance configuration
640-
if hasattr(self, "allowed_instance_type") and self.allowed_instance_type:
641-
result["allowedInstanceType"] = self.allowed_instance_type # type: ignore[assignment]
642+
if hasattr(self, "allowed_instance_types") and self.allowed_instance_types:
643+
result["allowedInstanceTypes"] = self.allowed_instance_types # type: ignore[assignment]
642644
if self.default_instance_type:
643645
result["defaultInstanceType"] = self.default_instance_type
644646
elif self.instance_type:

0 commit comments

Comments
 (0)