I am developing an POC it is required for a approach evaluation. I have python, venv, apache beam and gcloud installed in my Mac. And, i have logged in gcloud pupsub.
the following code, creates an subscription my Pubsub topic and read the message from PubSub.
Steps:
- execute the code
- go to gcloud poubsub topic and publish a simple message
- the code reads the message and creates an out put file
but no luck, i am getting the following error: AttributeError: 'SubscriberGrpcTransport' object has no attribute 'channel'
Code:
def run(argv=None):
parser = argparse.ArgumentParser()
parser.add_argument(
'--topic',
type=str,
help='Pub/sub topic to read from')
parser.add_argument(
'--output',
help=('Output local filename'))
args, pipeline_args = parser.parse_known_args(argv)
options = PipelineOptions(pipeline_args)
options.view_as(SetupOptions).save_main_session = True
options.view_as(StandardOptions).streaming = True
p = beam.Pipeline(options=options)
(p | 'Read from PubSub' >> beam.io.ReadStringsFromPubSub(topic=args.topic)
| 'Write to file' >> beam.io.WriteToText(args.output)
)
result = p.run()
result.wait_until_finish()
if __name__ == '__main__':
run()
and ref the video: https://www.youtube.com/watch?v=I1JUtoDHFcg 9:13th mintus.
Please pass your expert help to fix the issue.