Skip to content

CI Add pytest soft dependency test to github actions - #32738

Merged
lesteve merged 8 commits into
scikit-learn:mainfrom
FrancoisPgm:ci_pytest_soft_dep
Nov 19, 2025
Merged

lesteve merged 8 commits into
scikit-learn:mainfrom
FrancoisPgm:ci_pytest_soft_dep

Conversation

@FrancoisPgm

Copy link
Copy Markdown
Member

Reference Issues/PRs

Towards #32434

What does this implement/fix? Explain your changes.

Add a step in unit_tests GHA to run the test_pytest_soft_dependency.sh script.

Any other comments?

I tried to have a look at #31192 (comment), and it seems to me that there was a test with both with both array_api_strict and CHECK_PYTEST_SOFT_DEPENDENCY in this build which has CHECK_PYTEST_SOFT_DEPENDENCY: 'true' and a lock file with array_api_strict. But I'm not sure which exact mechanism in the modifications of #31192 was supposed to break test_estimator_checks.py.

@github-actions

github-actions Bot commented Nov 18, 2025 •

Copy link
Copy Markdown

✔️ Linting Passed

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

Generated for commit: 62d1e01. Link to the linter CI: here

@lesteve

lesteve commented Nov 18, 2025

Copy link
Copy Markdown
Member

Just to test this can you add CHECK_PYTEST_SOFT_DEPENDENCY: 'true' in the macOS pylatest_conda_forge_arm build in unit-tests.yml?

We could even leave it so at least we would have a array-API + CHECK_PYTEST_SOFT_DEPENDENCY: true CI build.


- name: Run pytest soft dependency test
run: bash -l build_tools/azure/test_pytest_soft_dependency.sh
if: ${{ env.CHECK_PYTEST_SOFT_DEPENDENCY == 'true' && needs.retrieve-selected-tests.outputs.tests == ''}}

@lesteve lesteve Nov 18, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No strong opinion on needs.retrieve-selected-tests.outputs.tests == '' condition.

  • in general if you use [all random seeds] you only care about running a few selected tests with all random seeds, you don't really care about running the doctests
  • at the same time running pytest soft dependency tests is quite quick ~15s on a recent Azure build log

But if we add it for running pytest soft dependency we may as well add it in the "run doctests" above.

Running doctests is a bit longer (~3 minutes on the first recent Azure build log I could find) ...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Since I had to add the check on CHECK_PYTEST_SOFT_DEPENDENCY I thought I might as well add the test on the [all random seeds]. I'll add it to the run doctests.

… and add the condition on [all random seeds] to the doctest tests
@FrancoisPgm FrancoisPgm changed the title CI Add pytest sif dependency test to github actions CI Add pytest soft dependency test to github actions Nov 18, 2025
@lesteve

lesteve commented Nov 18, 2025

Copy link
Copy Markdown
Member

So macOS arm build fails, turns out that build_tools/azure/test_pytest_soft_dependency.sh uses an Azure-specific environment variable $BUILD_SOURCESDIRECTORY. I would try using $PWD instead and see if that works.

Context: IIRC for some partly historic reason, we have at least one build that doesn't install in editable mode and we cd into TEST_DIR before running the tests, otherwise pytest find the local sklearn folder rather than the installed sklearn package.

@lesteve

lesteve commented Nov 19, 2025

Copy link
Copy Markdown
Member

Nice it looks like this is working.

I would use $PWD in build_tools/azure/test_pytest_soft_dependency.sh. This make more sense to me (making our scripts CI provider agnostic) than using an Azure-specific environment variable name in GHA.

@lesteve lesteve left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

@lesteve

lesteve commented Nov 19, 2025 •

Copy link
Copy Markdown
Member

I couldn't resist pushing a test commit a68e381 (#32738) to see whether it breaks pytest soft dependency check (I would hope so), i.e. my understanding of #31192 (comment).

I will revert it once we have the answer.

Edit: the pytest soft dependency check is indeed failing which is reassuring see build log

@lesteve

lesteve commented Nov 19, 2025

Copy link
Copy Markdown
Member

Let's merge this one, thanks!

@lesteve
lesteve merged commit 2b0f476 into scikit-learn:main Nov 19, 2025
@FrancoisPgm
FrancoisPgm deleted the ci_pytest_soft_dep branch November 19, 2025 14:39
@lesteve lesteve mentioned this pull request Nov 26, 2025
11 of 14 tasks
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.

2 participants