Repository navigation
CI Add "autoclose" workflow by label setting - #32504
Conversation
| for PR in $(gh pr list --repo "$GH_REPO" --label autoclose --state open --json number --jq '.[].number'); do | ||
| TIMESTAMP=$(gh api repos/$GH_REPO/issues/$PR/events --jq ' | ||
| map(select(.event == "labeled" and .label.name == "autoclose")) | | ||
| last?.created_at' | tr -d '"') |
There was a problem hiding this comment.
last?.created_at looks up only the last time, the autoclose label was set.
This means, we can set, remove and re-set the label, if needed.
There was a problem hiding this comment.
Thanks for the PR! I think it definitely goes in the right direction.
Personally I am 👍 for trying an approach like this and adapt it as we go depending on how useful it turns out to be.
As someone who is still a bit worried about this approach being perceived as a bit harsh/not welcoming enough, something I only recently realized: you can have a saved search that gives you the list of opened issues with auto-close label and you can have a quick look and decide to remove the label if things have improved significantly since the label was set. i.e. something like this (I used the "Array API" label for this example and ordered by least recently updated)
https://github.com/scikit-learn/scikit-learn/pulls?q=is%3Apr+is%3Aopen+label%3A%22Array+API%22+sort%3Aupdated-asc
More minor comments:
- the wording of the first comment looks good in general
- the wording of the second/closing comment, I need to think about it more, or maybe I'll just wait for other opinions!
| runs-on: ubuntu-latest | ||
| steps: | ||
|
|
||
| - name: detect labeled PRs and filter for older than 14 days |
There was a problem hiding this comment.
To make this step easier to maintain, I would rewrite it as a Python script. The bash logic is a bit complicated IMO.
lucyleeow
left a comment
There was a problem hiding this comment.
Some comments but I'm +1 for trialling this.
I have kind of been using the 'closing candidate' label in a similar way atm.
| [contribution guide](https://scikit-learn.org/dev/developers/contributing.html). | ||
| - Include a clear motivation and concise explanation of what the PR does \ | ||
| in the pull request description. | ||
| - Make sure the code runs and passes tests locally (`pytest`) and in the CI. |
There was a problem hiding this comment.
Do you think it is worth adding a link to https://scikit-learn.org/dev/developers/contributing.html#testing-and-improving-test-coverage ?
Also should we add that the linter is passing?
There was a problem hiding this comment.
I would tend to not include both, though no strong opinion.
The linting is already covered when we mention the CI should pass.
On the testing: most new contributors do add tests and not ideal tests / not perfect coverage is hasd to explain and not reason for me to apply an autoclose label. If they didn't add any tests, there are usually other problems that also justify an autoclose.
| - Ensure your contribution aligns with our \ | ||
| [contribution guide](https://scikit-learn.org/dev/developers/contributing.html). |
There was a problem hiding this comment.
This will be mentioned in our contribution guide but I wonder if we want to add that they should reference an issue where there is consensus on how to address it, and someone else has not already started working on it.
Also is it worth mentioning that contribution should not be solely AI generated with no curation...? Not sure if we want to mention this
There was a problem hiding this comment.
I wonder if we want to add that they should reference an issue where there is consensus on how to address it, and someone else has not already started working on it.
For me, these are reasons to immediately close this PR. Why would we want to keep a suplicate PR open or a PR that was made before an issue was triaged?
Also is it worth mentioning that contribution should not be solely AI generated with no curation...?
I was hoping that "don't commit code you don't understand" below would capture this case and also cases where AI was used and not thoroughly reviewed.
| time for improvements. | ||
|
|
||
| We apologise for the inconvenience. If you think your PR has been closed \ | ||
| by mistake, please contact a maintainer. |
There was a problem hiding this comment.
I wonder if we should specify how exactly we want them to contact us?
There was a problem hiding this comment.
Not sure. We had discussed this before and agreed it is better not to mention pinging people, to not give incentive for cases where a ping is not justified. I am happy to change this if someone has a good formulation.
There was a problem hiding this comment.
I think we either include a way that we want them to contact us, or we don't include the line "contact a maintainer" at all.
This may lead to the contributor trying to contact in ways that are not ideal (e..g. pinging someone, pinging everyone) and it's just not nice to say contact us but then don't tell people how.
I would just say, either ask them to comment in the PR or email CoC? From talking to another maintainer (n=1) of a different project, they have never (or almost never) had anyone follow up an autoclose 😅
There was a problem hiding this comment.
What do you think about:
"If you think your PR has been closed by mistake, please comment on this PR including a ping to the maintainer who set the autoclose label?"
There was a problem hiding this comment.
I'd be okay with this, we can always adapt if we find we are getting too many pings.
But let's see what others, that are likely to use this, think - @adrinjalali @betatim @lesteve ...not sure who else
nit:
"If you think your PR has been closed by mistake, please comment on this PR including a ping (using @) to the maintainer who set the autoclose label?"
StefanieSenger
left a comment
There was a problem hiding this comment.
Thanks for reviewing @lesteve and @lucyleeow!
I have rewritten the long bash code in python to make it more maintainable and replied to the other suggestions. I am really happy to change the wording of the messages if you have suggestions, but let's try to keep to as concise as possible. If we add something let's in turn remove / reword something with a similar meaning.
| - name: detect labeled PRs and filter for older than 14 days | ||
| run: | | ||
| set -e | ||
| ALL_LABELED_PRS=$(gh pr list --repo "$GH_REPO" --label autoclose --state open --json number --jq '.[].number') |
There was a problem hiding this comment.
I have pythonised the previous bash code and it's in filter_autoclose_events.py now. Though there doesn't seem to be a rest API endpoint for filtering all labeled PRs, so I keep this part in bash.
There was a problem hiding this comment.
You may as well move the gh pr list to Python as well, something like this:
import subprocess
command = [
'gh',
'pr',
'list',
'--repo',
os.environ["GH_REPO"],
'--label',
'autoclose',
'--state',
'open',
'--json',
'number',
'--jq',
'.[].number'
]
output = subprocess.run(command, capture_output=True)
output = output.decode('utf-8')Basically it's a bit weird to have a small part in bash and the rest in Python.
There was a problem hiding this comment.
Nice, I didn't know this existed. I have added this to the python file.
| [contribution guide](https://scikit-learn.org/dev/developers/contributing.html). | ||
| - Include a clear motivation and concise explanation of what the PR does \ | ||
| in the pull request description. | ||
| - Make sure the code runs and passes tests locally (`pytest`) and in the CI. |
There was a problem hiding this comment.
I would tend to not include both, though no strong opinion.
The linting is already covered when we mention the CI should pass.
On the testing: most new contributors do add tests and not ideal tests / not perfect coverage is hasd to explain and not reason for me to apply an autoclose label. If they didn't add any tests, there are usually other problems that also justify an autoclose.
| - Ensure your contribution aligns with our \ | ||
| [contribution guide](https://scikit-learn.org/dev/developers/contributing.html). |
There was a problem hiding this comment.
I wonder if we want to add that they should reference an issue where there is consensus on how to address it, and someone else has not already started working on it.
For me, these are reasons to immediately close this PR. Why would we want to keep a suplicate PR open or a PR that was made before an issue was triaged?
Also is it worth mentioning that contribution should not be solely AI generated with no curation...?
I was hoping that "don't commit code you don't understand" below would capture this case and also cases where AI was used and not thoroughly reviewed.
| time for improvements. | ||
|
|
||
| We apologise for the inconvenience. If you think your PR has been closed \ | ||
| by mistake, please contact a maintainer. |
There was a problem hiding this comment.
Not sure. We had discussed this before and agreed it is better not to mention pinging people, to not give incentive for cases where a ping is not justified. I am happy to change this if someone has a good formulation.
| timestamp_label_last_set = None | ||
| url = f"https://api.github.com/repos/{GH_REPO}/issues/{pr}/events" | ||
| events = _get_paginated_results(url, get_headers(GITHUB_TOKEN)) | ||
| for event in events: |
There was a problem hiding this comment.
events are sorted chronologically, so we will only keep the date of the last time when the label was set.
| - Only submit code you understand and can maintain. We will likely request \ | ||
| changes or explanations. |
There was a problem hiding this comment.
What do you think of adding, please disclose any AI use here...?
betatim
left a comment
There was a problem hiding this comment.
A few review comments, some about grammar tweaks.
I think we should merge this and start using it. We will gather experience as we use it, based on what user's responses are, etc. So let's merge now and then adjust things in a few weeks when we have that real world feedback.
| -f "body=$BODY" | ||
| env: | ||
| BODY: | | ||
| This pull request has been labeled for potential autoclose. |
There was a problem hiding this comment.
I don't love the first sentence ("for potential autoclose"), it somehow feels like much bad english. Below a suggestion that I could come up with that I feel is better english, but it says something slightly different from what is currently in the message.
| This pull request has been labeled for potential autoclose. | |
| This pull request might be automatically closed in two weeks from now. |
| - Include a clear motivation and concise explanation of what the PR does \ | ||
| in the pull request description. |
There was a problem hiding this comment.
| - Include a clear motivation and concise explanation of what the PR does \ | |
| in the pull request description. | |
| - Include a clear motivation and concise explanation of why you chose this solution \ | |
| in the pull request description. |
Along the lines on what we tell people regarding comments: don't tell me what the code does, tell me why this code is here. Often you can tell what it does, the more tricky thing is to figure out why it needs doing (this way).
There was a problem hiding this comment.
I think it'd be nice to merge this to be able to try it even if it is far from being perfect ... full disclosure: I am telling this to also convince myself 😅.
In an ideal world we should try to make the comment shorter. People (including me) don't read long comments, and people whose PR we will label as autoclose, probably even less.
One way would to make it shorter would be to point towards our PR checklist 1 and maybe other places in our doc.
It's really tricky to find the right balance between being considerate and not being overly apologetic, right now I feel it could be a tiny bit less apologetic, but maybe it's just me ...
One last existential comment to get it out of the way, but that can be completely ignored: autoclose or auto-close? I have a slight preference for auto-close.
Footnotes
-
I think our PR checklist should be improved (way too long and some stuff are really not that important but this can be done in a separate PR) ↩
lucyleeow
left a comment
There was a problem hiding this comment.
Agree with everyone else's general sentiments. Some more comments, but happy to try and move forward.
| If you have carefully reviewed these points but are still stuck on a \ | ||
| specific problem, please describe it in your own words. This helps \ | ||
| maintainers see that you have designed your contribution and understand \ | ||
| how it fits into the codebase, rather than submitting AI-generated or \ | ||
| copied content. We especially encourage beginners to ask focused questions \ | ||
| that show you've tried to explore the problem and are interested to engage \ | ||
| with the project. We may be able to provide guidance if your explanation of \ | ||
| the problem is clear and reflects your own reasoning. |
There was a problem hiding this comment.
I would tend to agree with Loic's suggestion of making this comment shorter. In particular this paragraph could be shortened a lot, maybe to just a one sentence bullet point in the list above.
| time for improvements. | ||
|
|
||
| We apologise for the inconvenience. If you think your PR has been closed \ | ||
| by mistake, please contact a maintainer. |
I would say "If you think your PR has been closed by mistake, please comment below". IMO the triage person can look at the label autoclose and decide to reopen closed issues or remove the autoclose label on some still opened PRs. We could decide to be explicit about this if we write a short triage doc #32661. Personally I am ping-averse, others may be different. In general I think one idea behind the label was to avoid notifications that you get if you comment on something. |
|
We could instruct them to re-open the PR. I think as the creator of a PR you can re-open it no matter who closed it. Pinging individual people isn't great because everything involving a single person has a high chance of getting missed/forgotten/etc. |
Nope, when a PR is closed by a maintainer, the author can not re-open the PR. I tested this in October 2025 in lesteve#42 (comment). Similar thing for issues by the way lesteve#43 (comment). |
|
Thanks for all the feedback! :) I think I have implemented it all, but am happy to apply further changes. |
| - Make sure the code runs and passes tests locally (`pytest`) and in the CI. | ||
| - Submit only code you can explain and maintain; reviewers will ask for \ | ||
| clarifications and changes. Disclose any AI assistance per our \ | ||
| [Automated Contributions Policy](https://scikit-learn.org/dev/developers/contributing.html#automated-contributions-policy). |
There was a problem hiding this comment.
Strange that looks different on my branch and respects the indent on the lines (even after pre-commit did its work of cause).
|
I would propose to remove the linebreaks in the two comments, since it looks nicer on the PRs. |
lucyleeow
left a comment
There was a problem hiding this comment.
Some more thoughts, just on the comments. Sorry this is probably not helpful in keeping this moving.
| other contributions and ongoing work. Unless this PR is improved, it will \ | ||
| be automatically closed after two weeks. | ||
|
|
||
| To avoid autoclose and increase the chance of a productive review, please: |
There was a problem hiding this comment.
Related #32734
I noticed that there are several places where we have a similar-ish list - spam FAQ and PR template.
I created a specific section in the FAQ for tips on improving issue/PRs in #32734
Maybe we could keep the list in one place and refer to it?
There was a problem hiding this comment.
I am happy to substitute this list with a pointed link, once we have that. This could then be a long and extensive list that mentions all the potential problems that a PR can come with. I think #32734 is a good candidate for that.
| If you are stuck, we encourage you to ask focused questions that show you \ | ||
| have tried to explore the problem and are interested to engage with the \ | ||
| project. We may be able to provide guidance if your explanation of the \ | ||
| problem is clear and reflects your own reasoning. | ||
|
|
||
| We understand it can be frustrating that we cannot provide individual \ | ||
| guidance on every PR. Reviewer capacity is very limited and our goal is to \ | ||
| prioritize well-prepared contributions to keep scikit-learn maintainable. |
There was a problem hiding this comment.
In light of keeping things short, I wonder if these 2 paragraphs could be shortened/amalgamated?
I think we have covered most of the second paragraph in the first ('Thank you for your contribution...') paragraph.
I am also not sure about the first paragraph, maybe pointing them to the list on how to improve their PR is adequate? I suspect if this label has been used, the questions they ask may be basic questions answered in our contributing guide or e.g., on basic git usage, which I am not sure maintainers have the time/energy to answer.
There was a problem hiding this comment.
I have shortened and merged both paragraphs in my latest commit. I find it important to signal that we are still inviting people to discuss and that we encourage questions, since I don't want to shut doors to new contributors who want to learn. We now write that we cannot answer all the questions, but we might be able to come back an help them if they are reflective.
I don't mind contributors to ask questions that go unanswered but it would be bad for the project to shut people down.
Co-authored-by: Lucy Liu <[email protected]>
|
I couldn't help rewriting the GitHub logic with PyGithub together with @StefanieSenger and @DeaMariaLeon 😅, which hopefully makes it a bit simpler, it was tested in StefanieSenger/GitHub-Actions-test-repo#1 (comment). We used this opportunity to tweak the "close" comment a tiny bit. I enabled auto-merge, let's try to use it and adapt it if we need. |
|
Nice, the Thanks to everyone who was involved and / or reviewing! 🎉 |
|
Thanks for creating the label, I am testing this in #32743. The comment worked. I guess we will actually be 100% sure that the autoclose mechanism works in two weeks 🤞. |
|
Another thing to check is tomorrow whether the autoclose workflow ran without errors https://github.com/scikit-learn/scikit-learn/actions/workflows/autoclose-schedule.yml. It should find no PRs to close. |
It ran as expected build log |
closes #32207
also towards #31679
This PR adds an "autoclose" workflow to the CI, as discussed in RFC: Proposal for autoclose option for non-compliant PRs.
These are two Github Actions workflow, that close a PR after a delay when an "autoclose" label is set, unless a scikit-learn member removes this label in time. In addition, the author of the PR gets a helpful comment when the label is set explaining how to get a PR into shape to make it more reviewable.
I've also drafted the two comments that get posted to a PR (one while lable-setting, the other while closing). Happy to discuss.