Skip to content

CI/TST: fix parquet tz test returning pytz fixed offset (pyarrow 18) #60143

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

Merged
merged 2 commits into from
Oct 30, 2024

Conversation

jorisvandenbossche
Copy link
Member

This should fix the parquet failures that started occurring on main. PyArrow 18 was just released, and this release did not change anything regarding timezones AFAIK (but the tests were only skipping something for pyarrow<18)

@jorisvandenbossche jorisvandenbossche added CI Continuous Integration Compat pandas objects compatability with Numpy or Python functions labels Oct 30, 2024
@jorisvandenbossche jorisvandenbossche added this to the 2.3 milestone Oct 30, 2024
@@ -977,18 +976,6 @@ def test_timestamp_nanoseconds(self, pa):
def test_timezone_aware_index(self, request, pa, timezone_aware_date_list):
pytest.importorskip("pyarrow", "11.0.0")

if (
timezone_aware_date_list.tzinfo != datetime.timezone.utc
and pa_version_under18p0
Copy link
Member Author

Choose a reason for hiding this comment

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

This was added in the PR removing our default usage of pytz. @mroeschke you were assuming that pyarrow would have fixed this in time for 18.0?

Copy link
Member Author

Choose a reason for hiding this comment

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

(I changed the test to test the actual (although undesired) behaviour, just to ensure we are still testing the behaviour in general, and then this should also start failing once pyarrow fixes it, just like with the xfail)

Copy link
Member

Choose a reason for hiding this comment

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

you were assuming that pyarrow would have fixed this in time for 18.0?

I don't recall anymore; this might been an unnecessary "is pyarrow installed" check.

@jorisvandenbossche
Copy link
Member Author

The relevant builds that were failing in main (macos and arm) are passing here

if timezone_aware_date_list.tzinfo != datetime.timezone.utc:
# pyarrow returns pytz.FixedOffset while pandas constructs datetime.timezone
# https://github.com/pandas-dev/pandas/issues/37286
import pytz
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import pytz
pytz = pytest.importorskip("pytz")

I suppose your prior import was safe since having pyarrow installed would require pytz to also be installed here? IMO would be nice to extra safe with importorskip in case that ever changes :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I actually first wrote it like that, but then intentionally did a plain import. Because otherwise, if we would for some reason no longer have pytz in the test builds that have pyarrow, we would silently never run this test. I would rather be notified at that point that we need pytz.

Now, while writing that, if the env doesn't have pytz, then pyarrow would actually fall back to another tz implementation. We could also write the test more generically so it does not only work with pytz. But I think at the moment we install pytz in almost all test envs?

Copy link
Member

Choose a reason for hiding this comment

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

But I think at the moment we install pytz in almost all test envs?

Yeah tests envs where we install optional dependencies will have pyarrow and pytz. Sure I'm OK then skipping the importorskip

Copy link
Member

Choose a reason for hiding this comment

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

Actually looks like we need to install pytz for the pyarrow nightly build i.e. add pyarrow to actions-311-pyarrownightly.yaml https://github.com/pandas-dev/pandas/actions/runs/11595223185/job/32283356899?pr=60143

(I guess my above comment didn't really apply to our one-off builds like the pyarrow nightly)

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, made the test robust with both with and without pytz; seems fine to test both cases

@mroeschke mroeschke merged commit 9cd4a28 into pandas-dev:main Oct 30, 2024
44 of 51 checks passed
@mroeschke
Copy link
Member

Thanks @jorisvandenbossche

Copy link

lumberbot-app bot commented Oct 30, 2024

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout 2.3.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 9cd4a281c42838cd32261b92a55aed830ebeae03
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #60143: CI/TST: fix parquet tz test returning pytz fixed offset (pyarrow 18)'
  1. Push to a named branch:
git push YOURFORK 2.3.x:auto-backport-of-pr-60143-on-2.3.x
  1. Create a PR against branch 2.3.x, I would have named this PR:

"Backport PR #60143 on branch 2.3.x (CI/TST: fix parquet tz test returning pytz fixed offset (pyarrow 18))"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

@jorisvandenbossche jorisvandenbossche deleted the ci-fix-parquet-tz branch October 30, 2024 21:29
jorisvandenbossche added a commit to jorisvandenbossche/pandas that referenced this pull request Oct 31, 2024
…andas-dev#60143)

* CI/TST: fix parquet tz test returning pytz fixed offset (pyarrow 18)

* only convert to pytz if installed

(cherry picked from commit 9cd4a28)
@jorisvandenbossche
Copy link
Member Author

Manual backport -> #60151

jorisvandenbossche added a commit that referenced this pull request Oct 31, 2024
…set (pyarrow 18) (#60143) (#60151)

CI/TST: fix parquet tz test returning pytz fixed offset (pyarrow 18) (#60143)

* CI/TST: fix parquet tz test returning pytz fixed offset (pyarrow 18)

* only convert to pytz if installed

(cherry picked from commit 9cd4a28)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous Integration Compat pandas objects compatability with Numpy or Python functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants