damccorm commented on code in PR #30788:
URL: https://github.com/apache/beam/pull/30788#discussion_r1552164898


##########
sdks/python/apache_beam/examples/snippets/transforms/aggregation/batchelements_test.py:
##########
@@ -0,0 +1,49 @@
+# coding=utf-8
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+import unittest
+
+import mock
+from apache_beam.testing.test_pipeline import TestPipeline
+from apache_beam.testing.util import assert_that, equal_to
+
+from . import batchelements
+
+
+def check_batches(actual):
+  expected = [['🍓', '🥕', '🍆'], ['🍅', '🥕', '🍅'], ['🌽', '🥕', '🍅', '🍆']]

Review Comment:
   I'm a little bit skeptical of this test since the batches produced here are 
an implementation detail of how this is broken into bundles.
   
   Could we maybe instead check:
   
   1) That this does batching at all (returns lists, not strings)
   2) doesn't drop elements (if we pull them out of lists, and then count by 
element they return the correct counts)



##########
sdks/python/apache_beam/examples/snippets/transforms/aggregation/tolist_test.py:
##########
@@ -0,0 +1,47 @@
+# coding=utf-8
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+import mock
+import unittest
+
+from apache_beam.testing.test_pipeline import TestPipeline
+from apache_beam.testing.util import assert_that, equal_to
+
+from . import tolist
+
+
+def identity(x):
+  return x
+
+
[email protected]('apache_beam.Pipeline', TestPipeline)
+# pylint: disable=line-too-long
[email protected](
+    'apache_beam.examples.snippets.transforms.aggregation.tolist.print',
+    identity)
+# pylint: enable=line-too-long
+class BatchElementsTest(unittest.TestCase):
+  def test_tolist(self):
+    def check(result):
+      assert_that(result, equal_to([['🍓', '🥕', '🍆', '🍅']]))

Review Comment:
   Similarly, ordering isn't guaranteed here; could we try to test that it is a 
list and it contains all the correct elements?



##########
website/www/site/content/en/documentation/transforms/python/overview.md:
##########
@@ -48,13 +48,13 @@ limitations under the License.
 
 <table class="table-bordered table-striped">
   <tr><th>Transform</th><th>Description</th></tr>
-  <tr><td>ApproximateQuantiles</td><td>Not available. See <a 
href="https://issues.apache.org/jira/browse/BEAM-6694";>BEAM-6694</a> for 
updates.</td></tr>
-  <tr><td>ApproximateUnique</td><td>Not available. See <a 
href="https://issues.apache.org/jira/browse/BEAM-6693";>BEAM-6693</a> for 
updates.</td></tr>
+  <tr><td><a 
href="/documentation/transforms/python/aggregation/approximatequantiles">ApproximateQuantiles</a></td><td>Given
 a distribution, find the approximate N-tiles.</td></tr>
+  <tr><td><a 
href="/documentation/transforms/python/aggregation/approximateunique">ApproximateUnique</a></td><td>Given
 a pcollection, return the estimated number of unique elements.</td></tr>
+  <tr><td><a 
href="/documentation/transforms/python/aggregation/batchelements">BatchElements</a></td><td>Given
 a pcollection, return the estimated number of unique elements.</td></tr>

Review Comment:
   Thanks for catching these. Could we (a) also add ToList and (b) add these 
transforms to 
https://github.com/apache/beam/blob/21129a41e031c150c3f610639d71a95a3a941243/website/www/site/layouts/partials/section-menu/en/documentation.html#L324



##########
sdks/python/apache_beam/examples/snippets/transforms/aggregation/batchelements_test.py:
##########
@@ -0,0 +1,49 @@
+# coding=utf-8
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+import unittest
+
+import mock
+from apache_beam.testing.test_pipeline import TestPipeline
+from apache_beam.testing.util import assert_that, equal_to
+
+from . import batchelements
+
+
+def check_batches(actual):
+  expected = [['🍓', '🥕', '🍆'], ['🍅', '🥕', '🍅'], ['🌽', '🥕', '🍅', '🍆']]

Review Comment:
   BatchElements itself should have tests for the min/max size checks



##########
website/www/site/content/en/documentation/transforms/python/aggregation/approximatequantiles.md:
##########
@@ -17,7 +17,14 @@ limitations under the License.
 
 # ApproximateQuantiles
 
+{{< localstorage language language-py >}}
+
+{{< button-pydoc path="apache_beam.transforms.stat" 
class="ApproximateQuantile" >}}
+
 ## Examples
-See [Issue 19547](https://github.com/apache/beam/issues/19547) for updates.
+
+{{< playground height="700px" >}}
+{{< playground_snippet language="py" path="SDK_PYTHON_ApproximateQuantiles" 
show="approximatequantiles" >}}
+{{< /playground >}}

Review Comment:
   I think these won't render until the next playground release. So it may make 
sense to split this into 2 PRs, one for now and one for once the playground 
piece is released after 2.56



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to