Skip to content

CI: use a single function for GH calls - #47474

Merged
ydshieh merged 6 commits into
mainfrom
tarek-improve-gh-calls
Jul 28, 2026
Merged

ydshieh merged 6 commits into
mainfrom
tarek-improve-gh-calls

Conversation

@tarekziade

@tarekziade tarekziade commented Jul 22, 2026 •

Copy link
Copy Markdown
Collaborator

CI

What does this PR do?

  • unify all GH calls to the same function
  • make sure it uses vanilla Python so we can use it in all GH actions
  • do not retry on 401 for expired tokens

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@tarekziade tarekziade self-assigned this Jul 23, 2026
Comment thread utils/github_utils.py Resolved
ydshieh and others added 4 commits July 28, 2026 11:54
…o github_utils

- Add _log_token_status(): calls /rate_limit once before the retry loop (no quota
  consumed). Fails immediately if: CI env with no token, token rejected (401), or
  quota already exhausted (remaining=0). 401 with vs. without token gives distinct
  actionable error messages.
- Add _log_rate_limit_headers(): prints limit/used/remaining/reset on every request
  attempt, labeled [initial] / [retry N/M]. Skipped on 401 (GitHub omits those
  headers on auth failures).
- Remove _is_expired_or_bad_token(): pre-flight check catches bad tokens earlier;
  401s in the retry loop fall through to the generic fail-hard with the raw body.
- Update tests: remove IsExpiredOrBadTokenTest (function deleted), add
  LogTokenStatusTest covering all _log_token_status failure modes, patch
  _log_token_status in GithubRequestTest.setUp so mock responses are not consumed
  by the pre-flight call.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
get_github_json now raises RuntimeError on error responses (rate limiting,
auth failures, etc.) rather than returning an error dict. Update comments
in notification_service.py and check_bad_commit.py that incorrectly described
the old behaviour, while keeping the defensive .get() calls which guard
against unexpected response shapes.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@ydshieh

ydshieh commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

run-slow: vit

@github-actions

Copy link
Copy Markdown
Contributor

Workflow Run ⚙️

This comment contains run-slow, running the specified jobs:

models: ["models/vit"]
quantizations: []

@github-actions

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 30365348080:1
Result: success | Jobs: 4 | Tests: 322 | Failures: 2 | Duration: 2m 15s

@github-actions

Copy link
Copy Markdown
Contributor

CI Results

Workflow Run ⚙️

Commit Info

Context Commit Description
RUN 890ddcd0 workflow commit (merge commit)
PR 2f419036 branch commit (from PR)
main ebea912f base commit (on main)

✅ No failing test specific to this PR 🎉 👏 !

@ydshieh
ydshieh merged commit d0e91c7 into main Jul 28, 2026
34 checks passed
@ydshieh
ydshieh deleted the tarek-improve-gh-calls branch July 28, 2026 14:03
stevhliu pushed a commit to stevhliu/transformers that referenced this pull request Jul 30, 2026
* use a single function for GH calls

* check token before loop

* Add pre-flight token/quota check and per-request rate-limit logging to github_utils

- Add _log_token_status(): calls /rate_limit once before the retry loop (no quota
  consumed). Fails immediately if: CI env with no token, token rejected (401), or
  quota already exhausted (remaining=0). 401 with vs. without token gives distinct
  actionable error messages.
- Add _log_rate_limit_headers(): prints limit/used/remaining/reset on every request
  attempt, labeled [initial] / [retry N/M]. Skipped on 401 (GitHub omits those
  headers on auth failures).
- Remove _is_expired_or_bad_token(): pre-flight check catches bad tokens earlier;
  401s in the retry loop fall through to the generic fail-hard with the raw body.
- Update tests: remove IsExpiredOrBadTokenTest (function deleted), add
  LogTokenStatusTest covering all _log_token_status failure modes, patch
  _log_token_status in GithubRequestTest.setUp so mock responses are not consumed
  by the pre-flight call.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* Fix stale comments about get_github_json error handling

get_github_json now raises RuntimeError on error responses (rate limiting,
auth failures, etc.) rather than returning an error dict. Update comments
in notification_service.py and check_bad_commit.py that incorrectly described
the old behaviour, while keeping the defensive .get() calls which guard
against unexpected response shapes.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* format

* fix

---------

Co-authored-by: ydshieh <[email protected]>
Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Sainava pushed a commit to Sainava/Sai-transformers that referenced this pull request Aug 3, 2026
* use a single function for GH calls

* check token before loop

* Add pre-flight token/quota check and per-request rate-limit logging to github_utils

- Add _log_token_status(): calls /rate_limit once before the retry loop (no quota
  consumed). Fails immediately if: CI env with no token, token rejected (401), or
  quota already exhausted (remaining=0). 401 with vs. without token gives distinct
  actionable error messages.
- Add _log_rate_limit_headers(): prints limit/used/remaining/reset on every request
  attempt, labeled [initial] / [retry N/M]. Skipped on 401 (GitHub omits those
  headers on auth failures).
- Remove _is_expired_or_bad_token(): pre-flight check catches bad tokens earlier;
  401s in the retry loop fall through to the generic fail-hard with the raw body.
- Update tests: remove IsExpiredOrBadTokenTest (function deleted), add
  LogTokenStatusTest covering all _log_token_status failure modes, patch
  _log_token_status in GithubRequestTest.setUp so mock responses are not consumed
  by the pre-flight call.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* Fix stale comments about get_github_json error handling

get_github_json now raises RuntimeError on error responses (rate limiting,
auth failures, etc.) rather than returning an error dict. Update comments
in notification_service.py and check_bad_commit.py that incorrectly described
the old behaviour, while keeping the defensive .get() calls which guard
against unexpected response shapes.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* format

* fix

---------

Co-authored-by: ydshieh <[email protected]>
Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants