beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rober...@apache.org
Subject [1/2] incubator-beam git commit: Handle empty batches in GcsIO batch methods
Date Thu, 08 Dec 2016 19:19:00 GMT
Repository: incubator-beam
Updated Branches:
  refs/heads/python-sdk 75be6e974 -> 1392f70b6


Handle empty batches in GcsIO batch methods


Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/3ef83b33
Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/3ef83b33
Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/3ef83b33

Branch: refs/heads/python-sdk
Commit: 3ef83b3396a4574b3283b29ba1f878b31badd612
Parents: 75be6e9
Author: Charles Chen <ccy@google.com>
Authored: Wed Dec 7 15:03:01 2016 -0800
Committer: Robert Bradshaw <robertwb@google.com>
Committed: Thu Dec 8 11:18:51 2016 -0800

----------------------------------------------------------------------
 sdks/python/apache_beam/io/gcsio.py      | 4 ++++
 sdks/python/apache_beam/io/gcsio_test.py | 4 ++++
 2 files changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/3ef83b33/sdks/python/apache_beam/io/gcsio.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/io/gcsio.py b/sdks/python/apache_beam/io/gcsio.py
index 748465f..f150c4c 100644
--- a/sdks/python/apache_beam/io/gcsio.py
+++ b/sdks/python/apache_beam/io/gcsio.py
@@ -204,6 +204,8 @@ class GcsIO(object):
              argument, where exception is None if the operation succeeded or
              the relevant exception if the operation failed.
     """
+    if not paths:
+      return []
     batch_request = BatchApiRequest(
         retryable_codes=retry.SERVER_ERROR_OR_TIMEOUT_CODES)
     for path in paths:
@@ -264,6 +266,8 @@ class GcsIO(object):
              src_dest_pairs argument, where exception is None if the operation
              succeeded or the relevant exception if the operation failed.
     """
+    if not src_dest_pairs:
+      return []
     batch_request = BatchApiRequest(
         retryable_codes=retry.SERVER_ERROR_OR_TIMEOUT_CODES)
     for src, dest in src_dest_pairs:

http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/3ef83b33/sdks/python/apache_beam/io/gcsio_test.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/io/gcsio_test.py b/sdks/python/apache_beam/io/gcsio_test.py
index 5af13c6..bd7eb51 100644
--- a/sdks/python/apache_beam/io/gcsio_test.py
+++ b/sdks/python/apache_beam/io/gcsio_test.py
@@ -265,6 +265,10 @@ class TestGCSIO(unittest.TestCase):
     with self.assertRaises(ValueError):
       self.gcs.open(file_name, 'r+b')
 
+  def test_empty_batches(self):
+    self.assertEqual([], self.gcs.copy_batch([]))
+    self.assertEqual([], self.gcs.delete_batch([]))
+
   def test_delete(self):
     file_name = 'gs://gcsio-test/delete_me'
     file_size = 1024


Mime
View raw message