Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sdks/python/apache_beam/examples/complete/game/game_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ def run(argv=None):
# Read game events from Pub/Sub using custom timestamps, which
# are extracted from the data elements, and parse the data.
if args.subscription:
scores = p | 'ReadPubSub' >> beam.io.ReadStringsFromPubSub(
scores = p | 'ReadPubSub' >> beam.io.ReadFromPubSub(
subscription=args.subscription)
else:
scores = p | 'ReadPubSub' >> beam.io.ReadStringsFromPubSub(
scores = p | 'ReadPubSub' >> beam.io.ReadFromPubSub(
topic=args.topic)
raw_events = (
scores
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,10 @@ def run(argv=None):

# Read from PubSub into a PCollection.
if args.subscription:
scores = p | 'ReadPubSub' >> beam.io.ReadStringsFromPubSub(
scores = p | 'ReadPubSub' >> beam.io.ReadFromPubSub(
subscription=args.subscription)
else:
scores = p | 'ReadPubSub' >> beam.io.ReadStringsFromPubSub(
scores = p | 'ReadPubSub' >> beam.io.ReadFromPubSub(
topic=args.topic)

events = (
Expand Down
10 changes: 5 additions & 5 deletions sdks/python/apache_beam/examples/streaming_wordcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import argparse
import logging

from past.builtins import unicode
import six

import apache_beam as beam
import apache_beam.transforms.window as window
Expand Down Expand Up @@ -60,10 +60,10 @@ def run(argv=None):

# Read from PubSub into a PCollection.
if known_args.input_subscription:
lines = p | beam.io.ReadStringsFromPubSub(
lines = p | beam.io.ReadFromPubSub(
subscription=known_args.input_subscription)
else:
lines = p | beam.io.ReadStringsFromPubSub(topic=known_args.input_topic)
lines = p | beam.io.ReadFromPubSub(topic=known_args.input_topic)

# Count the occurrences of each word.
def count_ones(word_ones):
Expand All @@ -72,7 +72,7 @@ def count_ones(word_ones):

counts = (lines
| 'split' >> (beam.ParDo(WordExtractingDoFn())
.with_output_types(unicode))
.with_output_types(six.text_type))
| 'pair_with_one' >> beam.Map(lambda x: (x, 1))
| beam.WindowInto(window.FixedWindows(15, 0))
| 'group' >> beam.GroupByKey()
Expand All @@ -87,7 +87,7 @@ def format_result(word_count):

# Write to PubSub.
# pylint: disable=expression-not-assigned
output | beam.io.WriteStringsToPubSub(known_args.output_topic)
output | beam.io.WriteToPubSub(known_args.output_topic)

result = p.run()
result.wait_until_finish()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ def run(argv=None):

# Read from PubSub into a PCollection.
if known_args.input_subscription:
lines = p | beam.io.ReadStringsFromPubSub(
lines = p | beam.io.ReadFromPubSub(
subscription=known_args.input_subscription)
else:
lines = p | beam.io.ReadStringsFromPubSub(topic=known_args.input_topic)
lines = p | beam.io.ReadFromPubSub(topic=known_args.input_topic)

# Count the occurrences of each word.
def count_ones(word_ones):
Expand Down
2 changes: 1 addition & 1 deletion sdks/python/apache_beam/examples/windowed_wordcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def run(argv=None):
with beam.Pipeline(argv=pipeline_args) as p:

# Read the text from PubSub messages.
lines = p | beam.io.ReadStringsFromPubSub(known_args.input_topic)
lines = p | beam.io.ReadFromPubSub(known_args.input_topic)

# Get the number of appearances of a word.
def count_ones(word_ones):
Expand Down
Loading