You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by ro...@apache.org on 2017/10/12 22:54:50 UTC

[14/18] beam git commit: pr/cl-feedback from c-y-koo

pr/cl-feedback from c-y-koo


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

Branch: refs/heads/master
Commit: 3a04dbe46debc2c4aa188b210870a24dc1408bf1
Parents: 3b0ad58
Author: Holden Karau <ho...@us.ibm.com>
Authored: Tue Oct 10 12:31:16 2017 -0700
Committer: Robert Bradshaw <ro...@gmail.com>
Committed: Thu Oct 12 15:53:55 2017 -0700

----------------------------------------------------------------------
 .../apache_beam/examples/complete/game/leader_board.py    |  2 +-
 .../python/apache_beam/examples/cookbook/mergecontacts.py |  9 +++------
 sdks/python/apache_beam/examples/snippets/snippets.py     |  1 -
 .../runners/portability/maptask_executor_runner_test.py   |  2 +-
 sdks/python/apache_beam/transforms/ptransform_test.py     | 10 +++++-----
 5 files changed, 10 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/3a04dbe4/sdks/python/apache_beam/examples/complete/game/leader_board.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/examples/complete/game/leader_board.py b/sdks/python/apache_beam/examples/complete/game/leader_board.py
index a5bde05..e207f26 100644
--- a/sdks/python/apache_beam/examples/complete/game/leader_board.py
+++ b/sdks/python/apache_beam/examples/complete/game/leader_board.py
@@ -329,11 +329,11 @@ def run(argv=None):
              'processing_time': 'STRING',
          }))
 
-    # Get user scores and write the results to BigQuery
     def format_user_score_sums(user_score):
       (user, score) = user_score
       return {'user': user, 'total_score': score}
 
+    # Get user scores and write the results to BigQuery
     (events  # pylint: disable=expression-not-assigned
      | 'CalculateUserScores' >> CalculateUserScores(args.allowed_lateness)
      | 'FormatUserScoreSums' >> beam.Map(format_user_score_sums)

http://git-wip-us.apache.org/repos/asf/beam/blob/3a04dbe4/sdks/python/apache_beam/examples/cookbook/mergecontacts.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/examples/cookbook/mergecontacts.py b/sdks/python/apache_beam/examples/cookbook/mergecontacts.py
index b07b98d..237d4ca 100644
--- a/sdks/python/apache_beam/examples/cookbook/mergecontacts.py
+++ b/sdks/python/apache_beam/examples/cookbook/mergecontacts.py
@@ -118,12 +118,9 @@ def run(argv=None, assert_results=None):
       (_, (_, _, snailmail)) = name_email_phone_snailmail
       return not next(iter(snailmail), None)
 
-    luddites = grouped | beam.Filter(  # People without email.
-        without_email)
-    writers = grouped | beam.Filter(   # People without phones.
-        without_phones)
-    nomads = grouped | beam.Filter(    # People without addresses.
-        without_address)
+    luddites = grouped | beam.Filter(without_email) # People without email.
+    writers = grouped | beam.Filter(without_phones) # People without phones.
+    nomads = grouped | beam.Filter(without_address) # People without addresses.
 
     num_luddites = luddites | 'Luddites' >> beam.combiners.Count.Globally()
     num_writers = writers | 'Writers' >> beam.combiners.Count.Globally()

http://git-wip-us.apache.org/repos/asf/beam/blob/3a04dbe4/sdks/python/apache_beam/examples/snippets/snippets.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/examples/snippets/snippets.py b/sdks/python/apache_beam/examples/snippets/snippets.py
index 54abd8c..048b31a 100644
--- a/sdks/python/apache_beam/examples/snippets/snippets.py
+++ b/sdks/python/apache_beam/examples/snippets/snippets.py
@@ -1179,7 +1179,6 @@ def model_co_group_by_key_tuple(email_list, phone_list, output_path):
       return '%s; %s; %s' %\
         (name, sorted(info['emails']), sorted(info['phones']))
 
-
     contact_lines = result | beam.Map(join_info)
     # [END model_group_by_key_cogroupbykey_tuple]
     formatted_results | beam.io.WriteToText(output_path)

http://git-wip-us.apache.org/repos/asf/beam/blob/3a04dbe4/sdks/python/apache_beam/runners/portability/maptask_executor_runner_test.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/runners/portability/maptask_executor_runner_test.py b/sdks/python/apache_beam/runners/portability/maptask_executor_runner_test.py
index 4c0d3b3..0f8637f 100644
--- a/sdks/python/apache_beam/runners/portability/maptask_executor_runner_test.py
+++ b/sdks/python/apache_beam/runners/portability/maptask_executor_runner_test.py
@@ -152,7 +152,7 @@ class MapTaskExecutorRunnerTest(unittest.TestCase):
       derived = ((pcoll,) | beam.Flatten()
                  | beam.Map(lambda x: (x, x))
                  | beam.GroupByKey()
-                 | 'Unkey' >> beam.Map(lambda x__: x__[0]))
+                 | 'Unkey' >> beam.Map(lambda kv: kv[0]))
       assert_that(
           pcoll | beam.FlatMap(cross_product, AsList(derived)),
           equal_to([('a', 'a'), ('a', 'b'), ('b', 'a'), ('b', 'b')]))

http://git-wip-us.apache.org/repos/asf/beam/blob/3a04dbe4/sdks/python/apache_beam/transforms/ptransform_test.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/transforms/ptransform_test.py b/sdks/python/apache_beam/transforms/ptransform_test.py
index 0d2bb7a..dac2c4f 100644
--- a/sdks/python/apache_beam/transforms/ptransform_test.py
+++ b/sdks/python/apache_beam/transforms/ptransform_test.py
@@ -647,7 +647,7 @@ class PTransformTest(unittest.TestCase):
                 | beam.Flatten()
                 | beam.Map(lambda x: (x, None))
                 | beam.GroupByKey()
-                | beam.Map(lambda x__: x__[0]))
+                | beam.Map(lambda kv: kv[0]))
     self.assertEqual([1, 2, 3], sorted(([1, 2], [2, 3]) | DisjointUnion()))
 
   def test_apply_to_crazy_pvaluish(self):
@@ -1593,8 +1593,8 @@ class PTransformTypeCheckTestCase(TypeHintTestCase):
          | 'C' >> beam.Create(range(5)).with_output_types(int)
          | 'Mean' >> combine.Mean.Globally())
 
-    assert_that(d, equal_to([2.0]))
     self.assertEqual(float, d.element_type)
+    assert_that(d, equal_to([2.0]))
     self.p.run()
 
   def test_mean_globally_pipeline_checking_violated(self):
@@ -1616,8 +1616,8 @@ class PTransformTypeCheckTestCase(TypeHintTestCase):
          | 'C' >> beam.Create(range(5)).with_output_types(int)
          | 'Mean' >> combine.Mean.Globally())
 
-    assert_that(d, equal_to([2.0]))
     self.assertEqual(float, d.element_type)
+    assert_that(d, equal_to([2.0]))
     self.p.run()
 
   def test_mean_globally_runtime_checking_violated(self):
@@ -1709,8 +1709,8 @@ class PTransformTypeCheckTestCase(TypeHintTestCase):
          | 'P' >> beam.Create(range(5)).with_output_types(int)
          | 'CountInt' >> combine.Count.Globally())
 
-    assert_that(d, equal_to([5]))
     self.assertEqual(int, d.element_type)
+    assert_that(d, equal_to([5]))
     self.p.run()
 
   def test_count_globally_runtime_type_checking_satisfied(self):
@@ -1720,8 +1720,8 @@ class PTransformTypeCheckTestCase(TypeHintTestCase):
          | 'P' >> beam.Create(range(5)).with_output_types(int)
          | 'CountInt' >> combine.Count.Globally())
 
-    assert_that(d, equal_to([5]))
     self.assertEqual(int, d.element_type)
+    assert_that(d, equal_to([5]))
     self.p.run()
 
   def test_count_perkey_pipeline_type_checking_satisfied(self):