diff --git a/.github/workflows/add-models-to-runs.yml b/.github/workflows/add-models-to-runs.yml index cc07b43..ffda0ac 100644 --- a/.github/workflows/add-models-to-runs.yml +++ b/.github/workflows/add-models-to-runs.yml @@ -9,7 +9,7 @@ on: description: 'Comma-separated config IDs whose latest run gets the models' required: true rebuild_summaries: - description: 'Rebuild homepage, leaderboards and model summaries at the end' + description: 'Rebuild homepage, leaderboards and model summaries at the end (even if nothing changed)' type: boolean default: true rejudge: diff --git a/src/app/api/internal/add-models-to-runs/__tests__/route.test.ts b/src/app/api/internal/add-models-to-runs/__tests__/route.test.ts index 4cdf57c..e18e701 100644 --- a/src/app/api/internal/add-models-to-runs/__tests__/route.test.ts +++ b/src/app/api/internal/add-models-to-runs/__tests__/route.test.ts @@ -47,7 +47,7 @@ describe('POST /api/internal/add-models-to-runs', () => { expect(vi.mocked(addModelsToLatestRun).mock.calls[0][3]).toEqual({ rejudge: true, retryFailed: true }); }); - it('keeps going after a blueprint throws, and skips the rebuild when nothing was added', async () => { + it('keeps going after a blueprint throws, and rebuilds when asked even if nothing was added', async () => { vi.mocked(addModelsToLatestRun) .mockRejectedValueOnce(new Error('boom')) .mockResolvedValueOnce({ configId: 'b', status: 'skipped' }); @@ -57,6 +57,16 @@ describe('POST /api/internal/add-models-to-runs', () => { await flush(); expect(addModelsToLatestRun).toHaveBeenCalledTimes(2); + expect(actionBackfillSummary).toHaveBeenCalledTimes(1); + }); + + it('does not rebuild unless asked', async () => { + vi.mocked(addModelsToLatestRun).mockImplementation(async (configId) => ({ configId, status: 'added' })); + + const res = await POST(request({ models: [APERTUS], configIds: ['a'] })); + expect(res.status).toBe(202); + await flush(); + expect(actionBackfillSummary).not.toHaveBeenCalled(); }); diff --git a/src/app/api/internal/add-models-to-runs/route.ts b/src/app/api/internal/add-models-to-runs/route.ts index 5cb2569..989c85b 100644 --- a/src/app/api/internal/add-models-to-runs/route.ts +++ b/src/app/api/internal/add-models-to-runs/route.ts @@ -17,7 +17,8 @@ const MAX_CONFIGS = 300; * * Returns 202 immediately and works through the blueprints one at a time in * the background, logging under "add-models:". With rebuildSummaries, it - * rebuilds the homepage, leaderboards and model summaries once at the end. + * rebuilds the homepage, leaderboards and model summaries once at the end, + * even when no blueprint changed (so the box doubles as a plain rebuild). * With rejudge, listed models a run already has are judged again from their * saved responses instead of being skipped. With retryFailed, they are asked * again on the prompts where their answer failed. @@ -91,7 +92,7 @@ async function runJob( logger.info(`[AddModels] Done: ${count('added')} added, ${count('skipped')} skipped, ${count('failed')} failed.`); for (const r of results.filter(r => r.status === 'failed')) logger.warn(`[AddModels] Failed: ${r.configId}: ${r.reason}`); - if (rebuildSummaries && count('added') > 0) { + if (rebuildSummaries) { try { logger.info('[AddModels] Rebuilding homepage, leaderboards and model summaries...'); await actionBackfillSummary({ verbose: false, dryRun: false });