From 22aa88f2da91510914ae20bb5ba56ba3b611f72a Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 4 Sep 2024 22:21:31 +0530 Subject: [PATCH 01/34] Test Pyodide 0.27.0a2 --- .github/workflows/emscripten.yml | 76 ++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/emscripten.yml diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml new file mode 100644 index 0000000000000..ac18938b807cd --- /dev/null +++ b/.github/workflows/emscripten.yml @@ -0,0 +1,76 @@ +name: Test Emscripten/Pyodide build + +on: + pull_request: + +env: + FORCE_COLOR: 3 + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read # to fetch code (actions/checkout) + +jobs: + build-wasm-emscripten: + name: Build scikit-learn distribution for Pyodide + runs-on: ubuntu-22.04 + env: + PYODIDE_VERSION: 0.27.0a2 + # PYTHON_VERSION and EMSCRIPTEN_VERSION are determined by PYODIDE_VERSION. + # The appropriate versions can be found in the Pyodide repodata.json + # "info" field, or in Makefile.envs: + # https://github.com/pyodide/pyodide/blob/main/Makefile.envs#L2 + PYTHON_VERSION: 3.12.1 + EMSCRIPTEN_VERSION: 3.1.58 + NODE_VERSION: 20 + steps: + - name: Checkout scikit-learn + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Set up Python ${{ env.PYTHON_VERSION }} + uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Set up Emscripten toolchain + uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14 + with: + version: ${{ env.EMSCRIPTEN_VERSION }} + actions-cache-folder: emsdk-cache + + - name: Install pyodide-build + run: pip install pyodide-build + + - name: Build scikit-learn for Pyodide + run: pyodide build + + - name: Sanity check build artifacts + run: ls -ltrh dist + + - name: Set up Node.js + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Set up Pyodide virtual environment and test scikit-learn for Pyodide + env: + SKLEARN_SKIP_OPENMP_TEST: true + run: | + # Set up Pyodide virtual environment + pyodide xbuildenv install ${{ env.PYODIDE_VERSION }} + pyodide venv .venv-pyodide + + # Activate the virtual environment and install the built scikit-learn wheel + source .venv-pyodide/bin/activate + pip install dist/*.whl + # Change to a different directory to avoid importing the local scikit-learn + # package instead of the installed one + cd doc + pip install pytest + export SKLEARN_SKIP_OPENMP_TEST=1 + # Don't use the cache provider plugin, as it doesn't work with Pyodide + # right now: https://github.com/pypa/cibuildwheel/issues/1966 + pytest -svra -p no:cacheprovider --pyargs sklearn From 37884acb6adc234cfe9680c3889983499d2cbadb Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 4 Sep 2024 22:40:22 +0530 Subject: [PATCH 02/34] Try to fix `js.process` `ModuleNotFoundError` --- .github/workflows/emscripten.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index ac18938b807cd..2fa2143078107 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -57,7 +57,7 @@ jobs: - name: Set up Pyodide virtual environment and test scikit-learn for Pyodide env: - SKLEARN_SKIP_OPENMP_TEST: true + SKLEARN_SKIP_OPENMP_TEST: "true" run: | # Set up Pyodide virtual environment pyodide xbuildenv install ${{ env.PYODIDE_VERSION }} @@ -70,7 +70,6 @@ jobs: # package instead of the installed one cd doc pip install pytest - export SKLEARN_SKIP_OPENMP_TEST=1 # Don't use the cache provider plugin, as it doesn't work with Pyodide # right now: https://github.com/pypa/cibuildwheel/issues/1966 - pytest -svra -p no:cacheprovider --pyargs sklearn + pytest -svra -p no:cacheprovider --pyargs sklearn --durations 20 --showlocals From d9d43fad8505159919cb93ef118a3c6113d9183e Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 4 Sep 2024 22:55:20 +0530 Subject: [PATCH 03/34] Install Pyodide JS library for testing --- .github/workflows/emscripten.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 2fa2143078107..d09805e545c44 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -55,6 +55,10 @@ jobs: with: node-version: ${{ env.NODE_VERSION }} + # The Pyodide JavaScript library is needed to run the tests in WASM + - name: Install Pyodide + run: npm install pyodide@${{ env.PYODIDE_VERSION }} + - name: Set up Pyodide virtual environment and test scikit-learn for Pyodide env: SKLEARN_SKIP_OPENMP_TEST: "true" From 776e2c935f95b10c2f7de247f3313d489f8d520e Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 4 Sep 2024 22:57:02 +0530 Subject: [PATCH 04/34] Skip tests that require a network (with `pooch`) --- .github/workflows/emscripten.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index d09805e545c44..308a34570e4de 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -62,6 +62,7 @@ jobs: - name: Set up Pyodide virtual environment and test scikit-learn for Pyodide env: SKLEARN_SKIP_OPENMP_TEST: "true" + SKLEARN_SKIP_NETWORK_TESTS: 1 run: | # Set up Pyodide virtual environment pyodide xbuildenv install ${{ env.PYODIDE_VERSION }} From 85d644d84fd3ccf4367325e10fc729c6ec69f494 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 4 Sep 2024 23:13:09 +0530 Subject: [PATCH 05/34] Fix Pyodide NPM installation --- .github/workflows/emscripten.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 308a34570e4de..341276f9b1835 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -57,7 +57,7 @@ jobs: # The Pyodide JavaScript library is needed to run the tests in WASM - name: Install Pyodide - run: npm install pyodide@${{ env.PYODIDE_VERSION }} + run: npm install pyodide@0.27.0-alpha.2 - name: Set up Pyodide virtual environment and test scikit-learn for Pyodide env: From 527c1512c77539070ef5dbfa8bceae1b76f98e5f Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 4 Sep 2024 23:33:24 +0530 Subject: [PATCH 06/34] Don't explicitly set xbuildenv version --- .github/workflows/emscripten.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 341276f9b1835..7c9961ec2a39e 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -55,9 +55,9 @@ jobs: with: node-version: ${{ env.NODE_VERSION }} - # The Pyodide JavaScript library is needed to run the tests in WASM - - name: Install Pyodide - run: npm install pyodide@0.27.0-alpha.2 + # # The Pyodide JavaScript library is needed to run the tests in WASM + # - name: Install Pyodide + # run: npm install pyodide@0.27.0-alpha.2 - name: Set up Pyodide virtual environment and test scikit-learn for Pyodide env: @@ -65,7 +65,6 @@ jobs: SKLEARN_SKIP_NETWORK_TESTS: 1 run: | # Set up Pyodide virtual environment - pyodide xbuildenv install ${{ env.PYODIDE_VERSION }} pyodide venv .venv-pyodide # Activate the virtual environment and install the built scikit-learn wheel From 5ba18f0919a2afda906833b75574456bd66ada6b Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 4 Sep 2024 23:41:15 +0530 Subject: [PATCH 07/34] Install `pyodide-cli` --- .github/workflows/emscripten.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 7c9961ec2a39e..602c60db3ebb7 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -42,7 +42,7 @@ jobs: actions-cache-folder: emsdk-cache - name: Install pyodide-build - run: pip install pyodide-build + run: pip install pyodide-build pyodide-cli - name: Build scikit-learn for Pyodide run: pyodide build From d04b38e4cbf393a617f8ff4a4ba3cf06ce7cf9ea Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 5 Sep 2024 00:39:51 +0530 Subject: [PATCH 08/34] Import `sklearn`, try testing without `--pyargs` --- .github/workflows/emscripten.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 602c60db3ebb7..3fb6a19e1bf8e 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -64,16 +64,25 @@ jobs: SKLEARN_SKIP_OPENMP_TEST: "true" SKLEARN_SKIP_NETWORK_TESTS: 1 run: | + set -e -x + # Set up Pyodide virtual environment pyodide venv .venv-pyodide # Activate the virtual environment and install the built scikit-learn wheel source .venv-pyodide/bin/activate pip install dist/*.whl + # Change to a different directory to avoid importing the local scikit-learn # package instead of the installed one cd doc pip install pytest + + # Try importing sklearn to see if the build is successful + python -c "import sklearn; print(sklearn.__version__)" + # Don't use the cache provider plugin, as it doesn't work with Pyodide # right now: https://github.com/pypa/cibuildwheel/issues/1966 - pytest -svra -p no:cacheprovider --pyargs sklearn --durations 20 --showlocals + # Try testing without pyargs + # pytest -svra -p no:cacheprovider --pyargs sklearn --durations 20 --showlocals + pytest -svra -p no:cacheprovider --durations 20 --showlocals ../sklearn From d6708a63e44ff8d7131dbbf85ea1e4a98a9d35f8 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 5 Sep 2024 02:08:02 +0530 Subject: [PATCH 09/34] Reinstall xbuildenv manually, install npm-pyodide in doc/ --- .github/workflows/emscripten.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 3fb6a19e1bf8e..be254960d81d6 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -55,10 +55,6 @@ jobs: with: node-version: ${{ env.NODE_VERSION }} - # # The Pyodide JavaScript library is needed to run the tests in WASM - # - name: Install Pyodide - # run: npm install pyodide@0.27.0-alpha.2 - - name: Set up Pyodide virtual environment and test scikit-learn for Pyodide env: SKLEARN_SKIP_OPENMP_TEST: "true" @@ -67,6 +63,7 @@ jobs: set -e -x # Set up Pyodide virtual environment + pyodide xbuildenv install ${{ env.PYODIDE_VERSION }} pyodide venv .venv-pyodide # Activate the virtual environment and install the built scikit-learn wheel @@ -78,6 +75,9 @@ jobs: cd doc pip install pytest + # The Pyodide JavaScript library is needed to run the tests in WASM + npm install pyodide@0.27.0-alpha.2 + # Try importing sklearn to see if the build is successful python -c "import sklearn; print(sklearn.__version__)" From 2760c38715d64404972e139b46caf5f87801f703 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 5 Sep 2024 02:08:08 +0530 Subject: [PATCH 10/34] Add TODO note about Azure --- .github/workflows/emscripten.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index be254960d81d6..ce463690d102b 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -1,4 +1,7 @@ name: Test Emscripten/Pyodide build +# TODO: move the relevant workflow items to Azure Pipelines +# when the build and tests pass on GitHub Actions here +# and then remove this workflow file altogether. on: pull_request: From 16267d7b503c62236171b98cea6199ce1d788981 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 6 Sep 2024 00:07:33 +0530 Subject: [PATCH 11/34] Set `PYTHONVERBOSE` and `PYTHONDEBUG` for debugging --- .github/workflows/emscripten.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index ce463690d102b..62d616dcc20d2 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -62,6 +62,8 @@ jobs: env: SKLEARN_SKIP_OPENMP_TEST: "true" SKLEARN_SKIP_NETWORK_TESTS: 1 + PYTHONVERBOSE: 1 + PYTHONDEBUG: 1 run: | set -e -x From 961a9d4fc1fd9cd291631818ff010c604c29f494 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 6 Sep 2024 02:13:57 +0530 Subject: [PATCH 12/34] Switch to `maint_tools/` instead of `doc/` --- .github/workflows/emscripten.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 62d616dcc20d2..db661a02b3977 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -77,7 +77,7 @@ jobs: # Change to a different directory to avoid importing the local scikit-learn # package instead of the installed one - cd doc + cd maint_tools pip install pytest # The Pyodide JavaScript library is needed to run the tests in WASM From ee3228eeeb5431fc7d7936e2a1a667fbf4108c5e Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 6 Sep 2024 14:26:46 +0530 Subject: [PATCH 13/34] Clean up changes, use `--pyargs` --- .github/workflows/emscripten.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index db661a02b3977..64f94f163433e 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -45,7 +45,7 @@ jobs: actions-cache-folder: emsdk-cache - name: Install pyodide-build - run: pip install pyodide-build pyodide-cli + run: pip install pyodide-build - name: Build scikit-learn for Pyodide run: pyodide build @@ -62,8 +62,6 @@ jobs: env: SKLEARN_SKIP_OPENMP_TEST: "true" SKLEARN_SKIP_NETWORK_TESTS: 1 - PYTHONVERBOSE: 1 - PYTHONDEBUG: 1 run: | set -e -x @@ -80,14 +78,9 @@ jobs: cd maint_tools pip install pytest - # The Pyodide JavaScript library is needed to run the tests in WASM - npm install pyodide@0.27.0-alpha.2 - # Try importing sklearn to see if the build is successful python -c "import sklearn; print(sklearn.__version__)" # Don't use the cache provider plugin, as it doesn't work with Pyodide # right now: https://github.com/pypa/cibuildwheel/issues/1966 - # Try testing without pyargs - # pytest -svra -p no:cacheprovider --pyargs sklearn --durations 20 --showlocals - pytest -svra -p no:cacheprovider --durations 20 --showlocals ../sklearn + pytest -svra -p no:cacheprovider --pyargs sklearn --durations 20 --showlocals From 383bf7e749e4c17842893556e3457f0c593bc6d5 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 6 Sep 2024 14:56:02 +0530 Subject: [PATCH 14/34] =?UTF-8?q?Fix=20a=20typo:=20paralell=20=E2=9E=A1?= =?UTF-8?q?=EF=B8=8F=20parallel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sklearn/ensemble/tests/test_iforest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sklearn/ensemble/tests/test_iforest.py b/sklearn/ensemble/tests/test_iforest.py index 19e34bbf51808..18a2dc347b3bd 100644 --- a/sklearn/ensemble/tests/test_iforest.py +++ b/sklearn/ensemble/tests/test_iforest.py @@ -387,7 +387,7 @@ def test_iforest_predict_parallel(global_random_seed, contamination, n_jobs): ) clf_parallel.fit(X) with parallel_backend("threading", n_jobs=n_jobs): - pred_paralell = clf_parallel.predict(X) + pred_parallel = clf_parallel.predict(X) # assert the same results as non-parallel - assert_array_equal(pred, pred_paralell) + assert_array_equal(pred, pred_parallel) From 7efd95d8588ab32a40f0af398c186e843d85710c Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 6 Sep 2024 14:58:55 +0530 Subject: [PATCH 15/34] Try to run Cython from its pure Python wheel --- .github/workflows/emscripten.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 64f94f163433e..d200aacd842aa 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -76,7 +76,7 @@ jobs: # Change to a different directory to avoid importing the local scikit-learn # package instead of the installed one cd maint_tools - pip install pytest + pip install pytest cython # Try importing sklearn to see if the build is successful python -c "import sklearn; print(sklearn.__version__)" From cfae5ff29d63075c57d6221087ed7692e0a83c2e Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 6 Sep 2024 15:40:03 +0530 Subject: [PATCH 16/34] Trigger [pyodide] wheel build, add Cython comment --- .github/workflows/emscripten.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index d200aacd842aa..a67a41c16e175 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -76,6 +76,8 @@ jobs: # Change to a different directory to avoid importing the local scikit-learn # package instead of the installed one cd maint_tools + # TODO: Cython shouldn't be required here, move sklearn/_build_utils/tempita.py + # to something like build_tools/tempita.py and remove dependence on Cython pip install pytest cython # Try importing sklearn to see if the build is successful From 3ae370f1dfcc9293a84239f2448461642bd9e486 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 6 Sep 2024 20:58:34 +0530 Subject: [PATCH 17/34] Move `tempita.py` to root dir (for now) --- meson.build | 2 +- sklearn/_build_utils/tempita.py => tempita.py | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename sklearn/_build_utils/tempita.py => tempita.py (100%) diff --git a/meson.build b/meson.build index 3f14108f77998..9bcb1e1f4f98b 100644 --- a/meson.build +++ b/meson.build @@ -42,7 +42,7 @@ if m_dep.found() add_project_link_arguments('-lm', language : 'c') endif -tempita = files('sklearn/_build_utils/tempita.py') +tempita = files('tempita.py') py = import('python').find_installation(pure: false) diff --git a/sklearn/_build_utils/tempita.py b/tempita.py similarity index 100% rename from sklearn/_build_utils/tempita.py rename to tempita.py From f16a501f0465adad032a39a353da36d4ade6242d Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 6 Sep 2024 20:59:22 +0530 Subject: [PATCH 18/34] Bump verbosity for [pyodide] test suite --- build_tools/azure/test_script_pyodide.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_tools/azure/test_script_pyodide.sh b/build_tools/azure/test_script_pyodide.sh index d1aa207f864a2..239cb2e692d04 100644 --- a/build_tools/azure/test_script_pyodide.sh +++ b/build_tools/azure/test_script_pyodide.sh @@ -6,4 +6,4 @@ set -e # one day we can use a Pyodide venv instead but at the time of writing # (2023-09-27) there is an issue with scipy.linalg in a Pyodide venv, see # https://github.com/pyodide/pyodide/issues/3865 for more details. -node build_tools/azure/pytest-pyodide.js --pyargs sklearn --durations 20 --showlocals +node build_tools/azure/pytest-pyodide.js -svra --pyargs sklearn --durations 20 --showlocals From 382c8ba59dc46c306a928ffe841dfa09121b0e6d Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 7 Sep 2024 02:52:20 +0530 Subject: [PATCH 19/34] Remove spurious missing `cache` fixture --- sklearn/datasets/tests/test_openml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/datasets/tests/test_openml.py b/sklearn/datasets/tests/test_openml.py index ee6d75861ada8..b5dc46c02bf67 100644 --- a/sklearn/datasets/tests/test_openml.py +++ b/sklearn/datasets/tests/test_openml.py @@ -1459,7 +1459,7 @@ def _mock_urlopen_raise(request, *args, **kwargs): (False, "pandas"), ], ) -def test_fetch_openml_verify_checksum(monkeypatch, as_frame, cache, tmpdir, parser): +def test_fetch_openml_verify_checksum(monkeypatch, as_frame, tmpdir, parser): """Check that the checksum is working as expected.""" if as_frame or parser == "pandas": pytest.importorskip("pandas") From 049ccca32fb9c55fa675d0fd56d2b317f44060c7 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 7 Sep 2024 02:55:12 +0530 Subject: [PATCH 20/34] Trigger [pyodide] tests too From b39814467756ccda69698fc7c8ba27285747c86f Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 9 Sep 2024 22:36:27 +0530 Subject: [PATCH 21/34] Revert "Move `tempita.py` to root dir (for now)" This reverts commit 3ae370f1dfcc9293a84239f2448461642bd9e486. --- meson.build | 2 +- tempita.py => sklearn/_build_utils/tempita.py | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename tempita.py => sklearn/_build_utils/tempita.py (100%) diff --git a/meson.build b/meson.build index 9bcb1e1f4f98b..3f14108f77998 100644 --- a/meson.build +++ b/meson.build @@ -42,7 +42,7 @@ if m_dep.found() add_project_link_arguments('-lm', language : 'c') endif -tempita = files('tempita.py') +tempita = files('sklearn/_build_utils/tempita.py') py = import('python').find_installation(pure: false) diff --git a/tempita.py b/sklearn/_build_utils/tempita.py similarity index 100% rename from tempita.py rename to sklearn/_build_utils/tempita.py From 3af4ea294ead7570c665ea72620d77f6e021daf5 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 9 Sep 2024 22:37:48 +0530 Subject: [PATCH 22/34] Use `find_program` function for Tempita and trigger [pyodide] wheel build --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 3f14108f77998..84052bee5b549 100644 --- a/meson.build +++ b/meson.build @@ -42,7 +42,7 @@ if m_dep.found() add_project_link_arguments('-lm', language : 'c') endif -tempita = files('sklearn/_build_utils/tempita.py') +tempita = find_program('sklearn/_build_utils/tempita.py') py = import('python').find_installation(pure: false) From 4a45a9780a075e25f0b4eeb80d42ffac1ae19ec0 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 9 Sep 2024 22:41:51 +0530 Subject: [PATCH 23/34] Clean up test dependencies [pyodide] --- .github/workflows/emscripten.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index a67a41c16e175..64f94f163433e 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -76,9 +76,7 @@ jobs: # Change to a different directory to avoid importing the local scikit-learn # package instead of the installed one cd maint_tools - # TODO: Cython shouldn't be required here, move sklearn/_build_utils/tempita.py - # to something like build_tools/tempita.py and remove dependence on Cython - pip install pytest cython + pip install pytest # Try importing sklearn to see if the build is successful python -c "import sklearn; print(sklearn.__version__)" From 745f6f931736ea16308dcc3e82f19839a1884f5e Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 9 Sep 2024 22:47:13 +0530 Subject: [PATCH 24/34] Move `tempita` to an inner `meson.build` --- meson.build | 2 -- sklearn/meson.build | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 84052bee5b549..2edf39e1b8dc1 100644 --- a/meson.build +++ b/meson.build @@ -42,8 +42,6 @@ if m_dep.found() add_project_link_arguments('-lm', language : 'c') endif -tempita = find_program('sklearn/_build_utils/tempita.py') - py = import('python').find_installation(pure: false) # Copy all the .py files to the install dir, rather than using diff --git a/sklearn/meson.build b/sklearn/meson.build index 4bf896fcdeaef..0d0f532938494 100644 --- a/sklearn/meson.build +++ b/sklearn/meson.build @@ -6,6 +6,9 @@ cython_args = [] is_windows = host_machine.system() == 'windows' is_mingw = is_windows and cc.get_id() == 'gcc' +# Tempita +tempita = find_program('_build_utils/tempita.py') + # Adapted from Scipy. mingw is untested and not officially supported. If you # ever bump into issues when trying to compile for mingw, please open an issue # in the scikit-learn issue tracker From 067541258e4244dd6c95ff7302f6ef45f3b365f6 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 9 Sep 2024 23:15:33 +0530 Subject: [PATCH 25/34] Revert "Move `tempita` to an inner `meson.build`" This reverts commit 745f6f931736ea16308dcc3e82f19839a1884f5e. --- meson.build | 2 ++ sklearn/meson.build | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 2edf39e1b8dc1..84052bee5b549 100644 --- a/meson.build +++ b/meson.build @@ -42,6 +42,8 @@ if m_dep.found() add_project_link_arguments('-lm', language : 'c') endif +tempita = find_program('sklearn/_build_utils/tempita.py') + py = import('python').find_installation(pure: false) # Copy all the .py files to the install dir, rather than using diff --git a/sklearn/meson.build b/sklearn/meson.build index 0d0f532938494..4bf896fcdeaef 100644 --- a/sklearn/meson.build +++ b/sklearn/meson.build @@ -6,9 +6,6 @@ cython_args = [] is_windows = host_machine.system() == 'windows' is_mingw = is_windows and cc.get_id() == 'gcc' -# Tempita -tempita = find_program('_build_utils/tempita.py') - # Adapted from Scipy. mingw is untested and not officially supported. If you # ever bump into issues when trying to compile for mingw, please open an issue # in the scikit-learn issue tracker From a9d7e6cd1c080dca9fd362dd8d14fbf1b6c2f996 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 9 Sep 2024 23:18:15 +0530 Subject: [PATCH 26/34] Make tempita usable with `find_program()` and trigger [pyodide] wheel builds --- sklearn/_loss/meson.build | 2 +- sklearn/linear_model/meson.build | 2 +- .../_pairwise_distances_reduction/meson.build | 24 +++++++++---------- sklearn/metrics/meson.build | 4 ++-- sklearn/neighbors/meson.build | 4 ++-- sklearn/utils/meson.build | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/sklearn/_loss/meson.build b/sklearn/_loss/meson.build index bb187fd03f71b..ead867dcfa746 100644 --- a/sklearn/_loss/meson.build +++ b/sklearn/_loss/meson.build @@ -7,7 +7,7 @@ _loss_pyx = custom_target( '_loss_pyx', output: '_loss.pyx', input: '_loss.pyx.tp', - command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'], + command: [tempita, '@INPUT@', '-o', '@OUTDIR@'], # TODO in principle this should go in py.exension_module below. This is # temporary work-around for dependency issue with .pyx.tp files. For more # details, see https://github.com/mesonbuild/meson/issues/13212 diff --git a/sklearn/linear_model/meson.build b/sklearn/linear_model/meson.build index 00ab496fb60aa..53d44d45b0a2d 100644 --- a/sklearn/linear_model/meson.build +++ b/sklearn/linear_model/meson.build @@ -18,7 +18,7 @@ foreach name: name_list name + '_pyx', output: name + '.pyx', input: name + '.pyx.tp', - command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'], + command: [tempita, '@INPUT@', '-o', '@OUTDIR@'], # TODO in principle this should go in py.exension_module below. This is # temporary work-around for dependency issue with .pyx.tp files. For more # details, see https://github.com/mesonbuild/meson/issues/13212 diff --git a/sklearn/metrics/_pairwise_distances_reduction/meson.build b/sklearn/metrics/_pairwise_distances_reduction/meson.build index 878b29e869f5e..07836f3d11f4e 100644 --- a/sklearn/metrics/_pairwise_distances_reduction/meson.build +++ b/sklearn/metrics/_pairwise_distances_reduction/meson.build @@ -24,13 +24,13 @@ _datasets_pair_pxd = custom_target( '_datasets_pair_pxd', output: '_datasets_pair.pxd', input: '_datasets_pair.pxd.tp', - command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'] + command: [tempita, '@INPUT@', '-o', '@OUTDIR@'] ) _datasets_pair_pyx = custom_target( '_datasets_pair_pyx', output: '_datasets_pair.pyx', input: '_datasets_pair.pyx.tp', - command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'], + command: [tempita, '@INPUT@', '-o', '@OUTDIR@'], # TODO in principle this should go in py.exension_module below. This is # temporary work-around for dependency issue with .pyx.tp files. For more # details, see https://github.com/mesonbuild/meson/issues/13212 @@ -50,13 +50,13 @@ _base_pxd = custom_target( '_base_pxd', output: '_base.pxd', input: '_base.pxd.tp', - command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'] + command: [tempita, '@INPUT@', '-o', '@OUTDIR@'] ) _base_pyx = custom_target( '_base_pyx', output: '_base.pyx', input: '_base.pyx.tp', - command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'], + command: [tempita, '@INPUT@', '-o', '@OUTDIR@'], # TODO in principle this should go in py.exension_module below. This is # temporary work-around for dependency issue with .pyx.tp files. For more # details, see https://github.com/mesonbuild/meson/issues/13212 @@ -77,13 +77,13 @@ _middle_term_computer_pxd = custom_target( '_middle_term_computer_pxd', output: '_middle_term_computer.pxd', input: '_middle_term_computer.pxd.tp', - command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'] + command: [tempita, '@INPUT@', '-o', '@OUTDIR@'] ) _middle_term_computer_pyx = custom_target( '_middle_term_computer_pyx', output: '_middle_term_computer.pyx', input: '_middle_term_computer.pyx.tp', - command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'], + command: [tempita, '@INPUT@', '-o', '@OUTDIR@'], # TODO in principle this should go in py.exension_module below. This is # temporary work-around for dependency issue with .pyx.tp files. For more # details, see https://github.com/mesonbuild/meson/issues/13212 @@ -105,13 +105,13 @@ _argkmin_pxd = custom_target( '_argkmin_pxd', output: '_argkmin.pxd', input: '_argkmin.pxd.tp', - command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'] + command: [tempita, '@INPUT@', '-o', '@OUTDIR@'] ) _argkmin_pyx = custom_target( '_argkmin_pyx', output: '_argkmin.pyx', input: '_argkmin.pyx.tp', - command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'], + command: [tempita, '@INPUT@', '-o', '@OUTDIR@'], # TODO in principle this should go in py.exension_module below. This is # temporary work-around for dependency issue with .pyx.tp files. For more # details, see https://github.com/mesonbuild/meson/issues/13212 @@ -133,13 +133,13 @@ _radius_neighbors_pxd = custom_target( '_radius_neighbors_pxd', output: '_radius_neighbors.pxd', input: '_radius_neighbors.pxd.tp', - command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'] + command: [tempita, '@INPUT@', '-o', '@OUTDIR@'] ) _radius_neighbors_pyx = custom_target( '_radius_neighbors_pyx', output: '_radius_neighbors.pyx', input: '_radius_neighbors.pyx.tp', - command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'], + command: [tempita, '@INPUT@', '-o', '@OUTDIR@'], # TODO in principle this should go in py.exension_module below. This is # temporary work-around for dependency issue with .pyx.tp files. For more # details, see https://github.com/mesonbuild/meson/issues/13212 @@ -161,7 +161,7 @@ _argkmin_classmode_pyx = custom_target( '_argkmin_classmode_pyx', output: '_argkmin_classmode.pyx', input: '_argkmin_classmode.pyx.tp', - command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'], + command: [tempita, '@INPUT@', '-o', '@OUTDIR@'], # TODO in principle this should go in py.exension_module below. This is # temporary work-around for dependency issue with .pyx.tp files. For more # details, see https://github.com/mesonbuild/meson/issues/13212 @@ -187,7 +187,7 @@ _radius_neighbors_classmode_pyx = custom_target( '_radius_neighbors_classmode_pyx', output: '_radius_neighbors_classmode.pyx', input: '_radius_neighbors_classmode.pyx.tp', - command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'], + command: [tempita, '@INPUT@', '-o', '@OUTDIR@'], # TODO in principle this should go in py.exension_module below. This is # temporary work-around for dependency issue with .pyx.tp files. For more # details, see https://github.com/mesonbuild/meson/issues/13212 diff --git a/sklearn/metrics/meson.build b/sklearn/metrics/meson.build index 2e01572144707..d788cf08f3add 100644 --- a/sklearn/metrics/meson.build +++ b/sklearn/metrics/meson.build @@ -10,7 +10,7 @@ _dist_metrics_pxd = custom_target( '_dist_metrics_pxd', output: '_dist_metrics.pxd', input: '_dist_metrics.pxd.tp', - command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'], + command: [tempita, '@INPUT@', '-o', '@OUTDIR@'], # Need to install the generated pxd because it is needed in other subpackages # Cython code, e.g. sklearn.cluster install_dir: sklearn_dir / 'metrics', @@ -22,7 +22,7 @@ _dist_metrics_pyx = custom_target( '_dist_metrics_pyx', output: '_dist_metrics.pyx', input: '_dist_metrics.pyx.tp', - command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'], + command: [tempita, '@INPUT@', '-o', '@OUTDIR@'], # TODO in principle this should go in py.exension_module below. This is # temporary work-around for dependency issue with .pyx.tp files. For more # details, see https://github.com/mesonbuild/meson/issues/13212 diff --git a/sklearn/neighbors/meson.build b/sklearn/neighbors/meson.build index 22f81d597948b..e7ce9a2972cd3 100644 --- a/sklearn/neighbors/meson.build +++ b/sklearn/neighbors/meson.build @@ -2,7 +2,7 @@ _binary_tree_pxi = custom_target( '_binary_tree_pxi', output: '_binary_tree.pxi', input: '_binary_tree.pxi.tp', - command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'], + command: [tempita, '@INPUT@', '-o', '@OUTDIR@'], ) # .pyx is generated so this is needed to make Cython compilation work. The pxi @@ -20,7 +20,7 @@ foreach name: name_list name + '_pyx', output: name + '.pyx', input: name + '.pyx.tp', - command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'], + command: [tempita, '@INPUT@', '-o', '@OUTDIR@'], # TODO in principle this should go in py.exension_module below. This is # temporary work-around for dependency issue with .pyx.tp files. For more # details, see https://github.com/mesonbuild/meson/issues/13212 diff --git a/sklearn/utils/meson.build b/sklearn/utils/meson.build index c7a6102b956e8..81a20d520c996 100644 --- a/sklearn/utils/meson.build +++ b/sklearn/utils/meson.build @@ -54,7 +54,7 @@ foreach name: util_extension_names name + '_pxd', output: name + '.pxd', input: name + '.pxd.tp', - command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'], + command: [tempita, '@INPUT@', '-o', '@OUTDIR@'], ) utils_cython_tree += [pxd] @@ -62,7 +62,7 @@ foreach name: util_extension_names name + '_pyx', output: name + '.pyx', input: name + '.pyx.tp', - command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'], + command: [tempita, '@INPUT@', '-o', '@OUTDIR@'], # TODO in principle this should go in py.exension_module below. This is # temporary work-around for dependency issue with .pyx.tp files. For more # details, see https://github.com/mesonbuild/meson/issues/13212 From 86247ad80f887e80d0e66bd4be672b7924fd3e32 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 9 Sep 2024 23:23:16 +0530 Subject: [PATCH 27/34] Add Python shebang to `tempita` [pyodide] See https://github.com/numpy/numpy/pull/24971 --- sklearn/_build_utils/tempita.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sklearn/_build_utils/tempita.py b/sklearn/_build_utils/tempita.py index c92ea17d2a9b9..c8a7a35a62fee 100644 --- a/sklearn/_build_utils/tempita.py +++ b/sklearn/_build_utils/tempita.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + # Authors: The scikit-learn developers # SPDX-License-Identifier: BSD-3-Clause From 5b4d0435aed292ce8d1e50488d065d3c543ee0f8 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 9 Sep 2024 23:57:09 +0530 Subject: [PATCH 28/34] Exclude `_build_utils/` from installation --- meson.build | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 84052bee5b549..f9cdd65d53b13 100644 --- a/meson.build +++ b/meson.build @@ -47,7 +47,11 @@ tempita = find_program('sklearn/_build_utils/tempita.py') py = import('python').find_installation(pure: false) # Copy all the .py files to the install dir, rather than using -# py.install_sources and needing to list them explicitely one by one -install_subdir('sklearn', install_dir: py.get_install_dir()) +# py.install_sources and needing to list them explicitly one by one +# Exclude the _build_utils directory, which is not needed at runtime +install_subdir('sklearn', + install_dir: py.get_install_dir(), + exclude_directories: ['sklearn/_build_utils'] +) subdir('sklearn') From 8acf67e41cb51a0d10a393bfc3389cbd443bcb3c Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 9 Sep 2024 23:58:50 +0530 Subject: [PATCH 29/34] Upload [pyodide] wheel artifact for debugging --- .github/workflows/emscripten.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 64f94f163433e..53a6c3f45b35d 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -53,6 +53,12 @@ jobs: - name: Sanity check build artifacts run: ls -ltrh dist + - name: Upload wheel artifact + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + with: + name: pyodide_wheel_${{ github.run_id }} + path: dist/*.whl + - name: Set up Node.js uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: From ecd310465200b3f65b96eb6348fa55bf91cb877d Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 10 Sep 2024 00:08:53 +0530 Subject: [PATCH 30/34] Fix `_build_utils/` folder exclusion --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index f9cdd65d53b13..1028188219613 100644 --- a/meson.build +++ b/meson.build @@ -51,7 +51,7 @@ py = import('python').find_installation(pure: false) # Exclude the _build_utils directory, which is not needed at runtime install_subdir('sklearn', install_dir: py.get_install_dir(), - exclude_directories: ['sklearn/_build_utils'] + exclude_directories: ['_build_utils'] ) subdir('sklearn') From 6759395b3a6501b3ac6f8956ec21dfe55a79e040 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Est=C3=A8ve?= Date: Mon, 24 Mar 2025 10:43:23 +0100 Subject: [PATCH 31/34] on push --- .github/workflows/emscripten.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 53a6c3f45b35d..4ec36a4530e9b 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -5,6 +5,7 @@ name: Test Emscripten/Pyodide build on: pull_request: + push: env: FORCE_COLOR: 3 @@ -21,12 +22,12 @@ jobs: name: Build scikit-learn distribution for Pyodide runs-on: ubuntu-22.04 env: - PYODIDE_VERSION: 0.27.0a2 + PYODIDE_VERSION: 0.27.4 # PYTHON_VERSION and EMSCRIPTEN_VERSION are determined by PYODIDE_VERSION. # The appropriate versions can be found in the Pyodide repodata.json # "info" field, or in Makefile.envs: # https://github.com/pyodide/pyodide/blob/main/Makefile.envs#L2 - PYTHON_VERSION: 3.12.1 + PYTHON_VERSION: 3.12.7 EMSCRIPTEN_VERSION: 3.1.58 NODE_VERSION: 20 steps: From 8bb1c34a9a8cd7d6b58a59369f613087988fed7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Est=C3=A8ve?= Date: Mon, 24 Mar 2025 12:17:18 +0100 Subject: [PATCH 32/34] Remove non tempita related --- .github/workflows/emscripten.yml | 93 ------------------------ build_tools/azure/test_script_pyodide.sh | 2 +- sklearn/datasets/tests/test_openml.py | 2 +- sklearn/ensemble/tests/test_iforest.py | 4 +- 4 files changed, 4 insertions(+), 97 deletions(-) delete mode 100644 .github/workflows/emscripten.yml diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml deleted file mode 100644 index 4ec36a4530e9b..0000000000000 --- a/.github/workflows/emscripten.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: Test Emscripten/Pyodide build -# TODO: move the relevant workflow items to Azure Pipelines -# when the build and tests pass on GitHub Actions here -# and then remove this workflow file altogether. - -on: - pull_request: - push: - -env: - FORCE_COLOR: 3 - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -permissions: - contents: read # to fetch code (actions/checkout) - -jobs: - build-wasm-emscripten: - name: Build scikit-learn distribution for Pyodide - runs-on: ubuntu-22.04 - env: - PYODIDE_VERSION: 0.27.4 - # PYTHON_VERSION and EMSCRIPTEN_VERSION are determined by PYODIDE_VERSION. - # The appropriate versions can be found in the Pyodide repodata.json - # "info" field, or in Makefile.envs: - # https://github.com/pyodide/pyodide/blob/main/Makefile.envs#L2 - PYTHON_VERSION: 3.12.7 - EMSCRIPTEN_VERSION: 3.1.58 - NODE_VERSION: 20 - steps: - - name: Checkout scikit-learn - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - - - name: Set up Emscripten toolchain - uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14 - with: - version: ${{ env.EMSCRIPTEN_VERSION }} - actions-cache-folder: emsdk-cache - - - name: Install pyodide-build - run: pip install pyodide-build - - - name: Build scikit-learn for Pyodide - run: pyodide build - - - name: Sanity check build artifacts - run: ls -ltrh dist - - - name: Upload wheel artifact - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 - with: - name: pyodide_wheel_${{ github.run_id }} - path: dist/*.whl - - - name: Set up Node.js - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 - with: - node-version: ${{ env.NODE_VERSION }} - - - name: Set up Pyodide virtual environment and test scikit-learn for Pyodide - env: - SKLEARN_SKIP_OPENMP_TEST: "true" - SKLEARN_SKIP_NETWORK_TESTS: 1 - run: | - set -e -x - - # Set up Pyodide virtual environment - pyodide xbuildenv install ${{ env.PYODIDE_VERSION }} - pyodide venv .venv-pyodide - - # Activate the virtual environment and install the built scikit-learn wheel - source .venv-pyodide/bin/activate - pip install dist/*.whl - - # Change to a different directory to avoid importing the local scikit-learn - # package instead of the installed one - cd maint_tools - pip install pytest - - # Try importing sklearn to see if the build is successful - python -c "import sklearn; print(sklearn.__version__)" - - # Don't use the cache provider plugin, as it doesn't work with Pyodide - # right now: https://github.com/pypa/cibuildwheel/issues/1966 - pytest -svra -p no:cacheprovider --pyargs sklearn --durations 20 --showlocals diff --git a/build_tools/azure/test_script_pyodide.sh b/build_tools/azure/test_script_pyodide.sh index 239cb2e692d04..d1aa207f864a2 100644 --- a/build_tools/azure/test_script_pyodide.sh +++ b/build_tools/azure/test_script_pyodide.sh @@ -6,4 +6,4 @@ set -e # one day we can use a Pyodide venv instead but at the time of writing # (2023-09-27) there is an issue with scipy.linalg in a Pyodide venv, see # https://github.com/pyodide/pyodide/issues/3865 for more details. -node build_tools/azure/pytest-pyodide.js -svra --pyargs sklearn --durations 20 --showlocals +node build_tools/azure/pytest-pyodide.js --pyargs sklearn --durations 20 --showlocals diff --git a/sklearn/datasets/tests/test_openml.py b/sklearn/datasets/tests/test_openml.py index b12af847c0cda..6632fecc3ca4c 100644 --- a/sklearn/datasets/tests/test_openml.py +++ b/sklearn/datasets/tests/test_openml.py @@ -1475,7 +1475,7 @@ def _mock_urlopen_raise(request, *args, **kwargs): (False, "pandas"), ], ) -def test_fetch_openml_verify_checksum(monkeypatch, as_frame, tmpdir, parser): +def test_fetch_openml_verify_checksum(monkeypatch, as_frame, cache, tmpdir, parser): """Check that the checksum is working as expected.""" if as_frame or parser == "pandas": pytest.importorskip("pandas") diff --git a/sklearn/ensemble/tests/test_iforest.py b/sklearn/ensemble/tests/test_iforest.py index 18a2dc347b3bd..19e34bbf51808 100644 --- a/sklearn/ensemble/tests/test_iforest.py +++ b/sklearn/ensemble/tests/test_iforest.py @@ -387,7 +387,7 @@ def test_iforest_predict_parallel(global_random_seed, contamination, n_jobs): ) clf_parallel.fit(X) with parallel_backend("threading", n_jobs=n_jobs): - pred_parallel = clf_parallel.predict(X) + pred_paralell = clf_parallel.predict(X) # assert the same results as non-parallel - assert_array_equal(pred, pred_parallel) + assert_array_equal(pred, pred_paralell) From 27dc2bdff07e23b165cda999ca6a3a7127ae3732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Est=C3=A8ve?= Date: Mon, 24 Mar 2025 12:18:19 +0100 Subject: [PATCH 33/34] Remove unneeded change --- meson.build | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 1028188219613..f843a1ff8f45c 100644 --- a/meson.build +++ b/meson.build @@ -48,10 +48,6 @@ py = import('python').find_installation(pure: false) # Copy all the .py files to the install dir, rather than using # py.install_sources and needing to list them explicitly one by one -# Exclude the _build_utils directory, which is not needed at runtime -install_subdir('sklearn', - install_dir: py.get_install_dir(), - exclude_directories: ['_build_utils'] -) +install_subdir('sklearn', install_dir: py.get_install_dir()) subdir('sklearn') From d213a6615e7e30e8c6e36257c2341e979c21a546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Est=C3=A8ve?= Date: Mon, 24 Mar 2025 12:26:42 +0100 Subject: [PATCH 34/34] [azure parallel] [pyodide]