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

fix: human time must not hard set the timezone #350

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

sdenef-adeo
Copy link
Contributor

Hello,

utils.get_human_time() function format a UNIX timestamp as string to be stored into BigQuery.
But it replaces the timezone without dealing with the UTC time.

Using datetime.fromtimestamp() do the job well.

Tests have been updated accordingly.

Regards,
Sébastien

@sdenef-adeo
Copy link
Contributor Author

Hello @lvaylet,

I don't understand why some checks failed as it works well and I'm pretty sure the method signature is correct.
Any help will be really appreciated.

Regards,
Sébastien

@lvaylet
Copy link
Collaborator

lvaylet commented Oct 4, 2023

Hello @sdenef-adeo, I will take a look later today.

@lvaylet
Copy link
Collaborator

lvaylet commented Oct 4, 2023

@sdenef-adeo The pytype stage of make lint completes successfully on my machine after removing timestamp=:

    dt_tz = datetime.fromtimestamp(timestamp, tz=to_zone)

But then the safety stage fails because of CVEs in GitPython and certifi.

@sdenef-adeo
Copy link
Contributor Author

Hello @lvaylet,

👌
AFAIU those CVE are not due to the code provided here. Is there any other PR I need to merge into this one to fix those CVE?

@lvaylet
Copy link
Collaborator

lvaylet commented Oct 5, 2023

I quickly checked yesterday but was unable to spot the exact source(s). These CVEs were probably reported recently. I wil work on a separate PR tomorrow and let you know when you can merge.

@lvaylet
Copy link
Collaborator

lvaylet commented Oct 6, 2023

@sdenef-adeo I just created #352 and will start investigate soon.

@lvaylet
Copy link
Collaborator

lvaylet commented Oct 6, 2023

@sdenef-adeo Done. Can you merge fb35d87 into your PR?

@sdenef-adeo
Copy link
Contributor Author

merged

@lvaylet
Copy link
Collaborator

lvaylet commented Oct 6, 2023

Then I guess you also have to remove timestamp= from your code, as highlighted above.

@lvaylet
Copy link
Collaborator

lvaylet commented Oct 13, 2023

Thanks @sdenef-adeo. Now that all checks complete successfully, let me reproduce the (bad) behavior and check this PR fixes it.

@lvaylet
Copy link
Collaborator

lvaylet commented Oct 13, 2023

I just confirmed that the current code does not return the expected values.

For example:

$ python
Python 3.9.15 (main, Nov  5 2022, 10:20:53) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from slo_generator.utils import get_human_time
>>> get_human_time(1702660513.987654, timezone='Europe/Paris')
'2023-12-15T17:15:13.987654+01:00'
>>> get_human_time(1565092435, timezone='Europe/Paris')
'2019-08-06T11:53:55.000000+02:00'

According to Epoch & Unix Timestamp Conversion Tools, the first call should return '2023-12-15T18:15:13.987654+01:00'. The second call should return '2019-08-06T13:53:55.000000+02:00'.

Your version returns the right values.

Can you rebase your branch as it is now out-of-date? Then I will merge this PR.

@sdenef-adeo
Copy link
Contributor Author

for sure @lvaylet

It should be OK now.

@lvaylet
Copy link
Collaborator

lvaylet commented Oct 13, 2023

Not quite. GitHub still reports 'This branch is out-of-date with the base branch'. I will move forward anyway, as these changes do not overlap with anything in recent PRs.

@lvaylet lvaylet enabled auto-merge (squash) October 13, 2023 13:58
@lvaylet
Copy link
Collaborator

lvaylet commented Oct 13, 2023

Unfortunately, GitHub is preventing me from moving forward.

Your master branch seems to lag behind by 2 commits:

image

Can you update your fork, then rebase your adeo:fix/timestamp_human_tz branch too?

@sdenef-adeo
Copy link
Contributor Author

I understand. It should be due to my "master branch" on the fork repo is out-of-date. I will do.

auto-merge was automatically disabled October 13, 2023 14:07

Head branch was pushed to by a user without write access

@lvaylet lvaylet merged commit 1948694 into google:master Oct 13, 2023
10 checks passed
@lvaylet
Copy link
Collaborator

lvaylet commented Oct 13, 2023

All good. Thanks for your patience @sdenef-adeo!

@lvaylet lvaylet self-requested a review October 13, 2023 14:24
@lvaylet lvaylet added the bug Something isn't working label Oct 13, 2023
@sdenef-adeo sdenef-adeo deleted the fix/timestamp_human_tz branch October 13, 2023 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants