-
Notifications
You must be signed in to change notification settings - Fork 685
Create pending_user_response.py #13881
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
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
87e7457
Create pending_user_response.py
nil-is-all 8d87136
Create pending_user_response.yml
nil-is-all 440ffc8
removed API calls in pending_user_response.py
nil-is-all cd95949
re-enable API call to allow testing of fetching issues
nil-is-all 40eceb8
Removed issue simulation in python script since we now fetch actual i…
nil-is-all c209a62
Update pending_user_response.py to prevent duplicate reminders
nil-is-all 78ca940
Update pending_user_response.yml to have workflow dispatch
nil-is-all 2b32d3a
Update pending_user_response.py to fix lintrunner
nil-is-all 7fff2bf
Update pending_user_response.py to fix lintrunner
nil-is-all a194264
Merge branch 'main' into nil-is-all-patch-1
nil-is-all 2fca973
Update pending_user_response.py to fix lint runner
nil-is-all ab5b2fa
Update pending_user_response.py to fix lint runner
nil-is-all dc11a0e
Update pending_user_response.py to fix lintrunner
nil-is-all 1292f32
Update pending_user_response.py to fix lintrunner
nil-is-all d27291b
Merge branch 'main' into nil-is-all-patch-1
nil-is-all File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import datetime | ||
import os | ||
|
||
from github import Github | ||
|
||
REPO_NAME = "pytorch/executorch" | ||
LABEL = "need-user-input" | ||
REMINDER_MARKER = "<!-- executorch-auto-reminder -->" | ||
REMINDER_COMMENT = ( | ||
f"{REMINDER_MARKER}\nHi @{0}, this issue/PR has been marked as 'need-user-input'. " | ||
"Please respond or provide input. If we don't hear back in 30 days, this will be closed." | ||
) | ||
CLOSE_COMMENT = ( | ||
f"{REMINDER_MARKER}\nClosing due to no response after 30 days. " | ||
"If you still need help, feel free to re-open or comment again!" | ||
) | ||
DAYS_BEFORE_REMINDER = 30 | ||
DAYS_BEFORE_CLOSE = 30 | ||
REMINDER_COOLDOWN_DAYS = 7 # Don't post another reminder within 7 days | ||
|
||
|
||
def main(): | ||
g = Github(os.environ["GH_TOKEN"]) | ||
repo = g.get_repo(REPO_NAME) | ||
|
||
print("[VALIDATION] Would connect to Github and fetch repo:", REPO_NAME) | ||
issues = repo.get_issues(state="open", labels=[LABEL]) | ||
print(f"[VALIDATION] Would fetch open issues with label '{LABEL}'.") | ||
|
||
now = datetime.datetime.utcnow() | ||
|
||
for issue in issues: | ||
print(f"[VALIDATION] Would fetch comments for issue/PR #{issue.number}.") | ||
comments = [] # Replace with mock comments if needed | ||
last_comment = comments[-1] if comments else None | ||
|
||
# Find automation comments | ||
auto_comments = [c for c in comments if REMINDER_MARKER in c.body] | ||
user_comments = [c for c in comments if REMINDER_MARKER not in c.body] | ||
|
||
# ---- REMINDER LOGIC ---- | ||
# Only remind if NO reminder in last 7 days | ||
recent_auto_reminder = any( | ||
(now - c.created_at).days < REMINDER_COOLDOWN_DAYS for c in auto_comments | ||
) | ||
|
||
if not auto_comments: | ||
if ( | ||
last_comment | ||
and (now - last_comment.created_at).days >= DAYS_BEFORE_REMINDER | ||
): | ||
user = issue.user.login | ||
print(f"[VALIDATION] Would remind {user} on issue/PR #{issue.number}") | ||
elif auto_comments and not recent_auto_reminder: | ||
# Only post new reminder if last was > REMINDER_COOLDOWN_DAYS ago | ||
last_auto = auto_comments[-1] | ||
user = issue.user.login | ||
if (now - last_auto.created_at).days >= REMINDER_COOLDOWN_DAYS: | ||
print( | ||
f"[VALIDATION] Would remind {user} again on issue/PR #{issue.number}" | ||
) | ||
|
||
# ---- EXISTING CLOSE/REMOVE LABEL LOGIC ---- | ||
if auto_comments: | ||
last_auto = auto_comments[-1] | ||
user_responded = any( | ||
c.created_at > last_auto.created_at and c.user.login == issue.user.login | ||
for c in user_comments | ||
) | ||
if not user_responded: | ||
if (now - last_auto.created_at).days >= DAYS_BEFORE_CLOSE: | ||
print( | ||
f"[VALIDATION] Would close issue/PR #{issue.number} due to inactivity." | ||
) | ||
else: | ||
print( | ||
f"[VALIDATION] Would remove label from issue/PR #{issue.number} after user response." | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Needs User Input Automation | ||
|
||
on: | ||
schedule: | ||
- cron: '0 8 * * 1' # runs every Monday at 8:00 UTC | ||
workflow_dispatch: | ||
|
||
jobs: | ||
needs-user-input: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Install dependencies | ||
run: pip install PyGithub | ||
|
||
- name: Run needs-user-input script | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: python .github/scripts/pending_user_response.py |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add on workflow dispatch to allow manual triggering? Here's an example: https://github.com/pytorch/executorch/blob/main/.github/workflows/trunk.yml#L11