beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From al...@apache.org
Subject [1/2] beam git commit: Respect type hints for IterableCoder
Date Wed, 22 Feb 2017 22:37:46 GMT
Repository: beam
Updated Branches:
  refs/heads/master e38a4803d -> 0f9fefe74


Respect type hints for IterableCoder


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

Branch: refs/heads/master
Commit: 37ff8835ef7bc0e988b1c3bbb5d71d7b025f63b2
Parents: e38a480
Author: Vikas Kedigehalli <vikasrk@google.com>
Authored: Tue Feb 21 21:50:48 2017 -0800
Committer: Ahmet Altay <altay@google.com>
Committed: Wed Feb 22 14:19:21 2017 -0800

----------------------------------------------------------------------
 sdks/python/apache_beam/coders/typecoders.py      | 6 +-----
 sdks/python/apache_beam/coders/typecoders_test.py | 7 +++++++
 2 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/37ff8835/sdks/python/apache_beam/coders/typecoders.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/coders/typecoders.py b/sdks/python/apache_beam/coders/typecoders.py
index 9bbfedf..767d791 100644
--- a/sdks/python/apache_beam/coders/typecoders.py
+++ b/sdks/python/apache_beam/coders/typecoders.py
@@ -117,11 +117,7 @@ class CoderRegistry(object):
             'Coder registry has no fallback coder. This can happen if the '
             'fast_coders module could not be imported.')
       if isinstance(typehint, typehints.IterableTypeConstraint):
-        # In this case, we suppress the warning message for using the fallback
-        # coder, since Iterable is hinted as the output of a GroupByKey
-        # operation and that direct output will not be coded.
-        # TODO(ccy): refine this behavior.
-        pass
+        return coders.IterableCoder.from_type_hint(typehint, self)
       elif typehint is None:
         # In some old code, None is used for Any.
         # TODO(robertwb): Clean this up.

http://git-wip-us.apache.org/repos/asf/beam/blob/37ff8835/sdks/python/apache_beam/coders/typecoders_test.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/coders/typecoders_test.py b/sdks/python/apache_beam/coders/typecoders_test.py
index 28c77af..2b6aa7a 100644
--- a/sdks/python/apache_beam/coders/typecoders_test.py
+++ b/sdks/python/apache_beam/coders/typecoders_test.py
@@ -112,6 +112,13 @@ class TypeCodersTest(unittest.TestCase):
         real_coder.encode('abc'), expected_coder.encode('abc'))
     self.assertEqual('abc', real_coder.decode(real_coder.encode('abc')))
 
+  def test_iterable_coder(self):
+    real_coder = typecoders.registry.get_coder(typehints.Iterable[str])
+    expected_coder = coders.IterableCoder(coders.BytesCoder())
+    values = ['abc', 'xyz']
+    self.assertEqual(expected_coder, real_coder)
+    self.assertEqual(real_coder.encode(values), expected_coder.encode(values))
+
 
 if __name__ == '__main__':
   unittest.main()


Mime
View raw message