You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by al...@apache.org on 2017/02/22 22:37:46 UTC
[1/2] beam git commit: Respect type hints for IterableCoder
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 <vi...@google.com>
Authored: Tue Feb 21 21:50:48 2017 -0800
Committer: Ahmet Altay <al...@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()
[2/2] beam git commit: This closes #2068
Posted by al...@apache.org.
This closes #2068
Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/0f9fefe7
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/0f9fefe7
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/0f9fefe7
Branch: refs/heads/master
Commit: 0f9fefe74d84d6a9e24268a1fba04daf74a5687a
Parents: e38a480 37ff883
Author: Ahmet Altay <al...@google.com>
Authored: Wed Feb 22 14:19:36 2017 -0800
Committer: Ahmet Altay <al...@google.com>
Committed: Wed Feb 22 14:19:36 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(-)
----------------------------------------------------------------------