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 2020/04/29 18:21:19 UTC
[beam] branch master updated: [BEAM-9771] Fix notebook github URLs
This is an automated email from the ASF dual-hosted git repository.
altay 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 598402a [BEAM-9771] Fix notebook github URLs
new e173fa8 Merge pull request #11573 from davidcavazos/fix-notebook-urls
598402a is described below
commit 598402ad85c4b3a7d44e4f2b11b81bcf60772789
Author: David Cavazos <dc...@google.com>
AuthorDate: Wed Apr 29 10:28:24 2020 -0700
[BEAM-9771] Fix notebook github URLs
---
.../transforms/python/elementwise/filter-py.ipynb | 155 ++++++++++++++-------
.../transforms/python/elementwise/flatmap-py.ipynb | 74 +++++-----
.../transforms/python/elementwise/keys-py.ipynb | 7 +-
.../transforms/python/elementwise/kvswap-py.ipynb | 7 +-
.../transforms/python/elementwise/map-py.ipynb | 58 ++++----
.../transforms/python/elementwise/pardo-py.ipynb | 35 +++--
.../python/elementwise/partition-py.ipynb | 51 +++----
.../transforms/python/elementwise/regex-py.ipynb | 31 ++---
.../python/elementwise/tostring-py.ipynb | 13 +-
.../transforms/python/elementwise/values-py.ipynb | 7 +-
.../python/elementwise/withtimestamps-py.ipynb | 4 +-
website/notebooks/generate.py | 6 +-
12 files changed, 248 insertions(+), 200 deletions(-)
diff --git a/examples/notebooks/documentation/transforms/python/elementwise/filter-py.ipynb b/examples/notebooks/documentation/transforms/python/elementwise/filter-py.ipynb
index 70da228..3ee08ef 100644
--- a/examples/notebooks/documentation/transforms/python/elementwise/filter-py.ipynb
+++ b/examples/notebooks/documentation/transforms/python/elementwise/filter-py.ipynb
@@ -6,7 +6,7 @@
"id": "view-in-github"
},
"source": [
- "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master//Users/dcavazos/src/beam/examples/notebooks/documentation/transforms/python/elementwise/filter-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
+ "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master/examples/notebooks/documentation/transforms/python/elementwise/filter-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
]
},
{
@@ -142,15 +142,24 @@
" perennials = (\n",
" pipeline\n",
" | 'Gardening plants' >> beam.Create([\n",
- " {'icon': 'π', 'name': 'Strawberry', 'duration': 'perennial'},\n",
- " {'icon': 'π₯', 'name': 'Carrot', 'duration': 'biennial'},\n",
- " {'icon': 'π', 'name': 'Eggplant', 'duration': 'perennial'},\n",
- " {'icon': 'π
', 'name': 'Tomato', 'duration': 'annual'},\n",
- " {'icon': 'π₯', 'name': 'Potato', 'duration': 'perennial'},\n",
+ " {\n",
+ " 'icon': 'π', 'name': 'Strawberry', 'duration': 'perennial'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π₯', 'name': 'Carrot', 'duration': 'biennial'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π', 'name': 'Eggplant', 'duration': 'perennial'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π
', 'name': 'Tomato', 'duration': 'annual'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π₯', 'name': 'Potato', 'duration': 'perennial'\n",
+ " },\n",
" ])\n",
" | 'Filter perennials' >> beam.Filter(is_perennial)\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -193,16 +202,25 @@
" perennials = (\n",
" pipeline\n",
" | 'Gardening plants' >> beam.Create([\n",
- " {'icon': 'π', 'name': 'Strawberry', 'duration': 'perennial'},\n",
- " {'icon': 'π₯', 'name': 'Carrot', 'duration': 'biennial'},\n",
- " {'icon': 'π', 'name': 'Eggplant', 'duration': 'perennial'},\n",
- " {'icon': 'π
', 'name': 'Tomato', 'duration': 'annual'},\n",
- " {'icon': 'π₯', 'name': 'Potato', 'duration': 'perennial'},\n",
+ " {\n",
+ " 'icon': 'π', 'name': 'Strawberry', 'duration': 'perennial'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π₯', 'name': 'Carrot', 'duration': 'biennial'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π', 'name': 'Eggplant', 'duration': 'perennial'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π
', 'name': 'Tomato', 'duration': 'annual'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π₯', 'name': 'Potato', 'duration': 'perennial'\n",
+ " },\n",
" ])\n",
- " | 'Filter perennials' >> beam.Filter(\n",
- " lambda plant: plant['duration'] == 'perennial')\n",
- " | beam.Map(print)\n",
- " )"
+ " | 'Filter perennials' >>\n",
+ " beam.Filter(lambda plant: plant['duration'] == 'perennial')\n",
+ " | beam.Map(print))"
]
},
{
@@ -251,15 +269,24 @@
" perennials = (\n",
" pipeline\n",
" | 'Gardening plants' >> beam.Create([\n",
- " {'icon': 'π', 'name': 'Strawberry', 'duration': 'perennial'},\n",
- " {'icon': 'π₯', 'name': 'Carrot', 'duration': 'biennial'},\n",
- " {'icon': 'π', 'name': 'Eggplant', 'duration': 'perennial'},\n",
- " {'icon': 'π
', 'name': 'Tomato', 'duration': 'annual'},\n",
- " {'icon': 'π₯', 'name': 'Potato', 'duration': 'perennial'},\n",
+ " {\n",
+ " 'icon': 'π', 'name': 'Strawberry', 'duration': 'perennial'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π₯', 'name': 'Carrot', 'duration': 'biennial'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π', 'name': 'Eggplant', 'duration': 'perennial'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π
', 'name': 'Tomato', 'duration': 'annual'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π₯', 'name': 'Potato', 'duration': 'perennial'\n",
+ " },\n",
" ])\n",
" | 'Filter perennials' >> beam.Filter(has_duration, 'perennial')\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -308,18 +335,28 @@
" perennials = (\n",
" pipeline\n",
" | 'Gardening plants' >> beam.Create([\n",
- " {'icon': 'π', 'name': 'Strawberry', 'duration': 'perennial'},\n",
- " {'icon': 'π₯', 'name': 'Carrot', 'duration': 'biennial'},\n",
- " {'icon': 'π', 'name': 'Eggplant', 'duration': 'perennial'},\n",
- " {'icon': 'π
', 'name': 'Tomato', 'duration': 'annual'},\n",
- " {'icon': 'π₯', 'name': 'Potato', 'duration': 'perennial'},\n",
+ " {\n",
+ " 'icon': 'π', 'name': 'Strawberry', 'duration': 'perennial'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π₯', 'name': 'Carrot', 'duration': 'biennial'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π', 'name': 'Eggplant', 'duration': 'perennial'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π
', 'name': 'Tomato', 'duration': 'annual'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π₯', 'name': 'Potato', 'duration': 'perennial'\n",
+ " },\n",
" ])\n",
" | 'Filter perennials' >> beam.Filter(\n",
- " lambda plant, duration: plant['duration'] == duration,\n",
+ " lambda plant,\n",
+ " duration: plant['duration'] == duration,\n",
" duration=beam.pvalue.AsSingleton(perennial),\n",
" )\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -370,18 +407,28 @@
" valid_plants = (\n",
" pipeline\n",
" | 'Gardening plants' >> beam.Create([\n",
- " {'icon': 'π', 'name': 'Strawberry', 'duration': 'perennial'},\n",
- " {'icon': 'π₯', 'name': 'Carrot', 'duration': 'biennial'},\n",
- " {'icon': 'π', 'name': 'Eggplant', 'duration': 'perennial'},\n",
- " {'icon': 'π
', 'name': 'Tomato', 'duration': 'annual'},\n",
- " {'icon': 'π₯', 'name': 'Potato', 'duration': 'PERENNIAL'},\n",
+ " {\n",
+ " 'icon': 'π', 'name': 'Strawberry', 'duration': 'perennial'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π₯', 'name': 'Carrot', 'duration': 'biennial'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π', 'name': 'Eggplant', 'duration': 'perennial'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π
', 'name': 'Tomato', 'duration': 'annual'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π₯', 'name': 'Potato', 'duration': 'PERENNIAL'\n",
+ " },\n",
" ])\n",
" | 'Filter valid plants' >> beam.Filter(\n",
- " lambda plant, valid_durations: plant['duration'] in valid_durations,\n",
+ " lambda plant,\n",
+ " valid_durations: plant['duration'] in valid_durations,\n",
" valid_durations=beam.pvalue.AsIter(valid_durations),\n",
" )\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -436,18 +483,28 @@
" perennials = (\n",
" pipeline\n",
" | 'Gardening plants' >> beam.Create([\n",
- " {'icon': 'π', 'name': 'Strawberry', 'duration': 'perennial'},\n",
- " {'icon': 'π₯', 'name': 'Carrot', 'duration': 'biennial'},\n",
- " {'icon': 'π', 'name': 'Eggplant', 'duration': 'perennial'},\n",
- " {'icon': 'π
', 'name': 'Tomato', 'duration': 'annual'},\n",
- " {'icon': 'π₯', 'name': 'Potato', 'duration': 'perennial'},\n",
+ " {\n",
+ " 'icon': 'π', 'name': 'Strawberry', 'duration': 'perennial'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π₯', 'name': 'Carrot', 'duration': 'biennial'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π', 'name': 'Eggplant', 'duration': 'perennial'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π
', 'name': 'Tomato', 'duration': 'annual'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π₯', 'name': 'Potato', 'duration': 'perennial'\n",
+ " },\n",
" ])\n",
" | 'Filter plants by duration' >> beam.Filter(\n",
- " lambda plant, keep_duration: keep_duration[plant['duration']],\n",
+ " lambda plant,\n",
+ " keep_duration: keep_duration[plant['duration']],\n",
" keep_duration=beam.pvalue.AsDict(keep_duration),\n",
" )\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -508,5 +565,5 @@
}
},
"nbformat": 4,
- "nbformat_minor": 2
+ "nbformat_minor": 4
}
diff --git a/examples/notebooks/documentation/transforms/python/elementwise/flatmap-py.ipynb b/examples/notebooks/documentation/transforms/python/elementwise/flatmap-py.ipynb
index b99e3e9..e5fedb1 100644
--- a/examples/notebooks/documentation/transforms/python/elementwise/flatmap-py.ipynb
+++ b/examples/notebooks/documentation/transforms/python/elementwise/flatmap-py.ipynb
@@ -6,7 +6,7 @@
"id": "view-in-github"
},
"source": [
- "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master//Users/dcavazos/src/beam/examples/notebooks/documentation/transforms/python/elementwise/flatmap-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
+ "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master/examples/notebooks/documentation/transforms/python/elementwise/flatmap-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
]
},
{
@@ -144,8 +144,7 @@
" 'π
Tomato π₯Potato',\n",
" ])\n",
" | 'Split words' >> beam.FlatMap(str.split)\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -195,8 +194,7 @@
" 'π
Tomato,π₯Potato',\n",
" ])\n",
" | 'Split words' >> beam.FlatMap(split_words)\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -245,8 +243,7 @@
" ['π
Tomato', 'π₯Potato'],\n",
" ])\n",
" | 'Flatten lists' >> beam.FlatMap(lambda elements: elements)\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -299,8 +296,7 @@
" ['π
Tomato', 'π₯Potato'],\n",
" ])\n",
" | 'Flatten lists' >> beam.FlatMap(generate_elements)\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -356,8 +352,7 @@
" (None, 'Invalid'),\n",
" ])\n",
" | 'Format' >> beam.FlatMapTuple(format_plant)\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -410,8 +405,7 @@
" 'π
Tomato,π₯Potato',\n",
" ])\n",
" | 'Split words' >> beam.FlatMap(split_words, delimiter=',')\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -464,11 +458,11 @@
" 'π
Tomato,π₯Potato',\n",
" ])\n",
" | 'Split words' >> beam.FlatMap(\n",
- " lambda text, delimiter: text.split(delimiter),\n",
+ " lambda text,\n",
+ " delimiter: text.split(delimiter),\n",
" delimiter=beam.pvalue.AsSingleton(delimiter),\n",
" )\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -524,18 +518,27 @@
" valid_plants = (\n",
" pipeline\n",
" | 'Gardening plants' >> beam.Create([\n",
- " {'icon': 'π', 'name': 'Strawberry', 'duration': 'Perennial'},\n",
- " {'icon': 'π₯', 'name': 'Carrot', 'duration': 'BIENNIAL'},\n",
- " {'icon': 'π', 'name': 'Eggplant', 'duration': 'perennial'},\n",
- " {'icon': 'π
', 'name': 'Tomato', 'duration': 'annual'},\n",
- " {'icon': 'π₯', 'name': 'Potato', 'duration': 'unknown'},\n",
+ " {\n",
+ " 'icon': 'π', 'name': 'Strawberry', 'duration': 'Perennial'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π₯', 'name': 'Carrot', 'duration': 'BIENNIAL'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π', 'name': 'Eggplant', 'duration': 'perennial'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π
', 'name': 'Tomato', 'duration': 'annual'\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π₯', 'name': 'Potato', 'duration': 'unknown'\n",
+ " },\n",
" ])\n",
" | 'Normalize and validate durations' >> beam.FlatMap(\n",
" normalize_and_validate_durations,\n",
" valid_durations=beam.pvalue.AsIter(valid_durations),\n",
" )\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -595,18 +598,27 @@
" valid_plants = (\n",
" pipeline\n",
" | 'Gardening plants' >> beam.Create([\n",
- " {'icon': 'π', 'name': 'Strawberry', 'duration': 2},\n",
- " {'icon': 'π₯', 'name': 'Carrot', 'duration': 1},\n",
- " {'icon': 'π', 'name': 'Eggplant', 'duration': 2},\n",
- " {'icon': 'π
', 'name': 'Tomato', 'duration': 0},\n",
- " {'icon': 'π₯', 'name': 'Potato', 'duration': -1},\n",
+ " {\n",
+ " 'icon': 'π', 'name': 'Strawberry', 'duration': 2\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π₯', 'name': 'Carrot', 'duration': 1\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π', 'name': 'Eggplant', 'duration': 2\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π
', 'name': 'Tomato', 'duration': 0\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π₯', 'name': 'Potato', 'duration': -1\n",
+ " },\n",
" ])\n",
" | 'Replace duration if valid' >> beam.FlatMap(\n",
" replace_duration_if_valid,\n",
" durations=beam.pvalue.AsDict(durations),\n",
" )\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -668,5 +680,5 @@
}
},
"nbformat": 4,
- "nbformat_minor": 2
+ "nbformat_minor": 4
}
diff --git a/examples/notebooks/documentation/transforms/python/elementwise/keys-py.ipynb b/examples/notebooks/documentation/transforms/python/elementwise/keys-py.ipynb
index b0be11e..467d75e 100644
--- a/examples/notebooks/documentation/transforms/python/elementwise/keys-py.ipynb
+++ b/examples/notebooks/documentation/transforms/python/elementwise/keys-py.ipynb
@@ -6,7 +6,7 @@
"id": "view-in-github"
},
"source": [
- "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master//Users/dcavazos/src/beam/examples/notebooks/documentation/transforms/python/elementwise/keys-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
+ "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master/examples/notebooks/documentation/transforms/python/elementwise/keys-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
]
},
{
@@ -131,8 +131,7 @@
" ('π₯', 'Potato'),\n",
" ])\n",
" | 'Keys' >> beam.Keys()\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -191,5 +190,5 @@
}
},
"nbformat": 4,
- "nbformat_minor": 2
+ "nbformat_minor": 4
}
diff --git a/examples/notebooks/documentation/transforms/python/elementwise/kvswap-py.ipynb b/examples/notebooks/documentation/transforms/python/elementwise/kvswap-py.ipynb
index 25046a5..753e2c3 100644
--- a/examples/notebooks/documentation/transforms/python/elementwise/kvswap-py.ipynb
+++ b/examples/notebooks/documentation/transforms/python/elementwise/kvswap-py.ipynb
@@ -6,7 +6,7 @@
"id": "view-in-github"
},
"source": [
- "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master//Users/dcavazos/src/beam/examples/notebooks/documentation/transforms/python/elementwise/kvswap-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
+ "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master/examples/notebooks/documentation/transforms/python/elementwise/kvswap-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
]
},
{
@@ -132,8 +132,7 @@
" ('π₯', 'Potato'),\n",
" ])\n",
" | 'Key-Value swap' >> beam.KvSwap()\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -192,5 +191,5 @@
}
},
"nbformat": 4,
- "nbformat_minor": 2
+ "nbformat_minor": 4
}
diff --git a/examples/notebooks/documentation/transforms/python/elementwise/map-py.ipynb b/examples/notebooks/documentation/transforms/python/elementwise/map-py.ipynb
index 471bef4..34f0075 100644
--- a/examples/notebooks/documentation/transforms/python/elementwise/map-py.ipynb
+++ b/examples/notebooks/documentation/transforms/python/elementwise/map-py.ipynb
@@ -6,7 +6,7 @@
"id": "view-in-github"
},
"source": [
- "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master//Users/dcavazos/src/beam/examples/notebooks/documentation/transforms/python/elementwise/map-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
+ "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master/examples/notebooks/documentation/transforms/python/elementwise/map-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
]
},
{
@@ -145,8 +145,7 @@
" ' π₯Potato \\n',\n",
" ])\n",
" | 'Strip' >> beam.Map(str.strip)\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -199,8 +198,7 @@
" '# π₯Potato\\n',\n",
" ])\n",
" | 'Strip header' >> beam.Map(strip_header_and_newline)\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -250,8 +248,7 @@
" '# π₯Potato\\n',\n",
" ])\n",
" | 'Strip header' >> beam.Map(lambda text: text.strip('# \\n'))\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -307,8 +304,7 @@
" '# π₯Potato\\n',\n",
" ])\n",
" | 'Strip header' >> beam.Map(strip, chars='# \\n')\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -358,10 +354,9 @@
" ('π
', 'Tomato'),\n",
" ('π₯', 'Potato'),\n",
" ])\n",
- " | 'Format' >> beam.MapTuple(\n",
- " lambda icon, plant: '{}{}'.format(icon, plant))\n",
- " | beam.Map(print)\n",
- " )"
+ " | 'Format' >>\n",
+ " beam.MapTuple(lambda icon, plant: '{}{}'.format(icon, plant))\n",
+ " | beam.Map(print))"
]
},
{
@@ -417,11 +412,11 @@
" '# π₯Potato\\n',\n",
" ])\n",
" | 'Strip header' >> beam.Map(\n",
- " lambda text, chars: text.strip(chars),\n",
+ " lambda text,\n",
+ " chars: text.strip(chars),\n",
" chars=beam.pvalue.AsSingleton(chars),\n",
" )\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -475,11 +470,11 @@
" '# π₯Potato\\n',\n",
" ])\n",
" | 'Strip header' >> beam.Map(\n",
- " lambda text, chars: text.strip(''.join(chars)),\n",
+ " lambda text,\n",
+ " chars: text.strip(''.join(chars)),\n",
" chars=beam.pvalue.AsIter(chars),\n",
" )\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -538,18 +533,27 @@
" plant_details = (\n",
" pipeline\n",
" | 'Gardening plants' >> beam.Create([\n",
- " {'icon': 'π', 'name': 'Strawberry', 'duration': 2},\n",
- " {'icon': 'π₯', 'name': 'Carrot', 'duration': 1},\n",
- " {'icon': 'π', 'name': 'Eggplant', 'duration': 2},\n",
- " {'icon': 'π
', 'name': 'Tomato', 'duration': 0},\n",
- " {'icon': 'π₯', 'name': 'Potato', 'duration': 2},\n",
+ " {\n",
+ " 'icon': 'π', 'name': 'Strawberry', 'duration': 2\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π₯', 'name': 'Carrot', 'duration': 1\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π', 'name': 'Eggplant', 'duration': 2\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π
', 'name': 'Tomato', 'duration': 0\n",
+ " },\n",
+ " {\n",
+ " 'icon': 'π₯', 'name': 'Potato', 'duration': 2\n",
+ " },\n",
" ])\n",
" | 'Replace duration' >> beam.Map(\n",
" replace_duration,\n",
" durations=beam.pvalue.AsDict(durations),\n",
" )\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -612,5 +616,5 @@
}
},
"nbformat": 4,
- "nbformat_minor": 2
+ "nbformat_minor": 4
}
diff --git a/examples/notebooks/documentation/transforms/python/elementwise/pardo-py.ipynb b/examples/notebooks/documentation/transforms/python/elementwise/pardo-py.ipynb
index 1bc48a8..c0125c9 100644
--- a/examples/notebooks/documentation/transforms/python/elementwise/pardo-py.ipynb
+++ b/examples/notebooks/documentation/transforms/python/elementwise/pardo-py.ipynb
@@ -6,7 +6,7 @@
"id": "view-in-github"
},
"source": [
- "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master//Users/dcavazos/src/beam/examples/notebooks/documentation/transforms/python/elementwise/pardo-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
+ "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master/examples/notebooks/documentation/transforms/python/elementwise/pardo-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
]
},
{
@@ -156,8 +156,7 @@
" 'π
Tomato,π₯Potato',\n",
" ])\n",
" | 'Split words' >> beam.ParDo(SplitWords(','))\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -206,7 +205,11 @@
"import apache_beam as beam\n",
"\n",
"class AnalyzeElement(beam.DoFn):\n",
- " def process(self, elem, timestamp=beam.DoFn.TimestampParam, window=beam.DoFn.WindowParam):\n",
+ " def process(\n",
+ " self,\n",
+ " elem,\n",
+ " timestamp=beam.DoFn.TimestampParam,\n",
+ " window=beam.DoFn.WindowParam):\n",
" yield '\\n'.join([\n",
" '# timestamp',\n",
" 'type(timestamp) -> ' + repr(type(timestamp)),\n",
@@ -216,21 +219,24 @@
" '',\n",
" '# window',\n",
" 'type(window) -> ' + repr(type(window)),\n",
- " 'window.start -> {} ({})'.format(window.start, window.start.to_utc_datetime()),\n",
- " 'window.end -> {} ({})'.format(window.end, window.end.to_utc_datetime()),\n",
- " 'window.max_timestamp() -> {} ({})'.format(window.max_timestamp(), window.max_timestamp().to_utc_datetime()),\n",
+ " 'window.start -> {} ({})'.format(\n",
+ " window.start, window.start.to_utc_datetime()),\n",
+ " 'window.end -> {} ({})'.format(\n",
+ " window.end, window.end.to_utc_datetime()),\n",
+ " 'window.max_timestamp() -> {} ({})'.format(\n",
+ " window.max_timestamp(), window.max_timestamp().to_utc_datetime()),\n",
" ])\n",
"\n",
"with beam.Pipeline() as pipeline:\n",
" dofn_params = (\n",
" pipeline\n",
" | 'Create a single test element' >> beam.Create([':)'])\n",
- " | 'Add timestamp (Spring equinox 2020)' >> beam.Map(\n",
- " lambda elem: beam.window.TimestampedValue(elem, 1584675660))\n",
- " | 'Fixed 30sec windows' >> beam.WindowInto(beam.window.FixedWindows(30))\n",
+ " | 'Add timestamp (Spring equinox 2020)' >>\n",
+ " beam.Map(lambda elem: beam.window.TimestampedValue(elem, 1584675660))\n",
+ " |\n",
+ " 'Fixed 30sec windows' >> beam.WindowInto(beam.window.FixedWindows(30))\n",
" | 'Analyze element' >> beam.ParDo(AnalyzeElement())\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -340,8 +346,7 @@
" pipeline\n",
" | 'Create inputs' >> beam.Create(['π', 'π₯', 'π', 'π
', 'π₯'])\n",
" | 'DoFn methods' >> beam.ParDo(DoFnMethods())\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -410,5 +415,5 @@
}
},
"nbformat": 4,
- "nbformat_minor": 2
+ "nbformat_minor": 4
}
diff --git a/examples/notebooks/documentation/transforms/python/elementwise/partition-py.ipynb b/examples/notebooks/documentation/transforms/python/elementwise/partition-py.ipynb
index ea520e5..9b0a7c7 100644
--- a/examples/notebooks/documentation/transforms/python/elementwise/partition-py.ipynb
+++ b/examples/notebooks/documentation/transforms/python/elementwise/partition-py.ipynb
@@ -6,7 +6,7 @@
"id": "view-in-github"
},
"source": [
- "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master//Users/dcavazos/src/beam/examples/notebooks/documentation/transforms/python/elementwise/partition-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
+ "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master/examples/notebooks/documentation/transforms/python/elementwise/partition-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
]
},
{
@@ -162,18 +162,12 @@
" ])\n",
" | 'Partition' >> beam.Partition(by_duration, len(durations))\n",
" )\n",
- " _ = (\n",
- " annuals\n",
- " | 'Annuals' >> beam.Map(lambda x: print('annual: ' + str(x)))\n",
- " )\n",
- " _ = (\n",
- " biennials\n",
- " | 'Biennials' >> beam.Map(lambda x: print('biennial: ' + str(x)))\n",
- " )\n",
- " _ = (\n",
- " perennials\n",
- " | 'Perennials' >> beam.Map(lambda x: print('perennial: ' + str(x)))\n",
- " )"
+ "\n",
+ " annuals | 'Annuals' >> beam.Map(lambda x: print('annual: {}'.format(x)))\n",
+ " biennials | 'Biennials' >> beam.Map(\n",
+ " lambda x: print('biennial: {}'.format(x)))\n",
+ " perennials | 'Perennials' >> beam.Map(\n",
+ " lambda x: print('perennial: {}'.format(x)))"
]
},
{
@@ -229,18 +223,12 @@
" len(durations),\n",
" )\n",
" )\n",
- " _ = (\n",
- " annuals\n",
- " | 'Annuals' >> beam.Map(lambda x: print('annual: ' + str(x)))\n",
- " )\n",
- " _ = (\n",
- " biennials\n",
- " | 'Biennials' >> beam.Map(lambda x: print('biennial: ' + str(x)))\n",
- " )\n",
- " _ = (\n",
- " perennials\n",
- " | 'Perennials' >> beam.Map(lambda x: print('perennial: ' + str(x)))\n",
- " )"
+ "\n",
+ " annuals | 'Annuals' >> beam.Map(lambda x: print('annual: {}'.format(x)))\n",
+ " biennials | 'Biennials' >> beam.Map(\n",
+ " lambda x: print('biennial: {}'.format(x)))\n",
+ " perennials | 'Perennials' >> beam.Map(\n",
+ " lambda x: print('perennial: {}'.format(x)))"
]
},
{
@@ -330,14 +318,9 @@
" ])\n",
" | 'Partition' >> beam.Partition(split_dataset, 2, ratio=[8, 2])\n",
" )\n",
- " _ = (\n",
- " train_dataset\n",
- " | 'Train' >> beam.Map(lambda x: print('train: ' + str(x)))\n",
- " )\n",
- " _ = (\n",
- " test_dataset\n",
- " | 'Test' >> beam.Map(lambda x: print('test: ' + str(x)))\n",
- " )"
+ "\n",
+ " train_dataset | 'Train' >> beam.Map(lambda x: print('train: {}'.format(x)))\n",
+ " test_dataset | 'Test' >> beam.Map(lambda x: print('test: {}'.format(x)))"
]
},
{
@@ -400,5 +383,5 @@
}
},
"nbformat": 4,
- "nbformat_minor": 2
+ "nbformat_minor": 4
}
diff --git a/examples/notebooks/documentation/transforms/python/elementwise/regex-py.ipynb b/examples/notebooks/documentation/transforms/python/elementwise/regex-py.ipynb
index 705ce90..31cc866 100644
--- a/examples/notebooks/documentation/transforms/python/elementwise/regex-py.ipynb
+++ b/examples/notebooks/documentation/transforms/python/elementwise/regex-py.ipynb
@@ -6,7 +6,7 @@
"id": "view-in-github"
},
"source": [
- "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master//Users/dcavazos/src/beam/examples/notebooks/documentation/transforms/python/elementwise/regex-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
+ "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master/examples/notebooks/documentation/transforms/python/elementwise/regex-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
]
},
{
@@ -175,8 +175,7 @@
" 'invalid, π, format',\n",
" ])\n",
" | 'Parse plants' >> beam.Regex.matches(regex)\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -239,8 +238,7 @@
" 'invalid, π, format',\n",
" ])\n",
" | 'Parse plants' >> beam.Regex.all_matches(regex)\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -304,8 +302,7 @@
" 'invalid, π, format',\n",
" ])\n",
" | 'Parse plants' >> beam.Regex.matches_kv(regex, keyGroup='icon')\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -367,8 +364,7 @@
" '# π₯, Potato, perennial',\n",
" ])\n",
" | 'Parse plants' >> beam.Regex.find(regex)\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -430,8 +426,7 @@
" '# π₯, Potato, perennial',\n",
" ])\n",
" | 'Parse plants' >> beam.Regex.find_all(regex)\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -494,8 +489,7 @@
" '# π₯, Potato, perennial',\n",
" ])\n",
" | 'Parse plants' >> beam.Regex.find_kv(regex, keyGroup='icon')\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -548,8 +542,7 @@
" 'π₯ : Potato : perennial',\n",
" ])\n",
" | 'To CSV' >> beam.Regex.replace_all(r'\\s*:\\s*', ',')\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -602,8 +595,7 @@
" 'π₯, Potato, perennial',\n",
" ])\n",
" | 'As dictionary' >> beam.Regex.replace_first(r'\\s*,\\s*', ': ')\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -654,8 +646,7 @@
" 'π₯ : Potato : perennial',\n",
" ])\n",
" | 'Parse plants' >> beam.Regex.split(r'\\s*:\\s*')\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -715,5 +706,5 @@
}
},
"nbformat": 4,
- "nbformat_minor": 2
+ "nbformat_minor": 4
}
diff --git a/examples/notebooks/documentation/transforms/python/elementwise/tostring-py.ipynb b/examples/notebooks/documentation/transforms/python/elementwise/tostring-py.ipynb
index 69addef..abc6aa9 100644
--- a/examples/notebooks/documentation/transforms/python/elementwise/tostring-py.ipynb
+++ b/examples/notebooks/documentation/transforms/python/elementwise/tostring-py.ipynb
@@ -6,7 +6,7 @@
"id": "view-in-github"
},
"source": [
- "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master//Users/dcavazos/src/beam/examples/notebooks/documentation/transforms/python/elementwise/tostring-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
+ "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master/examples/notebooks/documentation/transforms/python/elementwise/tostring-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
]
},
{
@@ -145,8 +145,7 @@
" ('π₯', 'Potato'),\n",
" ])\n",
" | 'To string' >> beam.ToString.Kvs()\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -197,8 +196,7 @@
" ['π₯', 'Potato', 'perennial'],\n",
" ])\n",
" | 'To string' >> beam.ToString.Element()\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -251,8 +249,7 @@
" ['π₯', 'Potato', 'perennial'],\n",
" ])\n",
" | 'To string' >> beam.ToString.Iterables()\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -310,5 +307,5 @@
}
},
"nbformat": 4,
- "nbformat_minor": 2
+ "nbformat_minor": 4
}
diff --git a/examples/notebooks/documentation/transforms/python/elementwise/values-py.ipynb b/examples/notebooks/documentation/transforms/python/elementwise/values-py.ipynb
index db28234..4d1ee81 100644
--- a/examples/notebooks/documentation/transforms/python/elementwise/values-py.ipynb
+++ b/examples/notebooks/documentation/transforms/python/elementwise/values-py.ipynb
@@ -6,7 +6,7 @@
"id": "view-in-github"
},
"source": [
- "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master//Users/dcavazos/src/beam/examples/notebooks/documentation/transforms/python/elementwise/values-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
+ "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master/examples/notebooks/documentation/transforms/python/elementwise/values-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
]
},
{
@@ -131,8 +131,7 @@
" ('π₯', 'Potato'),\n",
" ])\n",
" | 'Values' >> beam.Values()\n",
- " | beam.Map(print)\n",
- " )"
+ " | beam.Map(print))"
]
},
{
@@ -191,5 +190,5 @@
}
},
"nbformat": 4,
- "nbformat_minor": 2
+ "nbformat_minor": 4
}
diff --git a/examples/notebooks/documentation/transforms/python/elementwise/withtimestamps-py.ipynb b/examples/notebooks/documentation/transforms/python/elementwise/withtimestamps-py.ipynb
index 3418035..4624a88 100644
--- a/examples/notebooks/documentation/transforms/python/elementwise/withtimestamps-py.ipynb
+++ b/examples/notebooks/documentation/transforms/python/elementwise/withtimestamps-py.ipynb
@@ -6,7 +6,7 @@
"id": "view-in-github"
},
"source": [
- "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master//Users/dcavazos/src/beam/examples/notebooks/documentation/transforms/python/elementwise/withtimestamps-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
+ "<a href=\"https://colab.research.google.com/github/apache/beam/blob/master/examples/notebooks/documentation/transforms/python/elementwise/withtimestamps-py.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>"
]
},
{
@@ -365,5 +365,5 @@
}
},
"nbformat": 4,
- "nbformat_minor": 2
+ "nbformat_minor": 4
}
diff --git a/website/notebooks/generate.py b/website/notebooks/generate.py
index 6af6355..7996592 100644
--- a/website/notebooks/generate.py
+++ b/website/notebooks/generate.py
@@ -39,7 +39,7 @@ import yaml
docs_logo_url = 'https://beam.apache.org/images/logos/full-color/name-bottom/beam-logo-full-color-name-bottom-100.png'
-def run(docs, variables=None,
+def run(docs, root_dir, variables=None,
inputs_dir='.', outputs_dir='.', imports_dir='.', include_dir='.'):
errors = []
@@ -70,7 +70,8 @@ def run(docs, variables=None,
filter_classes='notebook-skip',
docs_url='https://beam.apache.org/' + basename.replace('-', ''),
docs_logo_url=docs_logo_url,
- github_ipynb_url='https://github.com/apache/beam/blob/master/' + ipynb_file,
+ github_ipynb_url='https://github.com/apache/beam/blob/master/'
+ + os.path.relpath(ipynb_file, root_dir),
include_dir=include_dir,
)
logging.info('{} succeeded'.format(input_file))
@@ -120,6 +121,7 @@ if __name__ == '__main__':
run(
docs=docs,
+ root_dir=root_dir,
variables=variables,
inputs_dir=os.path.join(root_dir, 'website', 'src'),
outputs_dir=os.path.join(root_dir, 'examples', 'notebooks'),