Skip to content

Commit 5514186

Browse files
authored
Serve the advisor default branch from config instead of a repos.get call (#8582)
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.14.0) (oldest at bottom): * #8584 * __->__ #8582 * #8580 * #8579 * #8578 * #8576 **Impact:** AI CI Advisor auto-dispatch path (Dr.CI cron) **Risk:** low ## What Adds a `defaultBranch` field to `AdvisorRepoConfig` and reads it in `dispatchAdvisorWorkflow` instead of looking the default branch up via the GitHub `repos.get` REST call on every dispatch. ## Why The PyTorchBot GitHub App installation intermittently hits its shared hourly REST rate limit, causing random 403s. This drops one installation-token call per advisor dispatch (~12k/mo) by moving a value that never changes into the per-repo config, which is already the single source of truth for advisor settings. Signed-off-by: Jean Schmidt <contato@jschmidt.me>
1 parent bc357a4 commit 5514186

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

torchci/lib/advisor/advisorConfig.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ export interface AdvisorRepoConfig {
3636
// The workflow_dispatch file (on the repo's default branch) that runs the
3737
// advisor analysis for this repo.
3838
workflowFile: string;
39+
// The repo's default branch (e.g. "main") the advisor dispatches against. Kept
40+
// as config so the dispatch path needs no repos.get REST call per run.
41+
defaultBranch: string;
3942
// Auto-dispatch bails entirely if a PR has more than this many NEW failures
4043
// (outage guard), unless the PR carries an OUTAGE_GUARD_BYPASS_LABELS label.
4144
// Falls back to DEFAULT_MAX_NEW_FAILURES when unset.
@@ -54,6 +57,7 @@ export interface AdvisorRepoConfig {
5457
export const ADVISOR_REPOS: Record<string, AdvisorRepoConfig> = {
5558
"pytorch/pytorch": {
5659
workflowFile: "claude-autorevert-advisor.yml",
60+
defaultBranch: "main",
5761
maxNewFailures: 8,
5862
maxDispatchPerPr: 32,
5963
},

torchci/lib/advisor/advisorDispatch.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,7 @@ export async function dispatchAdvisorWorkflow(
187187
const botOctokit = await getOctokit(owner, repo);
188188
const jobPattern = jobNameToBasePattern(jobName);
189189

190-
// Look up default branch (usually "main") instead of hardcoding
191-
const repoData = await botOctokit.rest.repos.get({ owner, repo });
192-
const defaultBranch = repoData.data.default_branch;
190+
const defaultBranch = cfg.defaultBranch;
193191

194192
// Fetch merge base SHA from GitHub
195193
let resolvedMergeBase = params.mergeBaseSha || "";

0 commit comments

Comments
 (0)