This is an automated email from the ASF dual-hosted git repository.

yhu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 561bf2f07e1 Fix playground examples (#31647)
561bf2f07e1 is described below

commit 561bf2f07e15719e9d698d2d57455e050246105e
Author: Vitaly Terentyev <vitaly.terent...@akvelon.com>
AuthorDate: Wed Jun 19 18:45:30 2024 +0400

    Fix playground examples (#31647)
---
 .../Core Transforms/GroupByKey/GroupByKey/task.py    | 20 ++++++++++++--------
 .../transforms/aggregation/approximatequantiles.py   |  4 ++--
 .../transforms/aggregation/approximateunique.py      |  2 +-
 .../python/aggregation/approximatequantiles.md       |  6 +++++-
 .../python/aggregation/approximateunique.md          |  7 ++++++-
 .../transforms/python/aggregation/batchelements.md   |  5 ++++-
 .../transforms/python/aggregation/count.md           |  2 +-
 .../transforms/python/aggregation/groupbykey.md      |  2 +-
 .../transforms/python/aggregation/tolist.md          | 10 ++++++++--
 .../en/documentation/transforms/python/overview.md   |  2 +-
 .../partials/section-menu/en/documentation.html      |  1 +
 11 files changed, 42 insertions(+), 19 deletions(-)

diff --git a/learning/katas/python/Core 
Transforms/GroupByKey/GroupByKey/task.py b/learning/katas/python/Core 
Transforms/GroupByKey/GroupByKey/task.py
index 2832de39cad..0d1308bd227 100644
--- a/learning/katas/python/Core Transforms/GroupByKey/GroupByKey/task.py       
+++ b/learning/katas/python/Core Transforms/GroupByKey/GroupByKey/task.py       
@@ -27,13 +27,17 @@
 #     - group
 #     - strings
 
-# [START groupbykey]
-import apache_beam as beam
+def groupbykey():
+  # [START groupbykey]
+  import apache_beam as beam
 
-with beam.Pipeline() as p:
+  with beam.Pipeline() as p:
 
-  (p | beam.Create(['apple', 'ball', 'car', 'bear', 'cheetah', 'ant'])
-     | beam.Map(lambda word: (word[0], word))
-     | beam.GroupByKey()
-     | beam.LogElements())
-# [END groupbykey]
+    (p | beam.Create(['apple', 'ball', 'car', 'bear', 'cheetah', 'ant'])
+       | beam.Map(lambda word: (word[0], word))
+       | beam.GroupByKey()
+       | beam.LogElements())
+  # [END groupbykey]
+
+if __name__ == '__main__':
+  groupbykey()
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/approximatequantiles.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/approximatequantiles.py
index ec93563928d..bb3f413a5c9 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/approximatequantiles.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/approximatequantiles.py
@@ -20,7 +20,7 @@
 # pylint:disable=line-too-long
 
 # beam-playground:
-#   name: AppromximateQuantiles
+#   name: ApproximateQuantiles
 #   description: Demonstration of ApproximateQuantiles transform usage.
 #   multifile: false
 #   default_example: false
@@ -34,7 +34,7 @@
 
 
 def approximatequantiles(test=None):
-  # [START quantiles]
+  # [START approximatequantiles]
   import apache_beam as beam
 
   with beam.Pipeline() as pipeline:
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/approximateunique.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/approximateunique.py
index 2bd0afcdb10..120129f9955 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/approximateunique.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/approximateunique.py
@@ -20,7 +20,7 @@
 # pylint:disable=line-too-long
 
 # beam-playground:
-#   name: AppromximateUnique
+#   name: ApproximateUnique
 #   description: Demonstration of ApproximateUnique transform usage.
 #   multifile: false
 #   default_example: false
diff --git 
a/website/www/site/content/en/documentation/transforms/python/aggregation/approximatequantiles.md
 
b/website/www/site/content/en/documentation/transforms/python/aggregation/approximatequantiles.md
index 95f66490f5e..2c186408706 100644
--- 
a/website/www/site/content/en/documentation/transforms/python/aggregation/approximatequantiles.md
+++ 
b/website/www/site/content/en/documentation/transforms/python/aggregation/approximatequantiles.md
@@ -19,7 +19,7 @@ limitations under the License.
 
 {{< localstorage language language-py >}}
 
-{{< button-pydoc path="apache_beam.transforms.stat" 
class="ApproximateQuantile" >}}
+{{< button-pydoc path="apache_beam.transforms.stats" 
class="ApproximateQuantiles" >}}
 
 ## Examples
 
@@ -28,3 +28,7 @@ limitations under the License.
 {{< /playground >}}
 
 ## Related transforms
+
+N/A
+
+{{< button-pydoc path="apache_beam.transforms.stats" 
class="ApproximateQuantiles" >}}
diff --git 
a/website/www/site/content/en/documentation/transforms/python/aggregation/approximateunique.md
 
b/website/www/site/content/en/documentation/transforms/python/aggregation/approximateunique.md
index dae287198fe..242c27d6c1d 100644
--- 
a/website/www/site/content/en/documentation/transforms/python/aggregation/approximateunique.md
+++ 
b/website/www/site/content/en/documentation/transforms/python/aggregation/approximateunique.md
@@ -14,11 +14,12 @@ 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.
 -->
+
 # ApproximateUnique
 
 {{< localstorage language language-py >}}
 
-{{< button-pydoc path="apache_beam.transforms.stat" class="ApproximateUnique" 
>}}
+{{< button-pydoc path="apache_beam.transforms.stats" class="ApproximateUnique" 
>}}
 
 ## Examples
 
@@ -27,3 +28,7 @@ limitations under the License.
 {{< /playground >}}
 
 ## Related transforms
+
+N/A
+
+{{< button-pydoc path="apache_beam.transforms.stats" class="ApproximateUnique" 
>}}
diff --git 
a/website/www/site/content/en/documentation/transforms/python/aggregation/batchelements.md
 
b/website/www/site/content/en/documentation/transforms/python/aggregation/batchelements.md
index c9d6a7ac6d0..8edf83f8a71 100644
--- 
a/website/www/site/content/en/documentation/transforms/python/aggregation/batchelements.md
+++ 
b/website/www/site/content/en/documentation/transforms/python/aggregation/batchelements.md
@@ -19,7 +19,7 @@ limitations under the License.
 
 {{< localstorage language language-py >}}
 
-{{< button-pydoc path="apache_beam.transforms.stat" class="BatchElements" >}}
+{{< button-pydoc path="apache_beam.transforms.util" class="BatchElements" >}}
 
 ## Examples
 
@@ -28,4 +28,7 @@ limitations under the License.
 {{< /playground >}}
 
 ## Related transforms
+
 * 
[GroupIntoBatches](/documentation/transforms/python/aggregation/groupintobatches)
 batches elements by key
+
+{{< button-pydoc path="apache_beam.transforms.util" class="BatchElements" >}}
diff --git 
a/website/www/site/content/en/documentation/transforms/python/aggregation/count.md
 
b/website/www/site/content/en/documentation/transforms/python/aggregation/count.md
index a444cd4b3dd..9aab13e2218 100644
--- 
a/website/www/site/content/en/documentation/transforms/python/aggregation/count.md
+++ 
b/website/www/site/content/en/documentation/transforms/python/aggregation/count.md
@@ -46,7 +46,7 @@ We use `Count.PerKey()` to count the elements for each unique 
key in a `PCollect
 
 ### Example 3: Counting all unique elements
 
-We use `Count.PerElement()` to count the only the unique elements in a 
`PCollection`.
+We use `Count.PerElement()` to count only the unique elements in a 
`PCollection`.
 
 {{< playground height="700px" >}}
 {{< playground_snippet language="py" path="SDK_PYTHON_CountPerElement" 
show="count_per_element" >}}
diff --git 
a/website/www/site/content/en/documentation/transforms/python/aggregation/groupbykey.md
 
b/website/www/site/content/en/documentation/transforms/python/aggregation/groupbykey.md
index e3f287da7d0..1a5fa2ded7f 100644
--- 
a/website/www/site/content/en/documentation/transforms/python/aggregation/groupbykey.md
+++ 
b/website/www/site/content/en/documentation/transforms/python/aggregation/groupbykey.md
@@ -33,7 +33,7 @@ See more information in the [Beam Programming 
Guide](/documentation/programming-
 We use `GroupByKey` to group all the produce for each season.
 
 {{< playground height="700px" >}}
-{{< playground_snippet language="py" path="SDK_PYTHON_GroupByKey" 
show="groupbykeysort" >}}
+{{< playground_snippet language="py" path="SDK_PYTHON_GroupByKeySort" 
show="groupbykey" >}}
 {{< /playground >}}
 
 **Example 2**:
diff --git 
a/website/www/site/content/en/documentation/transforms/python/aggregation/tolist.md
 
b/website/www/site/content/en/documentation/transforms/python/aggregation/tolist.md
index cfed9958079..1fd3e8dc48b 100644
--- 
a/website/www/site/content/en/documentation/transforms/python/aggregation/tolist.md
+++ 
b/website/www/site/content/en/documentation/transforms/python/aggregation/tolist.md
@@ -1,5 +1,5 @@
 ---
-title: "BatchElements"
+title: "ToList"
 ---
 <!--
 Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,7 +15,7 @@ See the License for the specific language governing 
permissions and
 limitations under the License.
 -->
 
-# BatchElements
+# ToList
 
 {{< localstorage language language-py >}}
 
@@ -26,3 +26,9 @@ limitations under the License.
 {{< playground height="700px" >}}
 {{< playground_snippet language="py" path="SDK_PYTHON_ToList" show="tolist" >}}
 {{< /playground >}}
+
+## Related transforms
+
+N/A
+
+{{< button-pydoc path="apache_beam.transforms.combiners" class="ToList" >}}
diff --git 
a/website/www/site/content/en/documentation/transforms/python/overview.md 
b/website/www/site/content/en/documentation/transforms/python/overview.md
index c5d9714e695..34599ed6c02 100644
--- a/website/www/site/content/en/documentation/transforms/python/overview.md
+++ b/website/www/site/content/en/documentation/transforms/python/overview.md
@@ -50,7 +50,7 @@ limitations under the License.
   <tr><th>Transform</th><th>Description</th></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>
+  <tr><td><a 
href="/documentation/transforms/python/aggregation/batchelements">BatchElements</a></td><td>Transform
 that batches elements for amortized processing.</td></tr>
   <tr><td><a 
href="/documentation/transforms/python/aggregation/cogroupbykey">CoGroupByKey</a></td><td>Takes
 several keyed collections of elements and produces a collection where each 
element consists of a key and all values associated with that key.</td></tr>
   <tr><td><a 
href="/documentation/transforms/python/aggregation/combineglobally">CombineGlobally</a></td><td>Transforms
 to combine elements.</td></tr>
   <tr><td><a 
href="/documentation/transforms/python/aggregation/combineperkey">CombinePerKey</a></td><td>Transforms
 to combine elements for each key.</td></tr>
diff --git 
a/website/www/site/layouts/partials/section-menu/en/documentation.html 
b/website/www/site/layouts/partials/section-menu/en/documentation.html
index df4a0f20d63..15140419a42 100755
--- a/website/www/site/layouts/partials/section-menu/en/documentation.html
+++ b/website/www/site/layouts/partials/section-menu/en/documentation.html
@@ -326,6 +326,7 @@
           <ul class="section-nav-list">
             <li><a 
href="/documentation/transforms/python/aggregation/approximatequantiles/">ApproximateQuantiles</a></li>
             <li><a 
href="/documentation/transforms/python/aggregation/approximateunique/">ApproximateUnique</a></li>
+            <li><a 
href="/documentation/transforms/python/aggregation/batchelements/">BatchElements</a></li>
             <li><a 
href="/documentation/transforms/python/aggregation/cogroupbykey/">CoGroupByKey</a></li>
             <li><a 
href="/documentation/transforms/python/aggregation/combineglobally/">CombineGlobally</a></li>
             <li><a 
href="/documentation/transforms/python/aggregation/combineperkey/">CombinePerKey</a></li>

Reply via email to