Skip to content

Commit 732d319

Browse files
authored
[DataLake][RecursiveAcl]Adopt AzureError change (Azure#14906)
* [DataLake][RecursiveAcl]Adopt AzureError change * add sample * address comments * parse StorageErrorException * use latest azure-core 1.9.0 as min-dependency * rename progress_callback in sample to progress_hook * update shared dependency * add python 3.9 as classifier
1 parent 82175dc commit 732d319

File tree

21 files changed

+132
-71
lines changed

21 files changed

+132
-71
lines changed

sdk/storage/azure-storage-blob/CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
# Release History
22

3-
## 12.6.0b2 (Unreleased)
3+
## 12.6.0 (2020-11-10)
4+
**Stable release of preview features**
5+
- Preview feature `ArrowDialect` as output format of `query_blob`
6+
- Preview feature `undelete_container` on BlobServiceClient.
7+
- Preview feature Last Access Time.
48

9+
**Fixes**
10+
- Fixed the expired Authorization token problem during retry (#14701, #14067)
11+
- Catch exceptions thrown by async download (#14319)
12+
13+
**Notes**
14+
- Updated dependency `azure-core` from azure-core<2.0.0,>=1.6.0 to azure-core<2.0.0,>=1.9.0 to get continuation_token attr on AzureError.
515

616
## 12.6.0b1 (2020-10-02)
717
**New features***

sdk/storage/azure-storage-blob/azure/storage/blob/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# license information.
55
# --------------------------------------------------------------------------
66

7-
VERSION = "12.6.0b2"
7+
VERSION = "12.6.0"

sdk/storage/azure-storage-blob/setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
author_email='ascl@microsoft.com',
7272
url='https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/storage/azure-storage-blob',
7373
classifiers=[
74-
"Development Status :: 4 - Beta",
74+
"Development Status :: 5 - Production/Stable",
7575
'Programming Language :: Python',
7676
'Programming Language :: Python :: 2',
7777
'Programming Language :: Python :: 2.7',
@@ -80,6 +80,7 @@
8080
'Programming Language :: Python :: 3.6',
8181
'Programming Language :: Python :: 3.7',
8282
'Programming Language :: Python :: 3.8',
83+
'Programming Language :: Python :: 3.9',
8384
'License :: OSI Approved :: MIT License',
8485
],
8586
zip_safe=False,
@@ -92,7 +93,7 @@
9293
'tests.common'
9394
]),
9495
install_requires=[
95-
"azure-core<2.0.0,>=1.6.0",
96+
"azure-core<2.0.0,>=1.9.0",
9697
"msrest>=0.6.10",
9798
"cryptography>=2.1.4"
9899
],

sdk/storage/azure-storage-file-datalake/CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# Release History
2-
## 12.2.0b2 (Unreleased)
2+
## 12.2.0 (2020-11-10)
3+
**Stable release of preview features**
4+
- Preview feature set/update/remove access control recursively.
5+
- Preview feature `set_file_expiry` on DataLakeFileClient.
6+
- Preview feature generating directory level sas.
37

8+
**Fixes**
9+
- Fixed session closure of filesystem (#14497)
10+
11+
**Notes**
12+
- Updated dependency `azure-core` from azure-core<2.0.0,>=1.6.0 to azure-core<2.0.0,>=1.9.0
413

514
## 12.2.0b1 (2020-10-02)
615
**New Features**

sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
ArrowDialect,
3333
ArrowType,
3434
DataLakeFileQueryError,
35-
DataLakeAclChangeFailedError,
3635
AccessControlChangeResult,
3736
AccessControlChangeCounters,
3837
AccessControlChangeFailure,
@@ -86,7 +85,6 @@
8685
'DelimitedTextDialect',
8786
'DelimitedJsonDialect',
8887
'DataLakeFileQueryError',
89-
'DataLakeAclChangeFailedError',
9088
'ArrowDialect',
9189
'ArrowType',
9290
'DataLakeFileQueryError'

sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_deserialize.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ def process_storage_error(storage_error):
140140
for name, info in additional_data.items():
141141
error_message += "\n{}:{}".format(name, info)
142142

143-
error = raise_error(message=error_message, response=storage_error.response)
143+
error = raise_error(message=error_message, response=storage_error.response,
144+
continuation_token=storage_error.continuation_token)
144145
error.error_code = error_code
145146
error.additional_info = additional_data
146147
raise error

sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_models.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -818,20 +818,3 @@ def __init__(self, batch_counters, aggregate_counters, batch_failures, continuat
818818
self.aggregate_counters = aggregate_counters
819819
self.batch_failures = batch_failures
820820
self.continuation = continuation
821-
822-
823-
class DataLakeAclChangeFailedError(Exception):
824-
"""The error happened during set/update/remove acl recursive operation.
825-
826-
:ivar ~azure.core.exceptions.AzureError error:
827-
The exception.
828-
:ivar str description:
829-
A description of the error.
830-
:ivar str continuation:
831-
An opaque continuation token that may be used to resume the operations in case of failures.
832-
"""
833-
834-
def __init__(self, error, description, continuation):
835-
self.error = error
836-
self.description = description
837-
self.continuation = continuation

sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from ._generated import DataLakeStorageClient
2020
from ._generated.models import StorageErrorException
2121
from ._models import LocationMode, DirectoryProperties, AccessControlChangeResult, AccessControlChanges, \
22-
AccessControlChangeCounters, AccessControlChangeFailure, DataLakeAclChangeFailedError
22+
AccessControlChangeCounters, AccessControlChangeFailure
2323
from ._serialize import convert_dfs_url_to_blob_url, get_mod_conditions, \
2424
get_path_http_headers, add_metadata_headers, get_lease_id, get_source_mod_conditions, get_access_conditions
2525
from ._shared.base_client import StorageAccountHostsMixin, parse_query
@@ -405,7 +405,7 @@ def _set_access_control_recursive_options(mode, acl, **kwargs):
405405
'mode': mode,
406406
'force_flag': kwargs.pop('continue_on_failure', None),
407407
'timeout': kwargs.pop('timeout', None),
408-
'continuation': kwargs.pop('continuation', None),
408+
'continuation': kwargs.pop('continuation_token', None),
409409
'max_records': kwargs.pop('batch_size', None),
410410
'acl': acl,
411411
'cls': return_headers_and_deserialized}
@@ -429,7 +429,7 @@ def set_access_control_recursive(self,
429429
:keyword func(~azure.storage.filedatalake.AccessControlChanges) progress_hook:
430430
Callback where the caller can track progress of the operation
431431
as well as collect paths that failed to change Access Control.
432-
:keyword str continuation:
432+
:keyword str continuation_token:
433433
Optional continuation token that can be used to resume previously stopped operation.
434434
:keyword int batch_size:
435435
Optional. If data set size exceeds batch size then operation will be split into multiple
@@ -451,6 +451,8 @@ def set_access_control_recursive(self,
451451
:return: A summary of the recursive operations, including the count of successes and failures,
452452
as well as a continuation token in case the operation was terminated prematurely.
453453
:rtype: :class:`~azure.storage.filedatalake.AccessControlChangeResult`
454+
:raises ~azure.core.exceptions.AzureError:
455+
User can restart the operation using continuation_token field of AzureError if the token is available.
454456
"""
455457
if not acl:
456458
raise ValueError("The Access Control List must be set for this operation")
@@ -478,7 +480,7 @@ def update_access_control_recursive(self,
478480
:keyword func(~azure.storage.filedatalake.AccessControlChanges) progress_hook:
479481
Callback where the caller can track progress of the operation
480482
as well as collect paths that failed to change Access Control.
481-
:keyword str continuation:
483+
:keyword str continuation_token:
482484
Optional continuation token that can be used to resume previously stopped operation.
483485
:keyword int batch_size:
484486
Optional. If data set size exceeds batch size then operation will be split into multiple
@@ -500,6 +502,8 @@ def update_access_control_recursive(self,
500502
:return: A summary of the recursive operations, including the count of successes and failures,
501503
as well as a continuation token in case the operation was terminated prematurely.
502504
:rtype: :class:`~azure.storage.filedatalake.AccessControlChangeResult`
505+
:raises ~azure.core.exceptions.AzureError:
506+
User can restart the operation using continuation_token field of AzureError if the token is available.
503507
"""
504508
if not acl:
505509
raise ValueError("The Access Control List must be set for this operation")
@@ -526,7 +530,7 @@ def remove_access_control_recursive(self,
526530
:keyword func(~azure.storage.filedatalake.AccessControlChanges) progress_hook:
527531
Callback where the caller can track progress of the operation
528532
as well as collect paths that failed to change Access Control.
529-
:keyword str continuation:
533+
:keyword str continuation_token:
530534
Optional continuation token that can be used to resume previously stopped operation.
531535
:keyword int batch_size:
532536
Optional. If data set size exceeds batch size then operation will be split into multiple
@@ -548,6 +552,8 @@ def remove_access_control_recursive(self,
548552
:return: A summary of the recursive operations, including the count of successes and failures,
549553
as well as a continuation token in case the operation was terminated prematurely.
550554
:rtype: :class:`~azure.storage.filedatalake.AccessControlChangeResult`
555+
:raises ~azure.core.exceptions.AzureError:
556+
User can restart the operation using continuation_token field of AzureError if the token is available.
551557
"""
552558
if not acl:
553559
raise ValueError("The Access Control List must be set for this operation")
@@ -613,8 +619,12 @@ def _set_access_control_internal(self, options, progress_hook, max_batches=None)
613619
failure_count=total_failure_count),
614620
continuation=last_continuation_token
615621
if total_failure_count > 0 and not continue_on_failure else current_continuation_token)
622+
except StorageErrorException as error:
623+
error.continuation_token = last_continuation_token
624+
process_storage_error(error)
616625
except AzureError as error:
617-
raise DataLakeAclChangeFailedError(error, error.message, last_continuation_token)
626+
error.continuation_token = last_continuation_token
627+
raise error
618628

619629
def _rename_path_options(self, rename_source, content_settings=None, metadata=None, **kwargs):
620630
# type: (Optional[ContentSettings], Optional[Dict[str, str]], **Any) -> Dict[str, Any]

sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# license information.
55
# --------------------------------------------------------------------------
66

7-
VERSION = "12.2.0b2"
7+
VERSION = "12.2.0"

sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_path_client_async.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from .._shared.base_client_async import AsyncStorageAccountHostsMixin
1010
from .._path_client import PathClient as PathClientBase
1111
from .._models import DirectoryProperties, AccessControlChangeResult, AccessControlChangeFailure, \
12-
AccessControlChangeCounters, AccessControlChanges, DataLakeAclChangeFailedError
12+
AccessControlChangeCounters, AccessControlChanges
1313
from .._generated.aio import DataLakeStorageClient
1414
from ._data_lake_lease_async import DataLakeLeaseClient
1515
from .._generated.models import StorageErrorException
@@ -292,7 +292,7 @@ async def set_access_control_recursive(self,
292292
:keyword func(~azure.storage.filedatalake.AccessControlChanges) progress_hook:
293293
Callback where the caller can track progress of the operation
294294
as well as collect paths that failed to change Access Control.
295-
:keyword str continuation:
295+
:keyword str continuation_token:
296296
Optional continuation token that can be used to resume previously stopped operation.
297297
:keyword int batch_size:
298298
Optional. If data set size exceeds batch size then operation will be split into multiple
@@ -314,6 +314,8 @@ async def set_access_control_recursive(self,
314314
:return: A summary of the recursive operations, including the count of successes and failures,
315315
as well as a continuation token in case the operation was terminated prematurely.
316316
:rtype: :~azure.storage.filedatalake.AccessControlChangeResult`
317+
:raises ~azure.core.exceptions.AzureError:
318+
User can restart the operation using continuation_token field of AzureError if the token is available.
317319
"""
318320
if not acl:
319321
raise ValueError("The Access Control List must be set for this operation")
@@ -339,7 +341,7 @@ async def update_access_control_recursive(self, acl, **kwargs):
339341
:keyword func(~azure.storage.filedatalake.AccessControlChanges) progress_hook:
340342
Callback where the caller can track progress of the operation
341343
as well as collect paths that failed to change Access Control.
342-
:keyword str continuation:
344+
:keyword str continuation_token:
343345
Optional continuation token that can be used to resume previously stopped operation.
344346
:keyword int batch_size:
345347
Optional. If data set size exceeds batch size then operation will be split into multiple
@@ -362,6 +364,8 @@ async def update_access_control_recursive(self, acl, **kwargs):
362364
:return: A summary of the recursive operations, including the count of successes and failures,
363365
as well as a continuation token in case the operation was terminated prematurely.
364366
:rtype: :~azure.storage.filedatalake.AccessControlChangeResult`
367+
:raises ~azure.core.exceptions.AzureError:
368+
User can restart the operation using continuation_token field of AzureError if the token is available.
365369
"""
366370
if not acl:
367371
raise ValueError("The Access Control List must be set for this operation")
@@ -388,7 +392,7 @@ async def remove_access_control_recursive(self,
388392
:keyword func(~azure.storage.filedatalake.AccessControlChanges) progress_hook:
389393
Callback where the caller can track progress of the operation
390394
as well as collect paths that failed to change Access Control.
391-
:keyword str continuation:
395+
:keyword str continuation_token:
392396
Optional continuation token that can be used to resume previously stopped operation.
393397
:keyword int batch_size:
394398
Optional. If data set size exceeds batch size then operation will be split into multiple
@@ -410,6 +414,8 @@ async def remove_access_control_recursive(self,
410414
:return: A summary of the recursive operations, including the count of successes and failures,
411415
as well as a continuation token in case the operation was terminated prematurely.
412416
:rtype: :~azure.storage.filedatalake.AccessControlChangeResult`
417+
:raises ~azure.core.exceptions.AzureError:
418+
User can restart the operation using continuation_token field of AzureError if the token is available.
413419
"""
414420
if not acl:
415421
raise ValueError("The Access Control List must be set for this operation")
@@ -475,8 +481,12 @@ async def _set_access_control_internal(self, options, progress_hook, max_batches
475481
failure_count=total_failure_count),
476482
continuation=last_continuation_token
477483
if total_failure_count > 0 and not continue_on_failure else current_continuation_token)
484+
except StorageErrorException as error:
485+
error.continuation_token = last_continuation_token
486+
process_storage_error(error)
478487
except AzureError as error:
479-
raise DataLakeAclChangeFailedError(error, error.message, last_continuation_token)
488+
error.continuation_token = last_continuation_token
489+
raise error
480490

481491
async def _rename_path(self, rename_source,
482492
**kwargs):

0 commit comments

Comments
 (0)