openreview / openreview-py

Official Python client library for the OpenReview API
https://openreview-py.readthedocs.io/en/latest/
MIT License
142 stars 20 forks source link

datetime_millis util function could return wrong value #2270

Open xkopenreview opened 1 month ago

xkopenreview commented 1 month ago

found this when executing test_venue_configuration from a different timezone

the pytest fail at assertion of

invitation = pc_client.get_invitation('ICLR.cc/2025/Conference/Submission1/-/Confidential_Comment')

the super confidential comment invitation is created but process function didn't create paper specific confidential comment invitations because the super invitation is not active yet.

the cdate set in pytest is correct which is

now - datetime.timedelta(minutes=1)

but when it's converted to mili seconds by tools.datetime_millis, the result was wrong which caused the super invitation to be inactive.

this is because

utcfromtimestamp(0)

was treated as local time

and it looks like utcfrormtimestamp function will be deprecated soon

image
melisabok commented 1 month ago

This method is deprecated and we should update the code with the new method. I'm aware of that.

xkopenreview commented 1 month ago

one possible fix: to change

epoch = datetime.datetime.utcfromtimestamp(0)
return int((dt - epoch).total_seconds() * 1000)

to

epoch=datetime.datetime.fromtimestamp(0, tz=datetime.timezone.utc)
return int((dt.timestamp() - epoch.timestamp())) * 1000

and

now = datetime.datetime.utcnow()

to

now = datetime.datetime.now(datetime.timezone.utc)
melisabok commented 1 month ago

do you want to make the change in the repo?