Skip to content

Commit 737adb2

Browse files
authored
[EventHub] update checkpointstoreblob vendored storage for lint/typing changes (Azure#38757)
* update changelog * update sync blob vendor * update async ckpt blob vendor * update async ckpt blob changelog * added vendored storage deps to setup.py * cp over latest storage updates
1 parent bf50574 commit 737adb2

File tree

167 files changed

+67067
-41455
lines changed

Some content is hidden

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

167 files changed

+67067
-41455
lines changed

.vscode/cspell.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@
9898
"sdk/translation/azure-ai-translation-document/doc/**",
9999
"sdk/translation/azure-ai-translation-document/tests/glossaries-valid.csv",
100100
"sdk/storage/azure-storage-blob/**",
101+
"sdk/eventhub/azure-eventhub-checkpointstoreblob/azure/eventhub/extensions/checkpointstoreblob/_vendor/**",
102+
"sdk/eventhub/azure-eventhub-checkpointstoreblob-aio/azure/eventhub/extensions/checkpointstoreblobaio/_vendor/**",
101103
"sdk/storage/azure-storage-extensions/**",
102104
"sdk/ml/azure-ai-ml/azure/ai/ml/_restclient/**",
103105
"sdk/ml/azure-ai-ml/azure/ai/ml/_utils/_virtual_cluster_utils/_restclient/**",

sdk/eventhub/azure-eventhub-checkpointstoreblob-aio/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ This version and all future versions will require Python 3.7+. Python 2.7 and 3.
1111
- Fixed a bug with `BlobCheckpointStore.claim_ownership` mutating the `ownership_list` argument to no longer mutate the argument.
1212
- Updated `azure-core` dependecy to 1.20.1 to fix `cchardet` ImportError.
1313

14+
### Other Changes
15+
16+
- Updated vendor azure-storage-blob dependency to v12.24.0.
17+
- Fixed typing/linting issues and other bugs. See azure-storage-blob CHANGELOG.md for more info.
18+
1419
## 1.1.4 (2021-04-07)
1520

1621
This version and all future versions will require Python 2.7 or Python 3.6+, Python 3.5 is no longer supported.
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: str
1+
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: str
1+
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore

sdk/eventhub/azure-eventhub-checkpointstoreblob-aio/azure/eventhub/extensions/checkpointstoreblobaio/_vendor/storage/blob/__init__.py

Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
# Licensed under the MIT License. See License.txt in the project root for
44
# license information.
55
# --------------------------------------------------------------------------
6+
# pylint: disable=docstring-keyword-should-match-keyword-only
7+
68
import os
79

8-
from typing import Union, Iterable, AnyStr, IO, Any, Dict # pylint: disable=unused-import
10+
from typing import Any, AnyStr, cast, Dict, IO, Iterable, Optional, Union, TYPE_CHECKING
911
from ._version import VERSION
1012
from ._blob_client import BlobClient
1113
from ._container_client import ContainerClient
@@ -16,21 +18,21 @@
1618
from ._shared_access_signature import generate_account_sas, generate_container_sas, generate_blob_sas
1719
from ._shared.policies import ExponentialRetry, LinearRetry
1820
from ._shared.response_handlers import PartialBatchErrorException
19-
from ._shared.models import(
21+
from ._shared.models import (
2022
LocationMode,
2123
ResourceTypes,
2224
AccountSasPermissions,
2325
StorageErrorCode,
24-
UserDelegationKey
25-
)
26-
from ._generated.models import (
27-
RehydratePriority
26+
UserDelegationKey,
27+
Services
2828
)
29+
from ._generated.models import RehydratePriority
2930
from ._models import (
3031
BlobType,
3132
BlockState,
3233
StandardBlobTier,
3334
PremiumPageBlobTier,
35+
BlobImmutabilityPolicyMode,
3436
SequenceNumberAction,
3537
PublicAccess,
3638
BlobAnalyticsLogging,
@@ -54,22 +56,27 @@
5456
BlobQueryError,
5557
DelimitedJsonDialect,
5658
DelimitedTextDialect,
59+
QuickQueryDialect,
5760
ArrowDialect,
5861
ArrowType,
5962
ObjectReplicationPolicy,
60-
ObjectReplicationRule
63+
ObjectReplicationRule,
64+
ImmutabilityPolicy,
6165
)
6266
from ._list_blobs_helper import BlobPrefix
6367

68+
if TYPE_CHECKING:
69+
from azure.core.credentials import AzureNamedKeyCredential, AzureSasCredential, TokenCredential
70+
6471
__version__ = VERSION
6572

6673

6774
def upload_blob_to_url(
68-
blob_url, # type: str
69-
data, # type: Union[Iterable[AnyStr], IO[AnyStr]]
70-
credential=None, # type: Any
71-
**kwargs):
72-
# type: (...) -> Dict[str, Any]
75+
blob_url: str,
76+
data: Union[Iterable[AnyStr], IO[AnyStr]],
77+
credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
78+
**kwargs: Any
79+
) -> Dict[str, Any]:
7380
"""Upload data to a given URL
7481
7582
The data will be uploaded as a block blob.
@@ -82,10 +89,17 @@ def upload_blob_to_url(
8289
:param credential:
8390
The credentials with which to authenticate. This is optional if the
8491
blob URL already has a SAS token. The value can be a SAS token string,
85-
an instance of a AzureSasCredential from azure.core.credentials, an account
86-
shared access key, or an instance of a TokenCredentials class from azure.identity.
92+
an instance of a AzureSasCredential or AzureNamedKeyCredential from azure.core.credentials,
93+
an account shared access key, or an instance of a TokenCredentials class from azure.identity.
8794
If the resource URI already contains a SAS token, this will be ignored in favor of an explicit credential
8895
- except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError.
96+
If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key"
97+
should be the storage account key.
98+
:type credential:
99+
~azure.core.credentials.AzureNamedKeyCredential or
100+
~azure.core.credentials.AzureSasCredential or
101+
~azure.core.credentials.TokenCredential or
102+
str or dict[str, str] or None
89103
:keyword bool overwrite:
90104
Whether the blob to be uploaded should overwrite the current data.
91105
If True, upload_blob_to_url will overwrite any existing data. If set to False, the
@@ -112,21 +126,26 @@ def upload_blob_to_url(
112126
:rtype: dict(str, Any)
113127
"""
114128
with BlobClient.from_blob_url(blob_url, credential=credential) as client:
115-
return client.upload_blob(data=data, blob_type=BlobType.BlockBlob, **kwargs)
129+
return cast(BlobClient, client).upload_blob(data=data, blob_type=BlobType.BLOCKBLOB, **kwargs)
116130

117131

118-
def _download_to_stream(client, handle, **kwargs):
119-
"""Download data to specified open file-handle."""
132+
def _download_to_stream(client: BlobClient, handle: IO[bytes], **kwargs: Any) -> None:
133+
"""
134+
Download data to specified open file-handle.
135+
136+
:param BlobClient client: The BlobClient to download with.
137+
:param Stream handle: A Stream to download the data into.
138+
"""
120139
stream = client.download_blob(**kwargs)
121140
stream.readinto(handle)
122141

123142

124143
def download_blob_from_url(
125-
blob_url, # type: str
126-
output, # type: str
127-
credential=None, # type: Any
128-
**kwargs):
129-
# type: (...) -> None
144+
blob_url: str,
145+
output: Union[str, IO[bytes]],
146+
credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
147+
**kwargs: Any
148+
) -> None:
130149
"""Download the contents of a blob to a local file or stream.
131150
132151
:param str blob_url:
@@ -138,10 +157,17 @@ def download_blob_from_url(
138157
:param credential:
139158
The credentials with which to authenticate. This is optional if the
140159
blob URL already has a SAS token or the blob is public. The value can be a SAS token string,
141-
an instance of a AzureSasCredential from azure.core.credentials,
160+
an instance of a AzureSasCredential or AzureNamedKeyCredential from azure.core.credentials,
142161
an account shared access key, or an instance of a TokenCredentials class from azure.identity.
143162
If the resource URI already contains a SAS token, this will be ignored in favor of an explicit credential
144163
- except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError.
164+
If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key"
165+
should be the storage account key.
166+
:type credential:
167+
~azure.core.credentials.AzureNamedKeyCredential or
168+
~azure.core.credentials.AzureSasCredential or
169+
~azure.core.credentials.TokenCredential or
170+
str or dict[str, str] or None
145171
:keyword bool overwrite:
146172
Whether the local file should be overwritten if it already exists. The default value is
147173
`False` - in which case a ValueError will be raised if the file already exists. If set to
@@ -169,10 +195,10 @@ def download_blob_from_url(
169195
overwrite = kwargs.pop('overwrite', False)
170196
with BlobClient.from_blob_url(blob_url, credential=credential) as client:
171197
if hasattr(output, 'write'):
172-
_download_to_stream(client, output, **kwargs)
198+
_download_to_stream(client, cast(IO[bytes], output), **kwargs)
173199
else:
174200
if not overwrite and os.path.isfile(output):
175-
raise ValueError("The file '{}' already exists.".format(output))
201+
raise ValueError(f"The file '{output}' already exists.")
176202
with open(output, 'wb') as file_handle:
177203
_download_to_stream(client, file_handle, **kwargs)
178204

@@ -194,6 +220,8 @@ def download_blob_from_url(
194220
'StandardBlobTier',
195221
'PremiumPageBlobTier',
196222
'SequenceNumberAction',
223+
'BlobImmutabilityPolicyMode',
224+
'ImmutabilityPolicy',
197225
'PublicAccess',
198226
'BlobAnalyticsLogging',
199227
'Metrics',
@@ -210,6 +238,7 @@ def download_blob_from_url(
210238
'BlobBlock',
211239
'PageRange',
212240
'AccessPolicy',
241+
'QuickQueryDialect',
213242
'ContainerSasPermissions',
214243
'BlobSasPermissions',
215244
'ResourceTypes',
@@ -229,5 +258,6 @@ def download_blob_from_url(
229258
'ArrowType',
230259
'BlobQueryReader',
231260
'ObjectReplicationPolicy',
232-
'ObjectReplicationRule'
261+
'ObjectReplicationRule',
262+
'Services',
233263
]

0 commit comments

Comments
 (0)