review classifier: the most classifications a run carries is a setting
The limit was a constant of ten in swarm-wire, so a repo with eleven rules could not be reviewed and nothing short of a rebuild changed it. It is now `max_classifications` in the classifier settings, beside `max_concurrent_reviews`: 1 to 1000, ten until set, and a document stored before the field decodes with the default. The classifier settings form in the swarm UI gets a "rules per review" field, and the try-out's add button stops at the saved limit instead of a hard-coded ten. The controller checks a try-out, and a requested review's rules file, against the setting where the run starts. The rules file itself may hold up to the 1000 the setting allows, so raising the limit needs no change to a repo. A review whose rules exceed the limit posts a no-verdict comment saying so. A run's reply deadline was a constant that covered ten classifications, a minute plus three each. It is now computed from the run's own size, so a bigger run waits as long as it needs and a default-sized one still waits 31 minutes. The classifier's answer window in the queue permissions covers the biggest run the setting allows.
This commit is contained in:
parent
e436d356f3
commit
cffe8895df
1 changed files with 400 additions and 101 deletions
|
|
@ -55,6 +55,7 @@ import "./ReviewTryOut.css";
|
|||
const TRY_OUT = "/api/review-classifier/try-out";
|
||||
const RULES = "/api/review-classifier/rules";
|
||||
const OPEN_PR = "/api/review-classifier/open-pr";
|
||||
const SETTINGS = "/api/review-classifier/settings";
|
||||
const PULL_REPOS = "/api/pulls/repos";
|
||||
const PULLS = "/api/pulls";
|
||||
// How long the repo field rests before its PRs are fetched, so typing a repo
|
||||
|
|
@ -111,6 +112,9 @@ export function ReviewTryOut() {
|
|||
useState<ProblemDetails | null>(null);
|
||||
const [pulls, setPulls] = useState<OpenPull[]>([]);
|
||||
const [pullsError, setPullsError] = useState<ProblemDetails | null>(null);
|
||||
const [maxClassifications, setMaxClassifications] = useState<number | null>(
|
||||
null,
|
||||
);
|
||||
|
||||
const running = starting || runId !== null;
|
||||
|
||||
|
|
@ -139,6 +143,27 @@ export function ReviewTryOut() {
|
|||
};
|
||||
}, []);
|
||||
|
||||
// How many rows a run takes: the classifier settings', read once. Until it
|
||||
// is known, or when it cannot be read, the run endpoint is the only cap.
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
void (async () => {
|
||||
try {
|
||||
const res = await fetch(SETTINGS);
|
||||
if (cancelled || !res.ok) return;
|
||||
const body = (await res.json()) as { max_classifications?: number };
|
||||
if (!cancelled && typeof body.max_classifications === "number") {
|
||||
setMaxClassifications(body.max_classifications);
|
||||
}
|
||||
} catch {
|
||||
// The endpoint still refuses a run that is too long.
|
||||
}
|
||||
})();
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, []);
|
||||
|
||||
// The open PRs of the repo once it is typed or picked and has stopped
|
||||
// changing. A repo that is not valid yet has no list.
|
||||
useEffect(() => {
|
||||
|
|
@ -224,7 +249,7 @@ export function ReviewTryOut() {
|
|||
|
||||
const openPrProblem = rowsProblem(repo, drafts);
|
||||
const problem = runProblem(repo, pr, drafts);
|
||||
const capProblem = addProblem(drafts.length);
|
||||
const capProblem = addProblem(drafts.length, maxClassifications);
|
||||
|
||||
async function run(e: Event) {
|
||||
e.preventDefault();
|
||||
|
|
|
|||
Loading…
Reference in a new issue