Skip to content

Commit 7f6bc29

Browse files
wanghoppewiborishoppecRui861
authored
Azure Batch Track 2 Initial Beta Release (Azure#32383)
* inital checkin * updating tests * test proxy changes * test fix * test updates * update python sdk with the latest changes to the typespec including the seperation fo class such as BatchPool to seperate classes that cover patch,update,add, etc * updating auth * Updating SDK based on the updated TypeSpec that combineds Get/Update Models plus some feedback from the review. All tests pass * updates * updates * add conftest * update with the latest typespec file * Revert "update with the latest typespec file" This reverts commit 090303d. * modify if_modified_since to pass tests * update to use new operations * updated with removed operation * modifiy preparer, still have datetime problem * some playback test running * 5 playback passing * add back operation patch file * really temp... * before live test * live and playback passsing, before change patch * before try sync * async test working v1 * batch name tests passed * temp: before patch operation * add aio operation patch to pass tests * add async_wrapper test, before add tasks related tests * tasks tests passing * remove backup file * restore some changes from origin/main * resolve credscan issue * update changelog * async tests working * change version to check CI * update changelog * fixing issue that blocked apiview from decoding the wheel file * Remove 'Result' from BatchNodeRemoteLoginSettingsResult (Azure#33089) * Wip * Fix naming changes in unit tests * create_pools switch argument body to pool - minor typo fix * Re-ran tsp compile from CADL with new script - generated format changes - fixes TypeError issues with _filter, _select, _expand * Fix more unit test errors * wip fixing len(data) issue - all tests passing * fix issue converting byte list to decimal * Add line * Remove line * Add line * Remove line * wip update changelog to include version * [Batch] Track 2 Updates (Azure#35796) * Generate track2 with latest typespec * Update imports * WIP sanitization/recordingredactor - some name changes between Parameters and Content endings - WIP certificateReference issue * WIP certificateReference issue * WIP update * Update with latest typespec - fix client.batch_api to just client now * Fix certificateReference * Fix module issues for generating API View * Fix more unit test errors * Update unit tests * Fix all unit tests * Update create_task_collection * playback tests passing * Migrate recordings to assets repo * Remove recordings from this repo bc migrated to assets repo * Update patch.py customizations * Add customizations for aio patch * Remove operations folders duplicate * Clean up comments * [Batch] Minor sanitization updates (Azure#37161) * Remove id and name sanitizers * Add sanitizer * Update assets * Undo * Update recordings * changelog update * Update changelog * Re-add changelog history and update major version to 15.0.0b1 for beta track 2 release * Update version and changelog * Update patch concurrencies * Update CreateTasksErrorException to CreateTasksError * Re-organize imports for patch files * Remove object from TaskWorkflowManager * cleanup imports and TYPE_CHECKING * import fixes * cleanup * Add samples directory * Update readme for samples * temp workaround ci pipeline error * readme update --------- Co-authored-by: wiboris <[email protected]> Co-authored-by: hoppe <[email protected]> Co-authored-by: Rena <[email protected]> Co-authored-by: Rena Chen <[email protected]>
1 parent 7e9ddf8 commit 7f6bc29

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+85501
-34044
lines changed

sdk/batch/azure-batch/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Release History
22

3+
## 15.0.0b1 (2024-09-01)
4+
5+
- Version (15.0.0b1) is the first preview of our efforts to create a user-friendly and Pythonic client library for Azure Batch. For more information about this, and preview releases of other Azure SDK libraries, please visit https://azure.github.io/azure-sdk/releases/latest/python.html.
6+
7+
### Breaking Changes
8+
9+
- Remove certificates
10+
- Remove render licenses
11+
- Remove `CloudServiceConfiguration` for pool models and operations. `VirtualMachineConfiguration` is supported for pool configurations moving forward.
12+
313
## 14.2.0 (2024-02-01)
414

515
### Features Added

sdk/batch/azure-batch/MANIFEST.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
include *.md
22
include LICENSE
3-
include azure/__init__.py
4-
recursive-include tests *.py
53
include azure/batch/py.typed
4+
recursive-include tests *.py
5+
recursive-include samples *.py *.md
6+
include azure/__init__.py

sdk/batch/azure-batch/assets.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"AssetsRepo": "Azure/azure-sdk-assets",
3+
"AssetsRepoPrefixPath": "python",
4+
"TagPrefix": "python/batch/azure-batch",
5+
"Tag": "python/batch/azure-batch_b2cb0e7ad7"
6+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
# coding=utf-8
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
4-
# Licensed under the MIT License. See License.txt in the project root for
5-
# license information.
6-
#
7-
# Code generated by Microsoft (R) AutoRest Code Generator.
8-
# Changes may cause incorrect behavior and will be lost if the code is
9-
# regenerated.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
107
# --------------------------------------------------------------------------
118

12-
from ._configuration import BatchServiceClientConfiguration
13-
from ._batch_service_client import BatchServiceClient
14-
__all__ = ['BatchServiceClient', 'BatchServiceClientConfiguration']
15-
9+
from ._client import BatchClient
1610
from ._version import VERSION
1711

1812
__version__ = VERSION
1913

14+
try:
15+
from ._patch import __all__ as _patch_all
16+
from ._patch import * # pylint: disable=unused-wildcard-import
17+
except ImportError:
18+
_patch_all = []
19+
from ._patch import patch_sdk as _patch_sdk
20+
21+
__all__ = [
22+
"BatchClient",
23+
]
24+
__all__.extend([p for p in _patch_all if p not in __all__])
25+
26+
_patch_sdk()

sdk/batch/azure-batch/azure/batch/_batch_service_client.py

Lines changed: 0 additions & 95 deletions
This file was deleted.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from copy import deepcopy
10+
from typing import Any, TYPE_CHECKING
11+
12+
from azure.core import PipelineClient
13+
from azure.core.pipeline import policies
14+
from azure.core.rest import HttpRequest, HttpResponse
15+
16+
from ._configuration import BatchClientConfiguration
17+
from ._operations import BatchClientOperationsMixin
18+
from ._serialization import Deserializer, Serializer
19+
20+
if TYPE_CHECKING:
21+
# pylint: disable=unused-import,ungrouped-imports
22+
from azure.core.credentials import TokenCredential
23+
24+
25+
class BatchClient(BatchClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
26+
"""BatchClient.
27+
28+
:param endpoint: Batch account endpoint (for example:
29+
https://batchaccount.eastus2.batch.azure.com). Required.
30+
:type endpoint: str
31+
:param credential: Credential used to authenticate requests to the service. Required.
32+
:type credential: ~azure.core.credentials.TokenCredential
33+
:keyword api_version: The API version to use for this operation. Default value is
34+
"2024-02-01.19.0". Note that overriding this default value may result in unsupported behavior.
35+
:paramtype api_version: str
36+
"""
37+
38+
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
39+
_endpoint = "{endpoint}"
40+
self._config = BatchClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
41+
kwargs["request_id_header_name"] = "client-request-id"
42+
_policies = kwargs.pop("policies", None)
43+
if _policies is None:
44+
_policies = [
45+
policies.RequestIdPolicy(**kwargs),
46+
self._config.headers_policy,
47+
self._config.user_agent_policy,
48+
self._config.proxy_policy,
49+
policies.ContentDecodePolicy(**kwargs),
50+
self._config.redirect_policy,
51+
self._config.retry_policy,
52+
self._config.authentication_policy,
53+
self._config.custom_hook_policy,
54+
self._config.logging_policy,
55+
policies.DistributedTracingPolicy(**kwargs),
56+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
57+
self._config.http_logging_policy,
58+
]
59+
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
60+
61+
self._serialize = Serializer()
62+
self._deserialize = Deserializer()
63+
self._serialize.client_side_validation = False
64+
65+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
66+
"""Runs the network request through the client's chained policies.
67+
68+
>>> from azure.core.rest import HttpRequest
69+
>>> request = HttpRequest("GET", "https://www.example.org/")
70+
<HttpRequest [GET], url: 'https://www.example.org/'>
71+
>>> response = client.send_request(request)
72+
<HttpResponse: 200 OK>
73+
74+
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
75+
76+
:param request: The network request you want to make. Required.
77+
:type request: ~azure.core.rest.HttpRequest
78+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
79+
:return: The response of your network call. Does not do error handling on your response.
80+
:rtype: ~azure.core.rest.HttpResponse
81+
"""
82+
83+
request_copy = deepcopy(request)
84+
path_format_arguments = {
85+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
86+
}
87+
88+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
89+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
90+
91+
def close(self) -> None:
92+
self._client.close()
93+
94+
def __enter__(self) -> "BatchClient":
95+
self._client.__enter__()
96+
return self
97+
98+
def __exit__(self, *exc_details: Any) -> None:
99+
self._client.__exit__(*exc_details)
Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,65 @@
11
# coding=utf-8
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
4-
# Licensed under the MIT License. See License.txt in the project root for
5-
# license information.
6-
#
7-
# Code generated by Microsoft (R) AutoRest Code Generator.
8-
# Changes may cause incorrect behavior and will be lost if the code is
9-
# regenerated.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
107
# --------------------------------------------------------------------------
11-
from msrestazure import AzureConfiguration
8+
9+
from typing import Any, TYPE_CHECKING
10+
11+
from azure.core.pipeline import policies
1212

1313
from ._version import VERSION
1414

15+
if TYPE_CHECKING:
16+
# pylint: disable=unused-import,ungrouped-imports
17+
from azure.core.credentials import TokenCredential
18+
19+
20+
class BatchClientConfiguration: # pylint: disable=too-many-instance-attributes
21+
"""Configuration for BatchClient.
1522
16-
class BatchServiceClientConfiguration(AzureConfiguration):
17-
"""Configuration for BatchServiceClient
1823
Note that all parameters used to create this instance are saved as instance
1924
attributes.
2025
21-
:param credentials: Credentials needed for the client to connect to Azure.
22-
:type credentials: :mod:`A msrestazure Credentials
23-
object<msrestazure.azure_active_directory>`
24-
:param batch_url: The base URL for all Azure Batch service requests.
25-
:type batch_url: str
26+
:param endpoint: Batch account endpoint (for example:
27+
https://batchaccount.eastus2.batch.azure.com). Required.
28+
:type endpoint: str
29+
:param credential: Credential used to authenticate requests to the service. Required.
30+
:type credential: ~azure.core.credentials.TokenCredential
31+
:keyword api_version: The API version to use for this operation. Default value is
32+
"2024-02-01.19.0". Note that overriding this default value may result in unsupported behavior.
33+
:paramtype api_version: str
2634
"""
2735

28-
def __init__(
29-
self, credentials, batch_url):
30-
31-
if credentials is None:
32-
raise ValueError("Parameter 'credentials' must not be None.")
33-
if batch_url is None:
34-
raise ValueError("Parameter 'batch_url' must not be None.")
35-
base_url = '{batchUrl}'
36-
37-
super(BatchServiceClientConfiguration, self).__init__(base_url)
36+
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
37+
api_version: str = kwargs.pop("api_version", "2024-02-01.19.0")
3838

39-
# Starting Autorest.Python 4.0.64, make connection pool activated by default
40-
self.keep_alive = True
39+
if endpoint is None:
40+
raise ValueError("Parameter 'endpoint' must not be None.")
41+
if credential is None:
42+
raise ValueError("Parameter 'credential' must not be None.")
4143

42-
self.add_user_agent('azure-batch/{}'.format(VERSION))
43-
self.add_user_agent('Azure-SDK-For-Python')
44+
self.endpoint = endpoint
45+
self.credential = credential
46+
self.api_version = api_version
47+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://batch.core.windows.net//.default"])
48+
kwargs.setdefault("sdk_moniker", "batch/{}".format(VERSION))
49+
self.polling_interval = kwargs.get("polling_interval", 30)
50+
self._configure(**kwargs)
4451

45-
self.credentials = credentials
46-
self.batch_url = batch_url
52+
def _configure(self, **kwargs: Any) -> None:
53+
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
54+
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
55+
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
56+
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
57+
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
58+
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
59+
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
60+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
61+
self.authentication_policy = kwargs.get("authentication_policy")
62+
if self.credential and not self.authentication_policy:
63+
self.authentication_policy = policies.BearerTokenCredentialPolicy(
64+
self.credential, *self.credential_scopes, **kwargs
65+
)

0 commit comments

Comments
 (0)