Skip to content

Commit 00b9583

Browse files
authored
Skip container creation when retrieving linked storage account from the service (#723)
* Updated autogenerated part with latest version * Skip container creation when retrieving linked storage account from the service * Remove container existance and creation in storage methods
1 parent 08122f6 commit 00b9583

10 files changed

Lines changed: 137 additions & 92 deletions

File tree

azure-quantum/azure/quantum/_client/_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class WorkspaceClient:
3535
credential type or a key credential type. Required.
3636
:type credential: ~azure.core.credentials.TokenCredential or
3737
~azure.core.credentials.AzureKeyCredential
38-
:keyword api_version: The API version to use for this operation. Default value is
39-
"2025-12-01-preview". Note that overriding this default value may result in unsupported
40-
behavior.
38+
:keyword api_version: The API version to use for this operation. Known values are
39+
"2026-01-15-preview" and None. Default value is "2026-01-15-preview". Note that overriding this
40+
default value may result in unsupported behavior.
4141
:paramtype api_version: str
4242
"""
4343

azure-quantum/azure/quantum/_client/_configuration.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ class WorkspaceClientConfiguration: # pylint: disable=too-many-instance-attribu
3030
credential type or a key credential type. Required.
3131
:type credential: ~azure.core.credentials.TokenCredential or
3232
~azure.core.credentials.AzureKeyCredential
33-
:keyword api_version: The API version to use for this operation. Default value is
34-
"2025-12-01-preview". Note that overriding this default value may result in unsupported
35-
behavior.
33+
:keyword api_version: The API version to use for this operation. Known values are
34+
"2026-01-15-preview" and None. Default value is "2026-01-15-preview". Note that overriding this
35+
default value may result in unsupported behavior.
3636
:paramtype api_version: str
3737
"""
3838

3939
def __init__(self, endpoint: str, credential: Union["TokenCredential", AzureKeyCredential], **kwargs: Any) -> None:
40-
api_version: str = kwargs.pop("api_version", "2025-12-01-preview")
40+
api_version: str = kwargs.pop("api_version", "2026-01-15-preview")
4141

4242
if endpoint is None:
4343
raise ValueError("Parameter 'endpoint' must not be None.")

azure-quantum/azure/quantum/_client/_utils/model_base.py

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
TZ_UTC = timezone.utc
3939
_T = typing.TypeVar("_T")
40+
_NONE_TYPE = type(None)
4041

4142

4243
def _timedelta_as_isostr(td: timedelta) -> str:
@@ -217,7 +218,7 @@ def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime:
217218
test_utc = date_obj.utctimetuple()
218219
if test_utc.tm_year > 9999 or test_utc.tm_year < 1:
219220
raise OverflowError("Hit max or min date")
220-
return date_obj
221+
return date_obj # type: ignore[no-any-return]
221222

222223

223224
def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime:
@@ -271,7 +272,7 @@ def _deserialize_time(attr: typing.Union[str, time]) -> time:
271272
"""
272273
if isinstance(attr, time):
273274
return attr
274-
return isodate.parse_time(attr)
275+
return isodate.parse_time(attr) # type: ignore[no-any-return]
275276

276277

277278
def _deserialize_bytes(attr):
@@ -807,6 +808,14 @@ def _deserialize_multiple_sequence(
807808
return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers))
808809

809810

811+
def _is_array_encoded_deserializer(deserializer: functools.partial) -> bool:
812+
return (
813+
isinstance(deserializer, functools.partial)
814+
and isinstance(deserializer.args[0], functools.partial)
815+
and deserializer.args[0].func == _deserialize_array_encoded # pylint: disable=comparison-with-callable
816+
)
817+
818+
810819
def _deserialize_sequence(
811820
deserializer: typing.Optional[typing.Callable],
812821
module: typing.Optional[str],
@@ -816,17 +825,19 @@ def _deserialize_sequence(
816825
return obj
817826
if isinstance(obj, ET.Element):
818827
obj = list(obj)
819-
try:
820-
if (
821-
isinstance(obj, str)
822-
and isinstance(deserializer, functools.partial)
823-
and isinstance(deserializer.args[0], functools.partial)
824-
and deserializer.args[0].func == _deserialize_array_encoded # pylint: disable=comparison-with-callable
825-
):
826-
# encoded string may be deserialized to sequence
828+
829+
# encoded string may be deserialized to sequence
830+
if isinstance(obj, str) and isinstance(deserializer, functools.partial):
831+
# for list[str]
832+
if _is_array_encoded_deserializer(deserializer):
827833
return deserializer(obj)
828-
except: # pylint: disable=bare-except
829-
pass
834+
835+
# for list[Union[...]]
836+
if isinstance(deserializer.args[0], list):
837+
for sub_deserializer in deserializer.args[0]:
838+
if _is_array_encoded_deserializer(sub_deserializer):
839+
return sub_deserializer(obj)
840+
830841
return type(obj)(_deserialize(deserializer, entry, module) for entry in obj)
831842

832843

@@ -877,16 +888,16 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur
877888

878889
# is it optional?
879890
try:
880-
if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore
891+
if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore
881892
if len(annotation.__args__) <= 2: # pyright: ignore
882893
if_obj_deserializer = _get_deserialize_callable_from_annotation(
883-
next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore
894+
next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore
884895
)
885896

886897
return functools.partial(_deserialize_with_optional, if_obj_deserializer)
887898
# the type is Optional[Union[...]], we need to remove the None type from the Union
888899
annotation_copy = copy.copy(annotation)
889-
annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore
900+
annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a is not _NONE_TYPE] # pyright: ignore
890901
return _get_deserialize_callable_from_annotation(annotation_copy, module, rf)
891902
except AttributeError:
892903
pass
@@ -1012,7 +1023,7 @@ def _failsafe_deserialize(
10121023
) -> typing.Any:
10131024
try:
10141025
return _deserialize(deserializer, response.json(), module, rf, format)
1015-
except DeserializationError:
1026+
except Exception: # pylint: disable=broad-except
10161027
_LOGGER.warning(
10171028
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
10181029
)
@@ -1025,7 +1036,7 @@ def _failsafe_deserialize_xml(
10251036
) -> typing.Any:
10261037
try:
10271038
return _deserialize_xml(deserializer, response.text())
1028-
except DeserializationError:
1039+
except Exception: # pylint: disable=broad-except
10291040
_LOGGER.warning(
10301041
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
10311042
)
@@ -1271,7 +1282,7 @@ def _get_wrapped_element(
12711282
_get_element(v, exclude_readonly, meta, wrapped_element)
12721283
else:
12731284
wrapped_element.text = _get_primitive_type_value(v)
1274-
return wrapped_element
1285+
return wrapped_element # type: ignore[no-any-return]
12751286

12761287

12771288
def _get_primitive_type_value(v) -> str:
@@ -1284,7 +1295,9 @@ def _get_primitive_type_value(v) -> str:
12841295
return str(v)
12851296

12861297

1287-
def _create_xml_element(tag, prefix=None, ns=None):
1298+
def _create_xml_element(
1299+
tag: typing.Any, prefix: typing.Optional[str] = None, ns: typing.Optional[str] = None
1300+
) -> ET.Element:
12881301
if prefix and ns:
12891302
ET.register_namespace(prefix, ns)
12901303
if ns:

azure-quantum/azure/quantum/_client/aio/_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class WorkspaceClient:
3535
credential type or a key credential type. Required.
3636
:type credential: ~azure.core.credentials_async.AsyncTokenCredential or
3737
~azure.core.credentials.AzureKeyCredential
38-
:keyword api_version: The API version to use for this operation. Default value is
39-
"2025-12-01-preview". Note that overriding this default value may result in unsupported
40-
behavior.
38+
:keyword api_version: The API version to use for this operation. Known values are
39+
"2026-01-15-preview" and None. Default value is "2026-01-15-preview". Note that overriding this
40+
default value may result in unsupported behavior.
4141
:paramtype api_version: str
4242
"""
4343

azure-quantum/azure/quantum/_client/aio/_configuration.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ class WorkspaceClientConfiguration: # pylint: disable=too-many-instance-attribu
3030
credential type or a key credential type. Required.
3131
:type credential: ~azure.core.credentials_async.AsyncTokenCredential or
3232
~azure.core.credentials.AzureKeyCredential
33-
:keyword api_version: The API version to use for this operation. Default value is
34-
"2025-12-01-preview". Note that overriding this default value may result in unsupported
35-
behavior.
33+
:keyword api_version: The API version to use for this operation. Known values are
34+
"2026-01-15-preview" and None. Default value is "2026-01-15-preview". Note that overriding this
35+
default value may result in unsupported behavior.
3636
:paramtype api_version: str
3737
"""
3838

3939
def __init__(
4040
self, endpoint: str, credential: Union["AsyncTokenCredential", AzureKeyCredential], **kwargs: Any
4141
) -> None:
42-
api_version: str = kwargs.pop("api_version", "2025-12-01-preview")
42+
api_version: str = kwargs.pop("api_version", "2026-01-15-preview")
4343

4444
if endpoint is None:
4545
raise ValueError("Parameter 'endpoint' must not be None.")

azure-quantum/azure/quantum/_client/aio/operations/_operations.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def __init__(self, *args, **kwargs) -> None:
118118
"accept",
119119
]
120120
},
121-
api_versions_list=["2024-10-01-preview", "2025-09-01-preview", "2025-12-01-preview"],
121+
api_versions_list=["2024-10-01-preview", "2025-09-01-preview", "2025-12-01-preview", "2026-01-15-preview"],
122122
)
123123
def listv2(
124124
self,
@@ -547,7 +547,7 @@ async def update(
547547
"accept",
548548
]
549549
},
550-
api_versions_list=["2025-09-01-preview", "2025-12-01-preview"],
550+
api_versions_list=["2025-09-01-preview", "2025-12-01-preview", "2026-01-15-preview"],
551551
)
552552
async def update(
553553
self,
@@ -710,7 +710,7 @@ async def delete(
710710
"accept",
711711
]
712712
},
713-
api_versions_list=["2025-12-01-preview"],
713+
api_versions_list=["2025-12-01-preview", "2026-01-15-preview"],
714714
)
715715
async def cancel(
716716
self, subscription_id: str, resource_group_name: str, workspace_name: str, job_id: str, **kwargs: Any
@@ -856,7 +856,13 @@ async def get(
856856
@distributed_trace
857857
@api_version_validation(
858858
params_added_on={"2024-10-01-preview": ["filter", "skip", "top", "orderby"]},
859-
api_versions_list=["2024-03-01-preview", "2024-10-01-preview", "2025-09-01-preview", "2025-12-01-preview"],
859+
api_versions_list=[
860+
"2024-03-01-preview",
861+
"2024-10-01-preview",
862+
"2025-09-01-preview",
863+
"2025-12-01-preview",
864+
"2026-01-15-preview",
865+
],
860866
)
861867
def list(
862868
self,
@@ -1555,7 +1561,7 @@ async def get(
15551561
"accept",
15561562
]
15571563
},
1558-
api_versions_list=["2024-10-01-preview", "2025-09-01-preview", "2025-12-01-preview"],
1564+
api_versions_list=["2024-10-01-preview", "2025-09-01-preview", "2025-12-01-preview", "2026-01-15-preview"],
15591565
)
15601566
def listv2(
15611567
self,
@@ -1673,7 +1679,13 @@ async def get_next(next_link=None):
16731679
@distributed_trace
16741680
@api_version_validation(
16751681
params_added_on={"2024-10-01-preview": ["filter", "skip", "top", "orderby"]},
1676-
api_versions_list=["2024-03-01-preview", "2024-10-01-preview", "2025-09-01-preview", "2025-12-01-preview"],
1682+
api_versions_list=[
1683+
"2024-03-01-preview",
1684+
"2024-10-01-preview",
1685+
"2025-09-01-preview",
1686+
"2025-12-01-preview",
1687+
"2026-01-15-preview",
1688+
],
16771689
)
16781690
def jobs_list(
16791691
self,
@@ -1822,7 +1834,9 @@ async def get_sas_uri(
18221834
**kwargs: Any
18231835
) -> _models.SasUriResponse:
18241836
"""Gets a URL with SAS token for a container/blob in the storage account associated with the
1825-
workspace. The SAS URL can be used to upload job input and/or download job output.
1837+
workspace. Starting with version 2026-01-15-preview, when used for a container the container is
1838+
also created if it does not already exist. The SAS URL can be used to upload job input and/or
1839+
download job output.
18261840
18271841
:param subscription_id: The Azure subscription ID. Required.
18281842
:type subscription_id: str
@@ -1852,7 +1866,9 @@ async def get_sas_uri(
18521866
**kwargs: Any
18531867
) -> _models.SasUriResponse:
18541868
"""Gets a URL with SAS token for a container/blob in the storage account associated with the
1855-
workspace. The SAS URL can be used to upload job input and/or download job output.
1869+
workspace. Starting with version 2026-01-15-preview, when used for a container the container is
1870+
also created if it does not already exist. The SAS URL can be used to upload job input and/or
1871+
download job output.
18561872
18571873
:param subscription_id: The Azure subscription ID. Required.
18581874
:type subscription_id: str
@@ -1882,7 +1898,9 @@ async def get_sas_uri(
18821898
**kwargs: Any
18831899
) -> _models.SasUriResponse:
18841900
"""Gets a URL with SAS token for a container/blob in the storage account associated with the
1885-
workspace. The SAS URL can be used to upload job input and/or download job output.
1901+
workspace. Starting with version 2026-01-15-preview, when used for a container the container is
1902+
also created if it does not already exist. The SAS URL can be used to upload job input and/or
1903+
download job output.
18861904
18871905
:param subscription_id: The Azure subscription ID. Required.
18881906
:type subscription_id: str
@@ -1910,7 +1928,9 @@ async def get_sas_uri(
19101928
**kwargs: Any
19111929
) -> _models.SasUriResponse:
19121930
"""Gets a URL with SAS token for a container/blob in the storage account associated with the
1913-
workspace. The SAS URL can be used to upload job input and/or download job output.
1931+
workspace. Starting with version 2026-01-15-preview, when used for a container the container is
1932+
also created if it does not already exist. The SAS URL can be used to upload job input and/or
1933+
download job output.
19141934
19151935
:param subscription_id: The Azure subscription ID. Required.
19161936
:type subscription_id: str

azure-quantum/azure/quantum/_client/models/_enums.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
1414
"""The type of identity that created the item."""
1515

1616
USER = "User"
17-
"""The item is created by user"""
17+
"""The item is created by user."""
1818
APPLICATION = "Application"
19-
"""The item is created by application"""
19+
"""The item is created by application."""
2020
MANAGED_IDENTITY = "ManagedIdentity"
21-
"""The item is created using managed identity"""
21+
"""The item is created using managed identity."""
2222
KEY = "Key"
23-
"""The item is created using key"""
23+
"""The item is created using key."""
2424

2525

2626
class DimensionScope(str, Enum, metaclass=CaseInsensitiveEnumMeta):

0 commit comments

Comments
 (0)