Skip to content

CI Move some pip_dependencies to conda_dependencies #31623

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 12 commits into from
Jul 8, 2025

Conversation

StefanieSenger
Copy link
Member

This PR updates update_environments_and_lock_files.py to use conda for packages that were installed via pip but are now available on conda.

Copy link

github-actions bot commented Jun 22, 2025

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: c0b62a5. Link to the linter CI: here

@StefanieSenger
Copy link
Member Author

This is a draft to be able to experiment.

I checked all packages in pip_dependencies if the required version is available on the conda channel that is used in this CI setting.

I was unsure and have not moved meson, because it was not explicitly mentioned in this comment and I assume there is a reason for it?

Other dependencies have not defined a version in our pyproject.toml and I have moved them to conda_dependencies regardless if they were available: lightgbm, array-api-strict, pytest-xdist, ninja, jupyterlite-sphinx, and jupyterlite-pyodide-kernel. That means they will probably come in different versions as with pypi and we'll see where this leads, when the CIs have run.

@StefanieSenger
Copy link
Member Author

StefanieSenger commented Jun 22, 2025

Okay, seems that the version change in array-api-strict, which has no specified version our pyproject.toml, but was 2.4 (edit: no it was 2.3.1) with pip, and would be 2.2 with conda defaults as required by thepylatest_pip_openblas_pandas CI caused some tests to fail. So I think I should move it back to the pip_dependencies.

@StefanieSenger
Copy link
Member Author

StefanieSenger commented Jun 22, 2025

I have moved array-api-strict back to the pip_dependencies, and now it shows up in the diff of the lock file for the first time (before it didn't which I thought was strange) as:

# pip array-api-strict @ https://files.pythonhosted.org/packages/fe/c7/a97e26083985b49a7a54006364348cf1c26e5523850b8522a39b02b19715/array_api_strict-2.3.1-py3-none-any.whl#sha256=0ca6988be1c82d2f05b6cd44bc7e14cb390555d1455deb50f431d6d0cf468ded
# pip array-api-strict @ https://files.pythonhosted.org/packages/e5/33/cede42b7b866db4b77432889314fc652ecc5cb6988f831ef08881a767089/array_api_strict-2.4-py3-none-any.whl#sha256=1cb20acd008f171ad8cce49589cc59897d8a242d1acf8ce6a61c3d57b61ecd14

That shows that before version 2.3.1 was used and now it is the newest version on pypi 2.4, that was released 6 days ago.
I don't know why it is not version-locked since it is a fast developing library, but let's hope now the CI passes.

Edit: Nice they all passed. 🎉

Now it's only the Windows CI failing, and this is unrelated and coming from main.

@StefanieSenger StefanieSenger marked this pull request as ready for review June 22, 2025 08:52
@betatim
Copy link
Member

betatim commented Jun 25, 2025

This PR updates update_environments_and_lock_files.py to use conda for packages that were installed via pip but are now available on conda.

Do you know why we used pip for these and not conda? Was it because the version we wanted were not available on conda-forge? I don't know the answer but I assume that (like so many things in scikit-learn) it was done for a specific reason. If we know the reason then it is less likely to break something by accident

@StefanieSenger
Copy link
Member Author

StefanieSenger commented Jun 25, 2025

@betatim: I didn't know this before, but @adrinjalali told me that's a maintanance task we do from time to time. It is necessary because the versions we need were not available (before) on the respective conda channel that is used for this job (some use conda-forge and other use conda defaults channel) - but now they might be and we prefer this.

I also took notes while I checked everything. Let me share these, maybe it helps with reviewing:

We have specific minimal version requirements in our pyproject.toml:

We do not have a version specified in pyproject.toml and have thus used the newest version available on pypi:

Whether I have checked the version from the main ("defaults") channel or the conda-forge channel depends on how the channel in the job was specified in build_tools/update_environments_and_lock_files.py. Did I do all that correctly 🤷 ?

@betatim
Copy link
Member

betatim commented Jun 25, 2025

Cool! Thanks for doing the "chopping wood and carrying water" on moving things from PyPI to conda.

@betatim
Copy link
Member

betatim commented Jun 25, 2025

As far as I can tell all the moves make sense. I think we should wait for the CI to be working again and run it again. Maybe even using the [cd build] marker in a commit message to run the builds?

"conda_dependencies": ["python", "ccache"],
"pip_dependencies": (
remove_from(common_dependencies, ["python", "blas", "pip"])
"conda_dependencies": (
Copy link
Member

Choose a reason for hiding this comment

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

So this build's goal (note the pip in pylatest_pip_openblas_pandas) is to install everything with pip, and you don't want to move things to conda dependencies here.

@@ -234,7 +231,15 @@ def remove_from(alist, to_remove):
"folder": "build_tools/azure",
"platform": "linux-64",
"channels": ["defaults"],
"conda_dependencies": ["python", "ccache"],
"conda_dependencies": [
Copy link
Member

Choose a reason for hiding this comment

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

Same thing here, the pip inside the build name means we want to install all Python packages with pip.

@StefanieSenger
Copy link
Member Author

StefanieSenger commented Jul 6, 2025

Thanks for reviewing and your support @betatim and @lesteve! I have reverted the changes in the jobs that have "_pip_" in their name, resolved the conflicts with main and build the lock files again (with --select-build only those that I have changed in this PR: pylatest_conda_mkl_no_openmp, doc_min_dependencies and doc)

@StefanieSenger
Copy link
Member Author

StefanieSenger commented Jul 6, 2025

Oh, it seems that without re-building the lock files for pylatest_pip_openblas_pandas and pylatest_pip_scipy_dev too, the old lock files from my PR (that moved dependencies from conda to pip) where still on this branch. That doesn't fit at all with my current understanding of how resolving conflicts with lock files works (I have used the bash command that we have in our Resolve conflicts in lock files and to my understanding this should entirely prioritise the lock files from main over whatever lock files I had build before.

I have now rebuild the lock files for pylatest_pip_openblas_pandas and pylatest_pip_scipy_dev jobs too and these look better (only updates to some packages but no moving from pip to conda anymore).

@lesteve
Copy link
Member

lesteve commented Jul 8, 2025

Can you fix the conflicts? Each time we merged the automatic lock-files update on Monday, this may create new conflicts unfortunately ...

Based on the CI builds you are changing, I would suggest to only update the lock-files you want to change with the --select-build argument:

python build_tools/update_environments_and_lock_files.py --select-build <some-text-goes-here>

By default build_tools/update_environment_and_lock_files.py updates all the lock-files.

@StefanieSenger
Copy link
Member Author

Thanks @lesteve! I have pulled main and re-generated the relevant lock files. Let's hope everything does fine with the CI. :)

@lesteve
Copy link
Member

lesteve commented Jul 8, 2025

LGTM, I enabled auto-merge and pushed a commit to make sure we run the full doc build with [doc build] marker just to be sure.

@lesteve lesteve enabled auto-merge (squash) July 8, 2025 12:13
@lesteve
Copy link
Member

lesteve commented Jul 8, 2025

@StefanieSenger as a follow-up if you feel like it, you could tackle this TODO (noticed it while reviewing):

# scipy 1.12.x crashes on this platform (https://github.com/scipy/scipy/pull/20086)
# TODO: release scipy constraint when 1.13 is available in the "default"
# channel.
"scipy": "<1.12",

scipy >= 1.13 is available in the defaults channel and so removing the scipy constraint should "just work", but the only way to know is to try ...

@lesteve lesteve merged commit e971134 into scikit-learn:main Jul 8, 2025
34 checks passed
@StefanieSenger StefanieSenger deleted the move_pip-dependencies branch July 9, 2025 07:27
@StefanieSenger
Copy link
Member Author

Oh yes, nice, I will take care of this. Thanks for the hint, @lesteve! :)

jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Jul 15, 2025
@jeremiedbb jeremiedbb mentioned this pull request Jul 15, 2025
13 tasks
jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Jul 16, 2025
jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Jul 16, 2025
jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Jul 16, 2025
jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Jul 16, 2025
jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Jul 16, 2025
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.

3 participants