beam python with pub/sub subscription : error with DirectRunner but not DataflowRunner

394 Views Asked by At

I have a very simple BEAM Python script, working like a charm when started on the DataflowRunner. It takes datas from a Pub/Sub subscription and print it... And that is all and it works. But, when I start it on the DirectRunner, I get this error :

ERROR:apache_beam.runners.direct.executor:Exception at bundle , due to an exception.
 Traceback (most recent call last)
[...]
File ".../.local/lib/python3.9/site-packages/apache_beam/utils/timestamp.py", line 106, in from_utc_datetime
    if dt.tzinfo != pytz.utc and dt.tzinfo != datetime.timezone.utc:
AttributeError: tzinfo

If I replace the code about the Pub/Sub subscription by a Beam.Create([...]) step, it works.


    # Read from PubSub
    rows = (pipeline
            | 'Read from PubSub' >> beam.io.ReadFromPubSub(subscription=known_args.input_subscription)
            #| 'Simple PCollection' >> beam.Create([0,2,5])
            | 'print' >> beam.Map(print)
           )

0

There are 0 best solutions below