anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: lithops-cloud/lithops
Issue: Delete for temp data fails when number of objects exceeds 1000

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pywren_ibm_cloud-1.0.1-py3.6.egg/pywren_ibm_cloud/storage/cleaner.py", line 33, in clean_bucket
    clean_os_bucket(bucket, prefix, internal_storage)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pywren_ibm_cloud-1.0.1-py3.6.egg/pywren_ibm_cloud/storage/cleaner.py", line 50, in clean_os_bucket
    internal_storage.delete_temporal_data(objects_to_delete)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pywren_ibm_cloud-1.0.1-py3.6.egg/pywren_ibm_cloud/storage/storage.py", line 167, in delete_temporal_data
    return self.backend_handler.delete_objects(self.storage_bucket, key_list)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pywren_ibm_cloud-1.0.1-py3.6.egg/pywren_ibm_cloud/storage/backends/cos.py", line 153, in delete_objects
    return self.cos_client.delete_objects(Bucket=bucket_name, Delete=delete_keys)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ibm_cos_sdk_core-2.3.3-py3.6.egg/ibm_botocore/client.py", line 255, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ibm_cos_sdk_core-2.3.3-py3.6.egg/ibm_botocore/client.py", line 545, in _make_api_call
    raise error_class(parsed_response, operation_name)
ibm_botocore.exceptions.ClientError: An error occurred (InvalidRequest) when calling the DeleteObjects operation: Maximum 1000 objects in request body exceeded


Changed files:
pywren/pywren_ibm_cloud/storage/backends/cos.py

diff --git a/pywren/pywren_ibm_cloud/storage/backends/cos.py b/pywren/pywren_ibm_cloud/storage/backends/cos.py
index 950cee62..c79053ee 100644
--- a/pywren/pywren_ibm_cloud/storage/backends/cos.py
+++ b/pywren/pywren_ibm_cloud/storage/backends/cos.py
@@ -148,9 +148,13 @@ class COSBackend(object):
         :param bucket: bucket name
         :param key_list: list of keys
         """
-        delete_keys = {'Objects' : []}
-        delete_keys['Objects'] = [{'Key' : k} for k in key_list]
-        return self.cos_client.delete_objects(Bucket=bucket_name, Delete=delete_keys)
+        result = []
+        max_keys_num = 1000
+        for i in range(0, len(key_list), max_keys_num):
+            delete_keys = {'Objects' : []}
+            delete_keys['Objects'] = [{'Key' : k} for k in key_list[i:i+max_keys_num]]
+            result.append(self.cos_client.delete_objects(Bucket=bucket_name, Delete=delete_keys))
+        return result
             
     def bucket_exists(self, bucket_name):
         """