Skip to content

CI Run unit-tests with random seed on schedule and open automated issue - #32797

Merged
lesteve merged 1 commit into
scikit-learn:mainfrom
FrancoisPgm:scheduled_unit_tests_GHA
Nov 27, 2025
Merged

lesteve merged 1 commit into
scikit-learn:mainfrom
FrancoisPgm:scheduled_unit_tests_GHA

Conversation

@FrancoisPgm

@FrancoisPgm FrancoisPgm commented Nov 26, 2025 •

Copy link
Copy Markdown
Member

Reference Issues/PRs

Towards #32434

What does this implement/fix? Explain your changes.

Adding a scheduled and manual trigger for the unit-tests action, for both of these a random seed is used for SKLEARN_TESTS_GLOBAL_RANDOM_SEED. The update-tracker action is used to automatically create an issue if a scheduled test fails.

Any other comments?

When testing on my fork, the request to get the list of issues for the update-tracker to check if there already is an open issue for the CI failure returned an error saying the request should contain either is:issue or is:pull-request, so I updated maint_tools/update_tracking_issue.py but I assume it is working rn on the main repo, so maybe the issue was specific to my fork somehow and this update can be ignored.

Right now the pylatest_conda_forge_arm build explicitely uses SKLEARN_TESTS_GLOBAL_RANDOM_SEED: 5 which should override the use of a random value in the scheduled runs. I don't know if that's the expected behaviour or if we want to use 5 in non-scheduled runs and the random value in the scheduled ones.

EDIT: actually I misunderstood how the env variables are managed in the jobs, so the random value does override the non-default fixed 5 one.

@FrancoisPgm FrancoisPgm changed the title CI Run scheduled unit-tests with GHA, using a random seeds and the automatic issue tracker for failure CI Run scheduled unit-tests with GHA, using a random seeds and the automatic tracking issue for failure Nov 26, 2025
@github-actions

Copy link
Copy Markdown

✔️ Linting Passed

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

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

@lesteve

lesteve commented Nov 26, 2025 •

Copy link
Copy Markdown
Member

Nice! I guess you forgot to git add .github/workflows/update_tracking_issue.yml? Actually we already have this workflow used in wheels.yml, I definitely did not remember this 😅 ...

@lesteve

lesteve commented Nov 26, 2025 •

Copy link
Copy Markdown
Member

Right now the pylatest_conda_forge_arm build explicitely uses SKLEARN_TESTS_GLOBAL_RANDOM_SEED: 5 which should override the use of a random value in the scheduled runs. I don't know if that's the expected behaviour or if we want to use 5 in non-scheduled runs and the random value in the scheduled ones.

We want random seed in schedule runs, and 5 in non-scheduled runs. This way brittle numerical tests will be run once a day (and an automated issue will be opened in case of failures) rather than in PRs where it could fail randomly.

@lesteve lesteve mentioned this pull request Nov 26, 2025
11 of 14 tasks
@lesteve

lesteve commented Nov 27, 2025

Copy link
Copy Markdown
Member

To be honest I would have expected that the thing you did worked, i.e. that the environment variable in the step (via GITHUB_ENV) overrides the environment variable in the matrix entry. Maybe I am missing something, maybe it's a CI quirk I was not aware of ...

@FrancoisPgm

FrancoisPgm commented Nov 27, 2025 •

Copy link
Copy Markdown
Member Author

To be honest I would have expected that the thing you did worked, i.e. that the environment variable in the step (via GITHUB_ENV) overrides the environment variable in the matrix entry. Maybe I am missing something, maybe it's a CI quirk I was not aware of ...

No you're right, I was saying that based on my understanding of the workflow priority on env variable, but after actually checking the seed value, it does work the way you describe it, as the "Set random seed" step is executed after the env is initialised with the random seed at 5, so the random values overrides the 5. So I think it's actually good to go.

@lesteve

lesteve commented Nov 27, 2025

Copy link
Copy Markdown
Member

it does work the way you describe it, as the "Set random seed" step is executed after the env is initialised with the random seed at 5, so the random values overrides the 5

Nice, I am relieved that my mental model of GHA was accurate in this particular case 😌.

@lesteve lesteve changed the title CI Run scheduled unit-tests with GHA, using a random seeds and the automatic tracking issue for failure CI Run unit-tests with random seed on schedule and open automated issue Nov 27, 2025
@lesteve

lesteve commented Nov 27, 2025

Copy link
Copy Markdown
Member

Just for completeness, did you test this on your fork, and if yes can you link to a GHA log and/or an automated opened issue 🙏.

Looking at the diff, it looks fine, but testing in a fork is the only way to be 100% sure.

@FrancoisPgm

Copy link
Copy Markdown
Member Author

Yes I tested it on my fork, I just had to modify the workflows to check for my repo instead of scikit-learn/scikit-learn and for the update tracking issue one to trigger on manually triggered actions so that I can test manually.

Here is the issue that it managed to open and comment : FrancoisPgm#4

@FrancoisPgm

Copy link
Copy Markdown
Member Author

GH says I opened an commented the issue because I used a token for the workflow that signs in as me, I didn't go the exrta mile to have a bot token.

@lesteve

lesteve commented Nov 27, 2025

Copy link
Copy Markdown
Member

OK thanks seems all good, the is:issue does not hurt we can leave it.

@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 merged commit c915bbe into scikit-learn:main Nov 27, 2025
@lesteve

lesteve commented Nov 27, 2025

Copy link
Copy Markdown
Member

I manually triggered a unit test run to double-check everything was fine, follow it live at: https://github.com/scikit-learn/scikit-learn/actions/runs/19737362211

@lesteve

lesteve commented Nov 27, 2025

Copy link
Copy Markdown
Member

So I did not expect this but there is a failure great 🎉!

For some reason the issue creation job is skipped though, any idea why? See build log

@FrancoisPgm

Copy link
Copy Markdown
Member Author

Yes that's because the issue creation is done only for scheduled runs, not manual ones :

if: github.repository == 'scikit-learn/scikit-learn' && github.event_name == 'schedule'

@FrancoisPgm

Copy link
Copy Markdown
Member Author

In my fork I had to change it, in my case I just removed the if entirely but you could have if: github.repository == 'scikit-learn/scikit-learn' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'). I did not update it in the PR to keep a minimum of changes.

@lesteve

lesteve commented Nov 27, 2025 •

Copy link
Copy Markdown
Member

OK makes sense, thanks! Let's leave it like this for now and we can revisit if we ever feel a need to. I guess depending on the random state, there is a chance that an automated issue is opened tomorrow, gosh isn't it exciting 😉?

@lesteve

lesteve commented Nov 28, 2025 •

Copy link
Copy Markdown
Member

So I missed it somehow, and it's not a huge deal, but we actually want update_tracking issue on each matrix entry, i.e. if both build1 and build2 fails we want two separate issues one saying "build 1 failed", and the other one saying "build 2" failed.

Currently if I understand correctly we have a single issue saying Unit tests failed e.g. FrancoisPgm#4

Look at the currently opened issues by scikit-learn-bot if that can help clarifying what I am trying to say.

I guess there is a way to do what we want but I have to say I don't know it of the top of my head ...

It's true that Wheels are doing one issue for all the wheels build, maybe we will want to change this as well, I need to think about it more 🤔.

@FrancoisPgm

Copy link
Copy Markdown
Member Author

Ah ok, yes currently it behaves as you understand it, I thought it was desired behaviour to minimise the number of issue created, but now I get what's desired so I'll look into it.

@FrancoisPgm
FrancoisPgm deleted the scheduled_unit_tests_GHA branch December 4, 2025 13:32
lesteve pushed a commit to lesteve/scikit-learn that referenced this pull request Dec 9, 2025
@lesteve lesteve mentioned this pull request Dec 9, 2025
13 of 14 tasks
lesteve pushed a commit to lesteve/scikit-learn that referenced this pull request Dec 9, 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.

2 participants