Skip to content

CI Adds CPython 3.10 testing [python-dev] #20942

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

Closed
wants to merge 18 commits into from

Conversation

thomasjpfan
Copy link
Member

This PR adds python 3.10 testing to GitHub actions. Currently numpy has a 3.10 wheel to use and scipy needs to be build from source.

With yearly Python releases, I think it is good to have this type of testing set up.

@thomasjpfan thomasjpfan marked this pull request as draft September 4, 2021 22:23
@ogrisel
Copy link
Member

ogrisel commented Sep 6, 2021

Thanks. The pip build error is not very helpful:

WARNING: Discarding file:///home/runner/work/scikit-learn/scikit-learn. Command errored out with exit status 1: /opt/hostedtoolcache/Python/3.10.0-rc.1/x64/bin/python /opt/hostedtoolcache/Python/3.10.0-rc.1/x64/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpo9d1isjo Check the logs for full command output.
ERROR: Command errored out with exit status 1: /opt/hostedtoolcache/Python/3.10.0-rc.1/x64/bin/python /opt/hostedtoolcache/Python/3.10.0-rc.1/x64/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpo9d1isjo Check the logs for full command output.

shall we run pip with --verbose when building scikit-learn (and scipy?).

@ogrisel
Copy link
Member

ogrisel commented Sep 6, 2021

This build would probably benefit from using ccache with a reusable ccache folder.

Edit: apparently ccache integration can be achieved with https://github.com/hendrikmuhs/ccache-action

Copy link
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

It seems to be fast enough. @thomasjpfan why is this PR still in draft mode? Do you have other things in mind?

For scikit-learn, we could use cibuildwheel instead of a traditional build + test steps and publish the resulting wheel to https://anaconda.org/scipy-wheels-nightly/scikit-learn/files in addition to the other nightly builds.

But +1 to merge even without this, as long at it stays green :)

pip install --no-build-isolation -e .
- name: Test scikit-learn
run: |
cd /tmp && python -m pytest -n 2 --pyargs sklearn
Copy link
Member

@ogrisel ogrisel Sep 7, 2021

Choose a reason for hiding this comment

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

Even if our OPENMP-based Cython code should now avoid oversubscription problems in docker containers, numpy/scipy might still use too many threads and slow down the execution.

To be safe I think we should set OMP_NUM_THREADS=2 / OPENBLAS_NUM_THREADS=2 globally for this workflow.

Copy link
Member

Choose a reason for hiding this comment

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

@thomasjpfan Shall we set the environment variable in this file as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

The environment variables are set globally in lines 42-45:

    env:
      INSTALL_NUMPY: ${{ matrix.install-numpy }}
      INSTALL_SCIPY: ${{ matrix.install-scipy }}
      OMP_NUM_THREADS: '2'
      OPENBLAS_NUM_THREADS: '2'

Copy link
Member

Choose a reason for hiding this comment

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

Would this work and be useful?

Suggested change
cd /tmp && python -m pytest -n 2 --pyargs sklearn
cd /tmp && python -m pytest -n $OMP_NUM_THREADS --pyargs sklearn

run: |
echo "::set-output name=commit_msg::$(git log --no-merges -1 --oneline)"

nightly:
Copy link
Member

Choose a reason for hiding this comment

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

Maybe rename to nightly-cpython or upstream-nighly.

- name: Install scikit-learn
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
pip install --no-build-isolation -e .
Copy link
Member

Choose a reason for hiding this comment

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

To get more informative outputs in case of problems:

Suggested change
pip install --no-build-isolation -e .
pip install -v --no-build-isolation -e .

Also, it might be interesting to set SKLEARN_BUILD_PARALLEL=3 to speed up this step a bit.

@thomasjpfan thomasjpfan marked this pull request as ready for review September 10, 2021 13:12
@thomasjpfan
Copy link
Member Author

thomasjpfan commented Sep 10, 2021

It seems to be fast enough. @thomasjpfan why is this PR still in draft mode? Do you have other things in mind?

I forgot to change it while testing ccache. It's ready.

For scikit-learn, we could use cibuildwheel instead of a traditional build + test steps and publish the resulting wheel to https://anaconda.org/scipy-wheels-nightly/scikit-learn/files in addition to the other nightly builds.

I was going to wait for MacPython/scipy-wheels#124 to get merged before having our own wheels. Should we upload scikit-learn wheels for 3.10 without SciPy wheels?

@thomasjpfan thomasjpfan changed the title MAINT Adds CPython 3.10 testing [python-dev] CI Adds CPython 3.10 testing [python-dev] Sep 10, 2021
@ogrisel
Copy link
Member

ogrisel commented Sep 15, 2021

I was going to wait for MacPython/scipy-wheels#124 to get merged before having our own wheels. Should we upload scikit-learn wheels for 3.10 without SciPy wheels?

It's true that scikit-learn's Python 3.10 nightly wheels won't be that useful without scipy's but we don't strictly need to wait for them to do it ourselves :)

@ogrisel
Copy link
Member

ogrisel commented Sep 15, 2021

But's let's merge this PR as it is as it's already useful the way it is and we can do the wheel uploading later.

@thomasjpfan
Copy link
Member Author

thomasjpfan commented Oct 1, 2021

Wheels update

  1. There looks to be movement in getting scipy wheels built for 3.10: MAINT: add Python 3.10 wheels MacPython/scipy-wheels#127

  2. Also numpy is starting to look into wheels for osx and windows: Check if Python 3.10.0 available for Mac and Windows. MacPython/numpy-wheels#134

  3. Also no 32bit Python 3.10 wheels: MAINT: add Python 3.10 wheels MacPython/scipy-wheels#127 (comment)

Copy link
Member

@jjerphan jjerphan left a comment

Choose a reason for hiding this comment

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

Thanks for setting this workflow, @thomasjpfan.

I just have one naive suggestion.

pip install --no-build-isolation -e .
- name: Test scikit-learn
run: |
cd /tmp && python -m pytest -n 2 --pyargs sklearn
Copy link
Member

Choose a reason for hiding this comment

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

Would this work and be useful?

Suggested change
cd /tmp && python -m pytest -n 2 --pyargs sklearn
cd /tmp && python -m pytest -n $OMP_NUM_THREADS --pyargs sklearn

@thomasjpfan
Copy link
Member Author

thomasjpfan commented Oct 8, 2021

We may not need this anymore if we have #21232

Edit: I think it would be good to keep this around to always test on the latest dev build of Python. I am thinking of keeping this CI on Python 3.10 and then move to 3.11 when the Python RC comes up. The tests would be slow in the beginning because wheels are not built yet for NumPy, SciPy, or pandas during the early in the RC phase.

@glemaitre
Copy link
Member

The tests would be slow in the beginning because wheels are not built yet for NumPy, SciPy, or pandas during the early in the RC phase.

We could make it a CRON job at night like the build that check all nightly builds?

@thomasjpfan thomasjpfan marked this pull request as draft October 21, 2021 14:30
@ogrisel
Copy link
Member

ogrisel commented Oct 26, 2021

I think it's good to test against the nightly versions of CPython / numpy / scipy irrespective of their specific version numbers.

@thomasjpfan
Copy link
Member Author

Closing as we are testing on python 3.10 on azure now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants