Skip to content

Commit f713678

Browse files
[Storage] Remove batch delete files feature for GA release (Azure#23320)
1 parent 3acf56a commit f713678

11 files changed

+331
-3107
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ This version and all future versions will require Python 3.6+. Python 2.7 is no
66

77
### Stable release of preview features
88
- Added support for service version 2021-02-12.
9-
- Added support for batch deleting files using the `delete_files()` method from a `FileSystemClient`.
109
- Account level SAS tokens now supports two new permissions:
1110
- `permanent_delete`
1211
- `set_immutability_policy`
@@ -16,6 +15,10 @@ This version and all future versions will require Python 3.6+. Python 2.7 is no
1615
- Update `azure-core` dependency to avoid inconsistent dependencies from being installed.
1716
- Added all missing Service SAS permissions.
1817

18+
### Other Changes
19+
- Temporarily removed the preview `delete_files()` method on `FileSystemClient`. This feature will be added back
20+
in a future release.
21+
1922
## 12.6.0b2 (2021-12-13)
2023

2124
### Features Added

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

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# license information.
55
# --------------------------------------------------------------------------
66
import functools
7-
from typing import Optional, Any, Union, TypeVar, Iterator
7+
from typing import Optional, Any, Union, TypeVar
88

99
try:
1010
from urllib.parse import urlparse, quote, unquote
@@ -13,7 +13,6 @@
1313
from urllib2 import quote, unquote # type: ignore
1414
import six
1515

16-
from azure.core.pipeline.transport import HttpResponse
1716
from azure.core.pipeline import Pipeline
1817
from azure.core.exceptions import HttpResponseError
1918
from azure.core.paging import ItemPaged
@@ -814,70 +813,71 @@ def _get_root_directory_client(self):
814813
"""
815814
return self.get_directory_client('/')
816815

817-
def delete_files(self, *files, **kwargs):
818-
# type: (...) -> Iterator[HttpResponse]
819-
"""Marks the specified files or empty directories for deletion.
820-
821-
The files/empty directories are later deleted during garbage collection.
822-
823-
If a delete retention policy is enabled for the service, then this operation soft deletes the
824-
files/empty directories and retains the files or snapshots for specified number of days.
825-
After specified number of days, files' data is removed from the service during garbage collection.
826-
Soft deleted files/empty directories are accessible through :func:`list_deleted_paths()`.
827-
828-
:param files:
829-
The files/empty directories to delete. This can be a single file/empty directory, or multiple values can
830-
be supplied, where each value is either the name of the file/directory (str) or
831-
FileProperties/DirectoryProperties.
832-
833-
.. note::
834-
When the file/dir type is dict, here's a list of keys, value rules.
835-
836-
blob name:
837-
key: 'name', value type: str
838-
if the file modified or not:
839-
key: 'if_modified_since', 'if_unmodified_since', value type: datetime
840-
etag:
841-
key: 'etag', value type: str
842-
match the etag or not:
843-
key: 'match_condition', value type: MatchConditions
844-
lease:
845-
key: 'lease_id', value type: Union[str, LeaseClient]
846-
timeout for subrequest:
847-
key: 'timeout', value type: int
848-
849-
:type files: list[str], list[dict],
850-
or list[Union[~azure.storage.filedatalake.FileProperties, ~azure.storage.filedatalake.DirectoryProperties]
851-
:keyword ~datetime.datetime if_modified_since:
852-
A DateTime value. Azure expects the date value passed in to be UTC.
853-
If timezone is included, any non-UTC datetimes will be converted to UTC.
854-
If a date is passed in without timezone info, it is assumed to be UTC.
855-
Specify this header to perform the operation only
856-
if the resource has been modified since the specified time.
857-
:keyword ~datetime.datetime if_unmodified_since:
858-
A DateTime value. Azure expects the date value passed in to be UTC.
859-
If timezone is included, any non-UTC datetimes will be converted to UTC.
860-
If a date is passed in without timezone info, it is assumed to be UTC.
861-
Specify this header to perform the operation only if
862-
the resource has not been modified since the specified date/time.
863-
:keyword bool raise_on_any_failure:
864-
This is a boolean param which defaults to True. When this is set, an exception
865-
is raised even if there is a single operation failure.
866-
:keyword int timeout:
867-
The timeout parameter is expressed in seconds.
868-
:return: An iterator of responses, one for each blob in order
869-
:rtype: Iterator[~azure.core.pipeline.transport.HttpResponse]
870-
871-
.. admonition:: Example:
872-
873-
.. literalinclude:: ../samples/datalake_samples_file_system_async.py
874-
:start-after: [START batch_delete_files_or_empty_directories]
875-
:end-before: [END batch_delete_files_or_empty_directories]
876-
:language: python
877-
:dedent: 4
878-
:caption: Deleting multiple files or empty directories.
879-
"""
880-
return self._container_client.delete_blobs(*files, **kwargs)
816+
# TODO: Temporarily removing this for GA release.
817+
# def delete_files(self, *files, **kwargs):
818+
# # type: (...) -> Iterator[HttpResponse]
819+
# """Marks the specified files or empty directories for deletion.
820+
821+
# The files/empty directories are later deleted during garbage collection.
822+
823+
# If a delete retention policy is enabled for the service, then this operation soft deletes the
824+
# files/empty directories and retains the files or snapshots for specified number of days.
825+
# After specified number of days, files' data is removed from the service during garbage collection.
826+
# Soft deleted files/empty directories are accessible through :func:`list_deleted_paths()`.
827+
828+
# :param files:
829+
# The files/empty directories to delete. This can be a single file/empty directory, or multiple values can
830+
# be supplied, where each value is either the name of the file/directory (str) or
831+
# FileProperties/DirectoryProperties.
832+
833+
# .. note::
834+
# When the file/dir type is dict, here's a list of keys, value rules.
835+
836+
# blob name:
837+
# key: 'name', value type: str
838+
# if the file modified or not:
839+
# key: 'if_modified_since', 'if_unmodified_since', value type: datetime
840+
# etag:
841+
# key: 'etag', value type: str
842+
# match the etag or not:
843+
# key: 'match_condition', value type: MatchConditions
844+
# lease:
845+
# key: 'lease_id', value type: Union[str, LeaseClient]
846+
# timeout for subrequest:
847+
# key: 'timeout', value type: int
848+
849+
# :type files: list[str], list[dict],
850+
# or list[Union[~azure.storage.filedatalake.FileProperties, ~azure.storage.filedatalake.DirectoryProperties]
851+
# :keyword ~datetime.datetime if_modified_since:
852+
# A DateTime value. Azure expects the date value passed in to be UTC.
853+
# If timezone is included, any non-UTC datetimes will be converted to UTC.
854+
# If a date is passed in without timezone info, it is assumed to be UTC.
855+
# Specify this header to perform the operation only
856+
# if the resource has been modified since the specified time.
857+
# :keyword ~datetime.datetime if_unmodified_since:
858+
# A DateTime value. Azure expects the date value passed in to be UTC.
859+
# If timezone is included, any non-UTC datetimes will be converted to UTC.
860+
# If a date is passed in without timezone info, it is assumed to be UTC.
861+
# Specify this header to perform the operation only if
862+
# the resource has not been modified since the specified date/time.
863+
# :keyword bool raise_on_any_failure:
864+
# This is a boolean param which defaults to True. When this is set, an exception
865+
# is raised even if there is a single operation failure.
866+
# :keyword int timeout:
867+
# The timeout parameter is expressed in seconds.
868+
# :return: An iterator of responses, one for each blob in order
869+
# :rtype: Iterator[~azure.core.pipeline.transport.HttpResponse]
870+
871+
# .. admonition:: Example:
872+
873+
# .. literalinclude:: ../samples/datalake_samples_file_system_async.py
874+
# :start-after: [START batch_delete_files_or_empty_directories]
875+
# :end-before: [END batch_delete_files_or_empty_directories]
876+
# :language: python
877+
# :dedent: 4
878+
# :caption: Deleting multiple files or empty directories.
879+
# """
880+
# return self._container_client.delete_blobs(*files, **kwargs)
881881

882882
def get_directory_client(self, directory # type: Union[DirectoryProperties, str]
883883
):

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

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
# pylint: disable=invalid-overridden-method
88
import functools
99
from typing import ( # pylint: disable=unused-import
10-
Union, Optional, Any, Dict, TYPE_CHECKING,
11-
AsyncIterator)
12-
13-
from azure.core.pipeline.transport import AsyncHttpResponse
10+
Union, Optional, Any, Dict,
11+
TYPE_CHECKING
12+
)
1413

1514
from azure.core.exceptions import HttpResponseError
1615
from azure.core.tracing.decorator import distributed_trace
@@ -716,71 +715,72 @@ async def delete_file(self, file, # type: Union[FileProperties, str]
716715
await file_client.delete_file(**kwargs)
717716
return file_client
718717

719-
@distributed_trace_async
720-
async def delete_files(self, *files, **kwargs):
721-
# type: (...) -> AsyncIterator[AsyncHttpResponse]
722-
"""Marks the specified files or empty directories for deletion.
723-
724-
The files/empty directories are later deleted during garbage collection.
725-
726-
If a delete retention policy is enabled for the service, then this operation soft deletes the
727-
files/empty directories and retains the files or snapshots for specified number of days.
728-
After specified number of days, files' data is removed from the service during garbage collection.
729-
Soft deleted files/empty directories are accessible through :func:`list_deleted_paths()`.
730-
731-
:param files:
732-
The files/empty directories to delete. This can be a single file/empty directory, or multiple values can
733-
be supplied, where each value is either the name of the file/directory (str) or
734-
FileProperties/DirectoryProperties.
735-
736-
.. note::
737-
When the file/dir type is dict, here's a list of keys, value rules.
738-
739-
blob name:
740-
key: 'name', value type: str
741-
if the file modified or not:
742-
key: 'if_modified_since', 'if_unmodified_since', value type: datetime
743-
etag:
744-
key: 'etag', value type: str
745-
match the etag or not:
746-
key: 'match_condition', value type: MatchConditions
747-
lease:
748-
key: 'lease_id', value type: Union[str, LeaseClient]
749-
timeout for subrequest:
750-
key: 'timeout', value type: int
751-
752-
:type files: list[str], list[dict],
753-
or list[Union[~azure.storage.filedatalake.FileProperties, ~azure.storage.filedatalake.DirectoryProperties]
754-
:keyword ~datetime.datetime if_modified_since:
755-
A DateTime value. Azure expects the date value passed in to be UTC.
756-
If timezone is included, any non-UTC datetimes will be converted to UTC.
757-
If a date is passed in without timezone info, it is assumed to be UTC.
758-
Specify this header to perform the operation only
759-
if the resource has been modified since the specified time.
760-
:keyword ~datetime.datetime if_unmodified_since:
761-
A DateTime value. Azure expects the date value passed in to be UTC.
762-
If timezone is included, any non-UTC datetimes will be converted to UTC.
763-
If a date is passed in without timezone info, it is assumed to be UTC.
764-
Specify this header to perform the operation only if
765-
the resource has not been modified since the specified date/time.
766-
:keyword bool raise_on_any_failure:
767-
This is a boolean param which defaults to True. When this is set, an exception
768-
is raised even if there is a single operation failure.
769-
:keyword int timeout:
770-
The timeout parameter is expressed in seconds.
771-
:return: An iterator of responses, one for each blob in order
772-
:rtype: AsyncIterator[~azure.core.pipeline.transport.AsyncHttpResponse]
773-
774-
.. admonition:: Example:
775-
776-
.. literalinclude:: ../samples/datalake_samples_file_system_async.py
777-
:start-after: [START batch_delete_files_or_empty_directories]
778-
:end-before: [END batch_delete_files_or_empty_directories]
779-
:language: python
780-
:dedent: 4
781-
:caption: Deleting multiple files or empty directories.
782-
"""
783-
return await self._container_client.delete_blobs(*files, **kwargs)
718+
# TODO: Temporarily removing this for GA release.
719+
# @distributed_trace_async
720+
# async def delete_files(self, *files, **kwargs):
721+
# # type: (...) -> AsyncIterator[AsyncHttpResponse]
722+
# """Marks the specified files or empty directories for deletion.
723+
724+
# The files/empty directories are later deleted during garbage collection.
725+
726+
# If a delete retention policy is enabled for the service, then this operation soft deletes the
727+
# files/empty directories and retains the files or snapshots for specified number of days.
728+
# After specified number of days, files' data is removed from the service during garbage collection.
729+
# Soft deleted files/empty directories are accessible through :func:`list_deleted_paths()`.
730+
731+
# :param files:
732+
# The files/empty directories to delete. This can be a single file/empty directory, or multiple values can
733+
# be supplied, where each value is either the name of the file/directory (str) or
734+
# FileProperties/DirectoryProperties.
735+
736+
# .. note::
737+
# When the file/dir type is dict, here's a list of keys, value rules.
738+
739+
# blob name:
740+
# key: 'name', value type: str
741+
# if the file modified or not:
742+
# key: 'if_modified_since', 'if_unmodified_since', value type: datetime
743+
# etag:
744+
# key: 'etag', value type: str
745+
# match the etag or not:
746+
# key: 'match_condition', value type: MatchConditions
747+
# lease:
748+
# key: 'lease_id', value type: Union[str, LeaseClient]
749+
# timeout for subrequest:
750+
# key: 'timeout', value type: int
751+
752+
# :type files: list[str], list[dict],
753+
# or list[Union[~azure.storage.filedatalake.FileProperties, ~azure.storage.filedatalake.DirectoryProperties]
754+
# :keyword ~datetime.datetime if_modified_since:
755+
# A DateTime value. Azure expects the date value passed in to be UTC.
756+
# If timezone is included, any non-UTC datetimes will be converted to UTC.
757+
# If a date is passed in without timezone info, it is assumed to be UTC.
758+
# Specify this header to perform the operation only
759+
# if the resource has been modified since the specified time.
760+
# :keyword ~datetime.datetime if_unmodified_since:
761+
# A DateTime value. Azure expects the date value passed in to be UTC.
762+
# If timezone is included, any non-UTC datetimes will be converted to UTC.
763+
# If a date is passed in without timezone info, it is assumed to be UTC.
764+
# Specify this header to perform the operation only if
765+
# the resource has not been modified since the specified date/time.
766+
# :keyword bool raise_on_any_failure:
767+
# This is a boolean param which defaults to True. When this is set, an exception
768+
# is raised even if there is a single operation failure.
769+
# :keyword int timeout:
770+
# The timeout parameter is expressed in seconds.
771+
# :return: An iterator of responses, one for each blob in order
772+
# :rtype: AsyncIterator[~azure.core.pipeline.transport.AsyncHttpResponse]
773+
774+
# .. admonition:: Example:
775+
776+
# .. literalinclude:: ../samples/datalake_samples_file_system_async.py
777+
# :start-after: [START batch_delete_files_or_empty_directories]
778+
# :end-before: [END batch_delete_files_or_empty_directories]
779+
# :language: python
780+
# :dedent: 4
781+
# :caption: Deleting multiple files or empty directories.
782+
# """
783+
# return await self._container_client.delete_blobs(*files, **kwargs)
784784

785785
@distributed_trace_async
786786
async def _undelete_path(self, deleted_path_name, deletion_id, **kwargs):

sdk/storage/azure-storage-file-datalake/samples/datalake_samples_file_system.py

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -209,54 +209,6 @@ def create_file_from_file_system(self):
209209

210210
file_system_client.delete_file_system()
211211

212-
# [START batch_delete_files_or_empty_directories]
213-
def batch_delete_files_or_empty_directories(self):
214-
from azure.storage.filedatalake import FileSystemClient
215-
file_system_client = FileSystemClient.from_connection_string(self.connection_string, "filesystem")
216-
217-
file_system_client.create_file_system()
218-
219-
data = b'hello world'
220-
221-
try:
222-
# create file1
223-
file_system_client.get_file_client('file1').upload_data(data, overwrite=True)
224-
225-
# create file2, then pass file properties in batch delete later
226-
file2 = file_system_client.get_file_client('file2')
227-
file2.upload_data(data, overwrite=True)
228-
file2_properties = file2.get_file_properties()
229-
230-
# create file3 and batch delete it later only etag matches this file3 etag
231-
file3 = file_system_client.get_file_client('file3')
232-
file3.upload_data(data, overwrite=True)
233-
file3_etag = file3.get_file_properties().etag
234-
235-
# create dir1. Empty directory can be deleted using delete_files
236-
file_system_client.get_directory_client('dir1').create_directory(),
237-
238-
# create dir2, then pass directory properties in batch delete later
239-
dir2 = file_system_client.get_directory_client('dir2')
240-
dir2.create_directory()
241-
dir2_properties = dir2.get_directory_properties()
242-
except:
243-
pass
244-
245-
# Act
246-
response = file_system_client.delete_files(
247-
'file1',
248-
file2_properties,
249-
{'name': 'file3', 'etag': file3_etag},
250-
'dir1',
251-
dir2_properties,
252-
raise_on_any_failure=False
253-
)
254-
print("total number of sub-responses:" + len(response))
255-
print(response[0].status_code)
256-
print(response[2].status_code)
257-
print(response[3].status_code)
258-
# [END batch_delete_files_or_empty_directories]
259-
260212

261213
if __name__ == '__main__':
262214
sample = FileSystemSamples()
@@ -266,4 +218,3 @@ def batch_delete_files_or_empty_directories(self):
266218
sample.list_paths_in_file_system()
267219
sample.get_file_client_from_file_system()
268220
sample.create_file_from_file_system()
269-
sample.batch_delete_files_or_empty_directories()

0 commit comments

Comments
 (0)