Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cherry Pick #30188] gcsio: support dict as the input of delete_batch #30241

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Support dict as the input of delete_batch
This smooths the code path of feeding output of list_prefix()
to delete_batch().
  • Loading branch information
shunping authored and lostluck committed Feb 6, 2024
commit 768a4a8ae5d5af87df5b7b4753da590f24f83861
4 changes: 3 additions & 1 deletion sdks/python/apache_beam/io/gcp/gcsio.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ def delete_batch(self, paths):
"""Deletes the objects at the given GCS paths.
Args:
paths: List of GCS file path patterns in the form gs://<bucket>/<name>,
paths: List of GCS file path patterns or Dict with GCS file path patterns
as keys. The patterns are in the form gs://<bucket>/<name>, but
not to exceed MAX_BATCH_OPERATION_SIZE in length.
Returns: List of tuples of (path, exception) in the same order as the
Expand All @@ -217,6 +218,7 @@ def delete_batch(self, paths):
"""
final_results = []
s = 0
if not isinstance(paths, list): paths = list(iter(paths))
while s < len(paths):
if (s + MAX_BATCH_OPERATION_SIZE) < len(paths):
current_paths = paths[s:s + MAX_BATCH_OPERATION_SIZE]
Expand Down
Loading