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

Replace pytz dependency with zoneinfo. Fix #2958 #3161

Merged
merged 7 commits into from
Jul 26, 2023

Conversation

willthong
Copy link
Contributor

Pull Request Checklist

Resolves: #2958

  • Ensured tests pass and (if applicable) updated functional test output
  • Conformed to code style guidelines by running appropriate linting tools
  • Added tests for changed code
  • Updated documentation for changed code

Also wasn't sure how to add tests for changed code - sorry.

@justinmayer
Copy link
Member

Hey Will. Many thanks for the contribution. There seems to be one or more CI failures with tests and linters. Would you be so kind as to take a look and see what needs to be done to fix those?

@willthong
Copy link
Contributor Author

willthong commented Jul 24, 2023

Apologies, I've fixed the linting error but am stuck on the Python 3.8 test! Here's what I've done to troubleshoot:

  • Locally, checked that Poetry is at the right version (poetry env info returns Python 3.8.17 as expected)
  • Run poetry install to make sure packages are downloaded per the pyproject.toml file
  • Run poetry show to verify that backports-zoneinfo 0.2.1 is installed as expected
  • Run invoke tests, which confirms that on Python 3.8.17, all 264 tests passed

Would be grateful for any pointers as to why the test is failing on the server but not locally!

@justinmayer
Copy link
Member

justinmayer commented Jul 24, 2023

Let me know if you have any trouble fixing the import order that is causing the linter conformance failure.

The solution to the "works locally but not in CI" mystery is that we haven't yet fully switched over to pyproject-based builds, which means the canonical dependencies are still defined in setup.py, so the CI environment uses python -m pip install -e . instead of poetry install. The latter will install the dependency you added but the former will not. Sorry for the confusion. Eventually we will get around to fully switching and then removing setup.py altogether.

In the interim, I rectified that problem by adding backports-zoneinfo to setup.py via commit 85cb041 to this PR's branch.

With that problem fixed, the next issue has reared its head, which is a test failure in the Windows test environment. Could you take a look at the test failure output and see what you can come up with to fix that failure?

@willthong
Copy link
Contributor Author

Thanks @justinmayer! Useful to know. I think maybe maintainers need to approve tests so I'm not completely sure, but I believe the Windows problem may be because Windows doesn't have an IANA database so I should have used backports-zoneinfo[tzdata] to retrieve a PyPi version of that database. As for the linting error, that seems to have been a misordering of dependencies and I believe I've now fixed it.

@willthong willthong force-pushed the pytz-replacement branch 2 times, most recently from a8c9fe3 to aae2fe2 Compare July 24, 2023 16:20
@justinmayer
Copy link
Member

Thanks for fixing (hopefully) the Windows test failure.

By the way, it's usually not a good idea to add formatting changes to a PR that aren't related to changed lines of code. In this case, for example, there are a ton of changed lines in this PR that are probably the result of running Black, et al, on entire file(s). Those kinds of widespread formatting changes are usually best done in the context of separate PRs. Otherwise it's too hard to see the actual relevant code changes, because they are lost in a sea of formatting changes.

So my suggestion would be to replace the last commit with one that just addresses problems that are fixed by pre-commit, as that tool should only operate on changed lines of code.

@willthong
Copy link
Contributor Author

Thank you! I realised that I need to turn off my Black linter after I'd pushed, so I'll remember to avoid doing so next time. I ought also to check the diff to make sure I'm not inadvertently pushing more changes than I expect.

Hopefully the final commit with linting and substantive tests all passing now.

Copy link
Member

@justinmayer justinmayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for your work on this, Will. Nicely done! Tests are all now passing, and I don't see any glaring problems jumping out at me.

@avaris: Would you take a quick look at this, just as a second pair of eyes?

@willthong
Copy link
Contributor Author

Brilliant, thanks Justin! I am conscious that the tests still depend on pytz - if helpful, I'd be happy to remove this dependency (perhaps as a separate PR).

@justinmayer
Copy link
Member

Many thanks for that offer, Will. Removing pytz as a dependency in the tests would indeed be helpful, and a separate PR seems like a good place to do that.

If @avaris doesn't have time to chime in within the next few hours, I'll go ahead and merge this so we can proceed. Any needed follow-up adjustments can be done "in post", as it were. 😊

@justinmayer justinmayer requested a review from avaris July 26, 2023 07:07
@justinmayer justinmayer changed the title Fixes #2958. Replaces pytz dependency with zoneinfo. Replace pytz dependency with zoneinfo. Fix #2958 Jul 26, 2023
@justinmayer justinmayer self-requested a review July 26, 2023 10:47
Copy link
Member

@justinmayer justinmayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you please make the same improvement noted above in the other two relevant files in this PR? That is:

  • pelican/tools/pelican_quickstart.py
  • pelican/utils.py

@willthong
Copy link
Contributor Author

Thanks! Grepped for all zoneinfo references and all done.

Copy link
Member

@justinmayer justinmayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks to @willthong for the enhancement and to @avaris for reviewing! 🌟

@justinmayer justinmayer merged commit 1d2bf8e into getpelican:master Jul 26, 2023
@willthong willthong deleted the pytz-replacement branch July 26, 2023 17:27
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

Successfully merging this pull request may close these issues.

Replace pytz dependency with zoneinfo
4 participants