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

Working environment for Python 3.9 (pin to !=3.9.0) #885

Merged
merged 18 commits into from
Jan 15, 2021
Merged

Conversation

valeriupredoi
Copy link
Contributor

@valeriupredoi valeriupredoi commented Nov 26, 2020

Changes applied (so far):

Closes #881

@valeriupredoi valeriupredoi added the installation Installation problem label Nov 26, 2020
@valeriupredoi
Copy link
Contributor Author

OK a few notes:

  • I reverted back to fiona installed from PyPi (they have built wheels for manylinux now, but I am not sure how reliable this will be in the future, we may have to switch to installing it from conda-forge since they put it bluntly that they don't support PyPi installations inside conda environments)
  • the mock error is weird, I documented and raised it here mock throws ValueError when spec_arg is an ndarray testing-cabal/mock#493

@valeriupredoi
Copy link
Contributor Author

OK I have now isolated the issue with unittest.mock - it doesn't like an ndarray spec arg - pretty straightforward, it likes every other type tho:

import numpy as np

from unittest import mock as mg

ob = mg.Mock(spec=[4, 4])
print("spec is list, mock is", ob)

ob = mg.Mock(spec=["4", "4"])
print("spec is list of str, mock is", ob)

ob = mg.Mock(spec=(4, 4))
print("spec is tuple, mock is", ob)

ob = mg.Mock(spec="cow")
print("spec is string, mock is", ob)

ob = mg.Mock(spec=22)
print("spec is int, mock is", ob)

ob = mg.Mock(spec=np.array([4, 4]))
print("spec is ndarray, mock is", ob)

I am going to open a bug report on Her Majesty Python

@valeriupredoi
Copy link
Contributor Author

OK issue open in Python: https://bugs.python.org/issue42586

@valeriupredoi
Copy link
Contributor Author

OK I have now isolated the issue with unittest.mock - it doesn't like an ndarray spec arg - pretty straightforward, it likes every other type tho:

import numpy as np

from unittest import mock as mg

ob = mg.Mock(spec=[4, 4])
print("spec is list, mock is", ob)

ob = mg.Mock(spec=["4", "4"])
print("spec is list of str, mock is", ob)

ob = mg.Mock(spec=(4, 4))
print("spec is tuple, mock is", ob)

ob = mg.Mock(spec="cow")
print("spec is string, mock is", ob)

ob = mg.Mock(spec=22)
print("spec is int, mock is", ob)

ob = mg.Mock(spec=np.array([4, 4]))
print("spec is ndarray, mock is", ob)

I am going to open a bug report on Her Majesty Python

@bouweandela @zklaus you guys have more experience with mock than meself, is this something normal (also see our esmpy regrid tests that fail coz of this)? 🍺

@valeriupredoi
Copy link
Contributor Author

OK proves out that was inded a bug in 3.9.0 that was/is being fixed and will be in 3.9.1, so we'll just hold off using 3.9.0 and wait for 3.9.1 that already has an RC and looks like it'll roll out on Friday, 11 Dec - see full discussion https://bugs.python.org/issue42586 and the Python schedules at https://www.python.org/dev/peps/pep-0596/#lifespan

@valeriupredoi valeriupredoi changed the title Working environment for Python 3.9 Working environment for Python 3.9 (pin to !=3.9.0) Dec 7, 2020
@zklaus
Copy link

zklaus commented Dec 8, 2020

Thanks for checking this, @valeriupredoi!

@valeriupredoi
Copy link
Contributor Author

big day for Python 3.9.1 release tomorrow @zklaus 😁 Hopefully by next week we'll have a very modern and very working environment hehe

@valeriupredoi
Copy link
Contributor Author

an update to this one: the environment now builds and does it with python 3.9.1 unfortunately the new version from conda doesn't include the patch for mock.py:

python                    3.9.1           hffdb5ce_2_cpython    conda-forge

is the latest off conda-forge (uploaded on December 21st, conda list) and should contain the updated library mock with the fix at l.409 - but no, I don't know why it didn't make it - possibly next version, agh

@bouweandela
Copy link
Member

Maybe you could just mark the failing tests as should be skipped in python 3.9?

@valeriupredoi
Copy link
Contributor Author

valeriupredoi commented Jan 5, 2021

no coz the fix is there, proves out that they've not released 3.9.x after December 7th https://github.com/python/cpython/releases
so my bets are 3.9.2 will work

@bouweandela
Copy link
Member

So maybe you can just mark the test for skipping with python 3.9.0 and 3.9.1? If the only problem is some unit test failing because of the test code (not because of a problem with code in the ESMValCore), we can probably just start supporting Python 3.9.

@valeriupredoi
Copy link
Contributor Author

Maybe you could just mark the failing tests as should be skipped in python 3.9?

OK - maybe the best solution since they defo don't work in 3.9.0 and 3.9.1 and even if they will work in 3.9.2 it's still 3.9.x - how do you think - xfail them or skip them?

@valeriupredoi
Copy link
Contributor Author

So maybe you can just mark the test for skipping with python 3.9.0 and 3.9.1? If the only problem is some unit test failing because of the test code (not because of a problem with code in the ESMValCore), we can probably just start supporting Python 3.9.

yeah was just writing my comment at the same time 😁

@valeriupredoi
Copy link
Contributor Author

valeriupredoi commented Jan 5, 2021

OK things are in good shape, apart from a weird test fail (that is for Python 3.8 too, documented in #927 ) and lots of segfaults and the obvious issue that you can't install esmvalcore from pip with Python=3.9 (since it's a Python 3.8 build on pip), the GA tests and the ones on Circle are OK https://github.com/ESMValGroup/ESMValCore/actions (look for "test GA for Python 3.9" eg these) - I think we can do 2.2.0 with Python 3.9 easily -> @jvegasbsc

@valeriupredoi
Copy link
Contributor Author

right - this should be ready for merge! All major (non-silly, like installing esmvalcore from conda or pypi in a Python 3.9 environment, with the builds being done with Python 3.8) tests and builds work! 🍺

@valeriupredoi
Copy link
Contributor Author

@schlunma @jvegasbsc @stefsmeets @bouweandela I need an approval of this the sooner the better guys please - we should have support for Python 3.9 for the 2.2 release and it'd be better to have a few days in mainstream before we make the release just to be sure all stuff's working well 👍 🍺

Copy link
Contributor

@stefsmeets stefsmeets left a comment

Choose a reason for hiding this comment

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

Looks good, no obvious red flags!👍
(Soon enough? 😅)

@valeriupredoi
Copy link
Contributor Author

cheers @stefsmeets mate 🍺

@valeriupredoi valeriupredoi merged commit e01137f into master Jan 15, 2021
@valeriupredoi valeriupredoi deleted the python39 branch January 15, 2021 12:43
@jvegreg jvegreg added the enhancement New feature or request label Feb 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request installation Installation problem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Relax environment back to Python=3.9
5 participants