Skip to content

Commit 8978c80

Browse files
lostluckshunping
andauthored
Support dict as the input of delete_batch (#30241)
This smooths the code path of feeding output of list_prefix() to delete_batch(). Co-authored-by: Shunping Huang <shunping@google.com>
1 parent 435eab3 commit 8978c80

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

sdks/python/apache_beam/io/gcp/gcsio.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ def delete_batch(self, paths):
208208
"""Deletes the objects at the given GCS paths.
209209
210210
Args:
211-
paths: List of GCS file path patterns in the form gs://<bucket>/<name>,
211+
paths: List of GCS file path patterns or Dict with GCS file path patterns
212+
as keys. The patterns are in the form gs://<bucket>/<name>, but
212213
not to exceed MAX_BATCH_OPERATION_SIZE in length.
213214
214215
Returns: List of tuples of (path, exception) in the same order as the
@@ -217,6 +218,7 @@ def delete_batch(self, paths):
217218
"""
218219
final_results = []
219220
s = 0
221+
if not isinstance(paths, list): paths = list(iter(paths))
220222
while s < len(paths):
221223
if (s + MAX_BATCH_OPERATION_SIZE) < len(paths):
222224
current_paths = paths[s:s + MAX_BATCH_OPERATION_SIZE]

0 commit comments

Comments
 (0)