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

parse: Support pandas 2.x #1436

Merged
merged 3 commits into from Mar 11, 2024
Merged

parse: Support pandas 2.x #1436

merged 3 commits into from Mar 11, 2024

Conversation

emollier
Copy link
Contributor

@emollier emollier commented Mar 10, 2024

Replace parse_time_string() by parse_datetime_string_with_reso() to gain pandas 2.0 compatitibility.

This change was hinted by s3v in Debian bug #1044079 and allows the resolution of the github issue #1303 appropriately.

Thanks: s3v c0llapsed@yahoo.it

PS: filling the mandatory form below for your convenience.

Description of proposed changes

This change modifies augur/parse.py by replacing parse_time_string() by parse_datetime_string_with_reso() in order to gain pandas 2.0 compatitibility.

Related issue(s)

#1303

Checklist

  • Checks pass with the newer pandas 2 versions, but I have not tested how things behaved with the older pandas 1.x, so there are good chances some further adjustments will be necessary if you want to support both.
  • If making user-facing changes, add a message in CHANGES.md summarizing the changes in this PR

Replace parse_time_string() by parse_datetime_string_with_reso() to
gain pandas 2.0 compatitibility.

This change was hinted by s3v in [Debian bug #1044079] and allows the
resolution of the github issue nextstrain#1303 appropriately.

[Debian bug #1044079]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1044079#46

Thanks: s3v <c0llapsed@yahoo.it>
Signed-off-by: Étienne Mollier <emollier@debian.org>
Copy link
Member

@victorlin victorlin left a comment

Choose a reason for hiding this comment

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

@emollier thanks for the PR. We have no current plans to support pandas version 2 and will continue to pin to 1.x for PyPI/Bioconda until we're ready to support 2.x in all other parts of the codebase.

In the meantime, this specific call can be made compatible with both versions for environments that allow more flexible dependency versions.

augur/parse.py Outdated Show resolved Hide resolved
The initial pandas 2.x change does not work with pandas 1.x.  In 1.x, parse_datatime_string_with_reso is a cdef function which cannot be called ouside of the Cython module.  CI error:

        E   AttributeError: module 'pandas._libs.tslibs.parsing' has no attribute 'parse_datetime_string_with_reso'

Trapping AttributeError and falling back to code written for pandas 1.x should work.

Co-authored-by: Victor Lin <13424970+victorlin@users.noreply.github.com>
@emollier
Copy link
Contributor Author

Thank you for your time and your review, I took some time to test it in various conditions to make sure it works as expected, and saw no issues indeed. Even if you keep the pin to pandas 1.x, this may facilitate the change to pandas 2.x series when you feel that you are ready for it.

Noting that the long-term solution here is to replace this call with a public API call as mentioned in #601 (review).

I very much agree about an implementation using the public API: this would avoid further risks of abrupt breakage without notice or guidance from pandas. I'm afraid however that I'm not comfortable enough with augur's field of application nor pandas itself to be able to propos such a change myself. :/

@victorlin
Copy link
Member

@emollier thanks for the update! I've just approved the test runs. Once they pass, I'll add a changelog entry and get this merged.

@emollier
Copy link
Contributor Author

You're welcome,
Have a nice day, :)
Étienne.

Copy link

codecov bot commented Mar 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.67%. Comparing base (7197b9f) to head (0b45b71).

❗ Current head 0b45b71 differs from pull request most recent head 93caf05. Consider uploading reports for the commit 93caf05 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1436      +/-   ##
==========================================
+ Coverage   68.66%   68.67%   +0.01%     
==========================================
  Files          69       69              
  Lines        7554     7557       +3     
  Branches     1851     1851              
==========================================
+ Hits         5187     5190       +3     
  Misses       2089     2089              
  Partials      278      278              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@victorlin victorlin changed the title parse.py: port to pandas 2. parse: Support pandas 2.x Mar 11, 2024
@victorlin victorlin merged commit 82bdf45 into nextstrain:master Mar 11, 2024
19 checks passed
@victorlin victorlin mentioned this pull request Apr 18, 2024
5 tasks
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.

None yet

3 participants