Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 5 additions & 5 deletions sdk/batch/azure-mgmt-batch/_meta.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"commit": "e2b5f9323c4214408969a6e953b4075cfdc693b6",
"commit": "c10717e7d69bb8114fb1b248fad4cc16e517189d",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"autorest": "3.9.2",
"autorest": "3.9.7",
"use": [
"@autorest/python@6.6.0",
"@autorest/modelerfour@4.24.3"
"@autorest/python@6.7.1",
"@autorest/modelerfour@4.26.2"
],
"autorest_command": "autorest specification/batch/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.6.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False",
"autorest_command": "autorest specification/batch/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False",
"readme": "specification/batch/resource-manager/readme.md"
}
26 changes: 18 additions & 8 deletions sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,9 @@ def _serialize(self, target_obj, data_type=None, **kwargs):
_serialized.update(_new_attr) # type: ignore
_new_attr = _new_attr[k] # type: ignore
_serialized = _serialized[k]
except ValueError:
continue
except ValueError as err:
if isinstance(err, SerializationError):
raise

except (AttributeError, KeyError, TypeError) as err:
msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj))
Expand Down Expand Up @@ -741,6 +742,8 @@ def query(self, name, data, data_type, **kwargs):

:param data: The data to be serialized.
:param str data_type: The type to be serialized from.
:keyword bool skip_quote: Whether to skip quote the serialized result.
Defaults to False.
:rtype: str
:raises: TypeError if serialization fails.
:raises: ValueError if data is None
Expand All @@ -749,10 +752,8 @@ def query(self, name, data, data_type, **kwargs):
# Treat the list aside, since we don't want to encode the div separator
if data_type.startswith("["):
internal_data_type = data_type[1:-1]
data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data]
if not kwargs.get("skip_quote", False):
data = [quote(str(d), safe="") for d in data]
return str(self.serialize_iter(data, internal_data_type, **kwargs))
do_quote = not kwargs.get("skip_quote", False)
return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs))

# Not a list, regular serialization
output = self.serialize_data(data, data_type, **kwargs)
Expand Down Expand Up @@ -891,6 +892,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs):
not be None or empty.
:param str div: If set, this str will be used to combine the elements
in the iterable into a combined string. Default is 'None'.
:keyword bool do_quote: Whether to quote the serialized result of each iterable element.
Defaults to False.
:rtype: list, str
"""
if isinstance(data, str):
Expand All @@ -903,9 +906,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs):
for d in data:
try:
serialized.append(self.serialize_data(d, iter_type, **kwargs))
except ValueError:
except ValueError as err:
if isinstance(err, SerializationError):
raise
serialized.append(None)

if kwargs.get("do_quote", False):
serialized = ["" if s is None else quote(str(s), safe="") for s in serialized]

if div:
serialized = ["" if s is None else str(s) for s in serialized]
serialized = div.join(serialized)
Expand Down Expand Up @@ -950,7 +958,9 @@ def serialize_dict(self, attr, dict_type, **kwargs):
for key, value in attr.items():
try:
serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs)
except ValueError:
except ValueError as err:
if isinstance(err, SerializationError):
raise
serialized[self.serialize_unicode(key)] = None

if "xml" in serialization_ctxt:
Expand Down
14 changes: 0 additions & 14 deletions sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_vendor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import List, cast

from azure.core.pipeline.transport import HttpRequest


Expand All @@ -16,15 +14,3 @@ def _convert_request(request, files=None):
if files:
request.set_formdata_body(files)
return request


def _format_url_section(template, **kwargs):
components = template.split("/")
while components:
try:
return template.format(**kwargs)
except KeyError as key:
# Need the cast, as for some reasons "split" is typed as list[str | Any]
formatted_components = cast(List[str], template.split("/"))
components = [c for c in formatted_components if "{}".format(key.args[0]) not in c]
template = "/".join(components)
2 changes: 1 addition & 1 deletion sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

VERSION = "17.1.0"
VERSION = "14.0.0b1"
24 changes: 12 additions & 12 deletions sdk/batch/azure-mgmt-batch/azure/mgmt/batch/models/_models_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2619,7 +2619,7 @@ class FixedScaleSettings(_serialization.Model):
def __init__(
self,
*,
resize_timeout: Optional[datetime.timedelta] = None,
resize_timeout: datetime.timedelta = "PT15M",
target_dedicated_nodes: Optional[int] = None,
target_low_priority_nodes: Optional[int] = None,
node_deallocation_option: Optional[Union[str, "_models.ComputeNodeDeallocationOption"]] = None,
Expand Down Expand Up @@ -2684,7 +2684,7 @@ def __init__(
publisher: Optional[str] = None,
offer: Optional[str] = None,
sku: Optional[str] = None,
version: Optional[str] = None,
version: str = "latest",
id: Optional[str] = None, # pylint: disable=redefined-builtin
**kwargs: Any
) -> None:
Expand Down Expand Up @@ -3293,7 +3293,7 @@ def __init__(
self,
*,
subnet_id: Optional[str] = None,
dynamic_vnet_assignment_scope: Optional[Union[str, "_models.DynamicVNetAssignmentScope"]] = None,
dynamic_vnet_assignment_scope: Union[str, "_models.DynamicVNetAssignmentScope"] = "none",
endpoint_configuration: Optional["_models.PoolEndpointConfiguration"] = None,
public_ip_address_configuration: Optional["_models.PublicIPAddressConfiguration"] = None,
enable_accelerated_networking: Optional[bool] = None,
Expand Down Expand Up @@ -3914,7 +3914,7 @@ def __init__( # pylint: disable=too-many-locals
scale_settings: Optional["_models.ScaleSettings"] = None,
inter_node_communication: Optional[Union[str, "_models.InterNodeCommunicationState"]] = None,
network_configuration: Optional["_models.NetworkConfiguration"] = None,
task_slots_per_node: Optional[int] = None,
task_slots_per_node: int = 1,
task_scheduling_policy: Optional["_models.TaskSchedulingPolicy"] = None,
user_accounts: Optional[List["_models.UserAccount"]] = None,
metadata: Optional[List["_models.MetadataItem"]] = None,
Expand Down Expand Up @@ -4618,7 +4618,7 @@ class StartTask(_serialization.Model):
task once, and may then retry up to this limit. For example, if the maximum retry count is 3,
Batch tries the task up to 4 times (one initial try and 3 retries). If the maximum retry count
is 0, the Batch service does not retry the task. If the maximum retry count is -1, the Batch
service retries the task without limit.
service retries the task without limit. Default is 0.
:vartype max_task_retry_count: int
:ivar wait_for_success: If true and the start task fails on a compute node, the Batch service
retries the start task up to its maximum retry count (maxTaskRetryCount). If the task has still
Expand Down Expand Up @@ -4653,7 +4653,7 @@ def __init__(
resource_files: Optional[List["_models.ResourceFile"]] = None,
environment_settings: Optional[List["_models.EnvironmentSetting"]] = None,
user_identity: Optional["_models.UserIdentity"] = None,
max_task_retry_count: Optional[int] = None,
max_task_retry_count: int = 0,
wait_for_success: Optional[bool] = None,
container_settings: Optional["_models.TaskContainerSettings"] = None,
**kwargs: Any
Expand All @@ -4678,7 +4678,7 @@ def __init__(
the task once, and may then retry up to this limit. For example, if the maximum retry count is
3, Batch tries the task up to 4 times (one initial try and 3 retries). If the maximum retry
count is 0, the Batch service does not retry the task. If the maximum retry count is -1, the
Batch service retries the task without limit.
Batch service retries the task without limit. Default is 0.
:paramtype max_task_retry_count: int
:keyword wait_for_success: If true and the start task fails on a compute node, the Batch
service retries the start task up to its maximum retry count (maxTaskRetryCount). If the task
Expand Down Expand Up @@ -4837,8 +4837,8 @@ class TaskSchedulingPolicy(_serialization.Model):

All required parameters must be populated in order to send to Azure.

:ivar node_fill_type: How tasks should be distributed across compute nodes. Required. Known
values are: "Spread" and "Pack".
:ivar node_fill_type: How tasks should be distributed across compute nodes. Known values are:
"Spread" and "Pack".
:vartype node_fill_type: str or ~azure.mgmt.batch.models.ComputeNodeFillType
"""

Expand All @@ -4850,10 +4850,10 @@ class TaskSchedulingPolicy(_serialization.Model):
"node_fill_type": {"key": "nodeFillType", "type": "str"},
}

def __init__(self, *, node_fill_type: Union[str, "_models.ComputeNodeFillType"], **kwargs: Any) -> None:
def __init__(self, *, node_fill_type: Union[str, "_models.ComputeNodeFillType"] = "Spread", **kwargs: Any) -> None:
"""
:keyword node_fill_type: How tasks should be distributed across compute nodes. Required. Known
values are: "Spread" and "Pack".
:keyword node_fill_type: How tasks should be distributed across compute nodes. Known values
are: "Spread" and "Pack".
:paramtype node_fill_type: str or ~azure.mgmt.batch.models.ComputeNodeFillType
"""
super().__init__(**kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
from .._vendor import _convert_request

T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
Expand Down Expand Up @@ -63,7 +63,7 @@ def build_create_request(
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -101,7 +101,7 @@ def build_delete_request(
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -137,7 +137,7 @@ def build_get_request(
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -174,7 +174,7 @@ def build_update_request(
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -214,7 +214,7 @@ def build_list_request(
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
if maxresults is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
from .._vendor import _convert_request

T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
Expand Down Expand Up @@ -71,7 +71,7 @@ def build_activate_request(
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -118,7 +118,7 @@ def build_create_request(
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -164,7 +164,7 @@ def build_delete_request(
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -208,7 +208,7 @@ def build_get_request(
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -250,7 +250,7 @@ def build_list_request(
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
if maxresults is not None:
Expand Down
Loading