-
Notifications
You must be signed in to change notification settings - Fork 24
Python client datetimes are influenced by time zone #298
Comments
I met the same issue, does anybody have a solution? |
Hi all, we're working on this :) It comes from the fact that the we've used the local date time with your system time zone when sending data to TypeDB. It shouldn't be too hard to resolve but we want to make sure to be systematic about it. We're hoping to have this fixed and released early next week |
## What is the goal of this PR? Enables the BDD tests to check timezone-invariance of inserting and reading datetime attributes. ## What are the changes implemented in this PR? - During deserialization of datetime, we incorrectly used `fromtimestamp` function. This function is environment timezone-sensitive. The correct function to use is `utcfromtimestamp` which converts the milliseconds since epoch to UTC datetime object. This conforms to the serialization process: we convert datetime object to milliseconds since epoch assuming the datetime is in UTC. - Added step which sets environment timezone to `time_zone_label` - Fixed parsing of class `AttributeMatcher` and `ValueMatcher`. Fixes #298.
@hezhichenghzc @steenstral FYI the release is out on github & pip, please let us know if there are any remaining issues :) |
@flyingsilverfin Unfortunately I cannot test it yet, because there is a version mismatch between te client ( Error traceback
Traceback (most recent call last):
File "c:\<path_to_workspace>\datetime_example.py", line 55, in <module>
main()
File "c:\<path_to_workspace>\datetime_example.py", line 9, in main
with TypeDB.core_client(TypeDB.DEFAULT_ADDRESS) as client:
File "C:\<path_to_workspace>\venv\lib\site-packages\typedb\client.py", line 70, in core_client
return _CoreClient(address, parallelisation)
File "C:\<path_to_workspace>\venv\lib\site-packages\typedb\connection\core\client.py", line 35, in __init__
self._channel, self._stub = self.new_channel_and_stub()
File "C:\<path_to_workspace>\venv\lib\site-packages\typedb\connection\core\client.py", line 52, in new_channel_and_stub
return channel, _CoreStub(channel)
File "C:\<path_to_workspace>\venv\lib\site-packages\typedb\connection\core\stub.py", line 42, in __init__
raise e
File "C:\<path_to_workspace>\venv\lib\site-packages\typedb\connection\core\stub.py", line 39, in __init__
self._stub.connection_open(connection_open_req())
File "C:\<path_to_workspace>\venv\lib\site-packages\grpc\_channel.py", line 1030, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "C:\<path_to_workspace>\venv\lib\site-packages\grpc\_channel.py", line 910, in _end_unary_response_blocking
raise _InactiveRpcError(state) # pytype: disable=not-instantiable
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "failed to connect to all addresses; last error: UNAVAILABLE: ipv6:%5B::1%5D:1729:
WSA Error"
debug_error_string = "UNKNOWN:failed to connect to all addresses; last error: UNAVAILABLE: ipv6:%5B::1%5D:1729: WSA Error {grpc_status:14, created_time:"2023-07-06T08:58:42.245912889+00:00"}"
> I saw this issue also passing by on Discord. Is there a way I can test this patch update, or do I need to wait for the new TypeDB server release? |
TypeDB 2.19 is available on the Releases page (https://github.com/vaticle/typedb/releases/tag/2.19.0), and in package managers like apt and brew. |
I updated my TypeDB server version, and I can confirm that it is working and that I now get the expected result. Thank you for solving this issue! |
Description
The Python client API is inconsistent with time zones. When a
datetime
attribute is inserted, everything is fine. However, when this same attribute is queried, there is an offset of 2 hours (UTC+01:00 + summertime).Environment
venv
with onlytypedb-client
installedReproducible Steps
typedb server # Version 2.17.0
Expected Output
I would expect to retrieve back the exact same dates as inserted in the
query().insert()
:Actual Output
Instead, there is a clear offset in time, 1 hour in wintertime and 2 hours in summertime (exactly UTC+01:00).
Additional information
Doing a read data
match
query in thedatetime_issue
keyspace inside of TypeDB Studio 2.11.0 on Windows, does NOT have this time offset. This means that the problem is clearly in the Python API, especially in thetransaction.query().match(query)
method.When the system time in Windows is changed to UTC+00:00 and summer-/wintertime is disabled, there is no time offset.
The text was updated successfully, but these errors were encountered: