Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: tzinfo #158

Open
bumegha opened this issue Oct 17, 2022 · 2 comments
Open

AttributeError: tzinfo #158

bumegha opened this issue Oct 17, 2022 · 2 comments

Comments

@bumegha
Copy link

bumegha commented Oct 17, 2022

ERROR:apache_beam.runners.direct.executor:Giving up after 4 attempts.
WARNING:apache_beam.runners.direct.executor:A task failed with exception: tzinfo
WARNING:apache_beam.runners.direct.executor:A task failed with exception: tzinfo
Traceback (most recent call last):
File "/home/gcpuser/data-science-on-gcp/04_streaming/realtime/./avg01.py", line 82, in
run(project=args['project'], bucket=args['bucket'], region=args['region'])
File "/home/gcpuser/data-science-on-gcp/04_streaming/realtime/./avg01.py", line 61, in run
(all_events
File "/home/gcpuser/.local/lib/python3.9/site-packages/apache_beam/pipeline.py", line 598, in exit
self.result.wait_until_finish()
File "/home/gcpuser/.local/lib/python3.9/site-packages/apache_beam/runners/direct/direct_runner.py", line 588, in wait_until_finish
self._executor.await_completion()
File "/home/gcpuser/.local/lib/python3.9/site-packages/apache_beam/runners/direct/executor.py", line 432, in await_completion
self._executor.await_completion()
File "/home/gcpuser/.local/lib/python3.9/site-packages/apache_beam/runners/direct/executor.py", line 480, in await_completion
raise update.exception
File "/home/gcpuser/.local/lib/python3.9/site-packages/apache_beam/runners/direct/executor.py", line 370, in call
self.attempt_call(
File "/home/gcpuser/.local/lib/python3.9/site-packages/apache_beam/runners/direct/executor.py", line 416, in attempt_call
result = evaluator.finish_bundle()
File "/home/gcpuser/.local/lib/python3.9/site-packages/apache_beam/runners/direct/transform_evaluator.py", line 704, in finish_bundle
data = self._read_from_pubsub(self.source.timestamp_attribute)
File "/home/gcpuser/.local/lib/python3.9/site-packages/apache_beam/runners/direct/transform_evaluator.py", line 693, in _read_from_pubsub
results = [_get_element(rm.message) for rm in response.received_messages]
File "/home/gcpuser/.local/lib/python3.9/site-packages/apache_beam/runners/direct/transform_evaluator.py", line 693, in
results = [_get_element(rm.message) for rm in response.received_messages]
File "/home/gcpuser/.local/lib/python3.9/site-packages/apache_beam/runners/direct/transform_evaluator.py", line 681, in _get_element
timestamp = Timestamp.from_utc_datetime(message.publish_time)
File "/home/gcpuser/.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

@atee12
Copy link

atee12 commented Oct 26, 2022

i do have similar erro as well:

ERROR:apache_beam.runners.direct.executor:Giving up after 4 attempts.
WARNING:apache_beam.runners.direct.executor:A task failed with exception: tzinfo
Traceback (most recent call last):
File "/home/g12_sean_aye/code_sub_utility.py", line 132, in
ret.wait_until_finish()
File "/home/g12_sean_aye/.local/lib/python3.9/site-packages/apache_beam/runners/direct/direct_runner.py", line 588, in wait_until_finish
self._executor.await_completion()
File "/home/g12_sean_aye/.local/lib/python3.9/site-packages/apache_beam/runners/direct/executor.py", line 432, in await_completion
self._executor.await_completion()
File "/home/g12_sean_aye/.local/lib/python3.9/site-packages/apache_beam/runners/direct/executor.py", line 480, in await_completion
raise update.exception
File "/home/g12_sean_aye/.local/lib/python3.9/site-packages/apache_beam/runners/direct/executor.py", line 370, in call
self.attempt_call(
File "/home/g12_sean_aye/.local/lib/python3.9/site-packages/apache_beam/runners/direct/executor.py", line 416, in attempt_call
result = evaluator.finish_bundle()
File "/home/g12_sean_aye/.local/lib/python3.9/site-packages/apache_beam/runners/direct/transform_evaluator.py", line 704, in finish_bundle
data = self._read_from_pubsub(self.source.timestamp_attribute)
File "/home/g12_sean_aye/.local/lib/python3.9/site-packages/apache_beam/runners/direct/transform_evaluator.py", line 693, in _read_from_pubsub
results = [_get_element(rm.message) for rm in response.received_messages]
File "/home/g12_sean_aye/.local/lib/python3.9/site-packages/apache_beam/runners/direct/transform_evaluator.py", line 693, in
results = [_get_element(rm.message) for rm in response.received_messages]
File "/home/g12_sean_aye/.local/lib/python3.9/site-packages/apache_beam/runners/direct/transform_evaluator.py", line 681, in _get_element
timestamp = Timestamp.from_utc_datetime(message.publish_time)
File "/home/g12_sean_aye/.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

@atee12
Copy link

atee12 commented Oct 29, 2022

Manage to resolve this by upgrading the google cloud core, and assigning the correct access role. Follow some of the Pub/Sub toutorial to eaable the APIs and

I was running the .py code from gcp cloud console.

Name: google-cloud-core
Version: 2.3.2

I have set following roles in the service account and the key from that service acc is set as enviroment variable in the gcp cloud console.
BigQuery Admin
Dataflow Admin
Pub/Sub Admin
Storage Object Admin

Hope this can help to resolve! Good Luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants