-
Notifications
You must be signed in to change notification settings - Fork 13
Creating a task fails with "expected google.protobuf.Timestamp got datetime.datetime." #147
Comments
I found another issue related to this, and I found the solution. The python link to "View on github" on this page: https://cloud.google.com/tasks/docs/samples/cloud-tasks-taskqueues-new-task links to this python sample: https://github.com/GoogleCloudPlatform/python-docs-samples/blob/HEAD/appengine/flexible/tasks/snippets.py I think that documentation needs to be updated to link to the samples in this repo. Is that something I should raise here? Here's a link to the solution for anyone that might find this issue: #62 (comment) |
This has been fixed: GoogleCloudPlatform/python-docs-samples#6509. However, @busunkim96 is it possible to require either datetime or the timestamp protobuf? |
One potential issue with using a datetime is that functions like The cloudtasks API (direct API calls) rejects ISO8601 datetimes that don't contain a timezone. But submitting with It looks like That being said, I have another issue open where I mention that its hard to tell when to use certain types of objects when using this library: #148 |
Hmm. Accepting both protobuf timestamps and Python datetimes is by design. The proto-plus library is supposed to convert datetimes to protobufs (https://proto-plus-python.readthedocs.io/en/stable/marshal.html). It looks like that's not happening as expected here. I've assigned this issue to myself to investigate more closely. @jceresini Thanks for the heads up, it sounds like our samples should attach timezones to datetime objects per recommendation in the Python docs so there are no accidental conversions: https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow
|
Follow up to discussion in googleapis/python-tasks#147 (comment). If this is an OK blanket recommendation to make, I will follow up with a PR to adjust all the calls to `datetime.datetime` in this repository. For supporting documentation, see warnings for these two methods: - https://docs.python.org/3/library/datetime.html#datetime.datetime.utcfromtimestamp - https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow
Fixed in #6581 |
Thanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Please run down the following list and make sure you've tried the usual "quick fixes":
If you are still having issues, please be sure to include as much information as possible:
Environment details
python --version
3.9.6pip --version
21.1.3google-cloud-tasks
version:pip show google-cloud-tasks
2.5.1Steps to reproduce
python create_app_engine_queue_task.py --project my-project --location us-central1 --in_seconds 30 --queue myqueue
Code example
See python code sample here: https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/appengine/flexible/tasks/create_app_engine_queue_task.py
Also linked to from the google cloud documentation
Stack trace
Making sure to follow these steps will guarantee the quickest resolution possible.
Thanks!
The text was updated successfully, but these errors were encountered: