Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions app/static/builder/command-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@
return saved.length ? saved.map(s => `<div class="nb-savedrow"><span><strong>${esc(s.name)}</strong><small>${esc(s.recipe.harness)} · ${esc(new Date(s.saved).toLocaleDateString())}${state(s.recipe)}</small></span>`
+ `<div>${button('Load', `data-load="${esc(s.id)}"`)} ${button('Delete', del(s.id))}</div></div>`).join('') : '<p class="nb-note">No saved recipes.</p>';
}
if (typeof module === 'object' && module.exports) { module.exports = {servedRows, recipeStore, savedList}; return; }
// The Prerequisites head: a status only beside a Run the machines alone hold; a held or absent Run says why itself.
function prereqHead(out, busy, run) {
if (busy) return '<span class="nb-note">checking…</span>';
if (!out || !run || run.hasAttribute('data-held')) return '';
return out.ready ? '<span class="nb-note nb-ok">Ready</span>' : '<span class="nb-note nb-error">Missing something: Run waits</span>';
}
if (typeof module === 'object' && module.exports) { module.exports = {servedRows, recipeStore, savedList, prereqHead}; return; }
const root = document.getElementById('nullius-builder');
if (!root) return;
const schema = JSON.parse(document.getElementById('nb-schema').textContent);
Expand Down Expand Up @@ -1020,10 +1026,10 @@
if(blocked)return `<div class="nb-runbox" id="nb-runbox"><div class="nb-runline">${button('▶ Run on '+esc(where),'id="nb-run" disabled data-held title="'+esc(blocked)+'"','nb-button nb-primary')}</div><p class="nb-note nb-error">${esc(blocked)} ${button('Model step','data-step="'+S.model+'"','nb-inlinebutton')} · ${button('Settings','data-href="/settings#'+C.needsOf(C.choiceOf(rec))+'"','nb-inlinebutton')}</p></div>`;
if(C.isStandard(rec)){
const out=runnerOut||{errors:[{message:'Compiling the recipe…'}]}, noun=C.isStandard(rec)?unitsOf(rec).noun:'item';
return `<div class="nb-runbox" id="nb-runbox">${(out.errors||[]).length?out.errors.map(e=>`<p class="nb-note">${esc(e.message)}</p>`).join(''):`<div class="nb-runline">${button('▶ Run on '+esc(where),'id="nb-run"','nb-button nb-primary')}<span id="nb-runstate" class="nb-note"></span></div>`+(out.confirm?`<p class="nb-note nb-nolimit">No ${esc(noun)} limit: ${esc(out.confirm.replace(/^Run /,'').replace(/\?$/,''))}. Run asks before it starts.</p>`:'')}</div>`;
return `<div class="nb-runbox" id="nb-runbox">${(out.errors||[]).length?(runnerOut?[]:out.errors).map(e=>`<p class="nb-note">${esc(e.message)}</p>`).join(''):`<div class="nb-runline">${button('▶ Run on '+esc(where),'id="nb-run"','nb-button nb-primary')}<span id="nb-runstate" class="nb-note"></span></div>`+(out.confirm?`<p class="nb-note nb-nolimit">No ${esc(noun)} limit: ${esc(out.confirm.replace(/^Run /,'').replace(/\?$/,''))}. Run asks before it starts.</p>`:'')}</div>`;
}
const plan=C.runnable(rec);
return `<div class="nb-runbox" id="nb-runbox">${plan.errors.length?plan.errors.map(e=>`<p class="nb-note">${esc(e)}</p>`).join(''):`<div class="nb-runline">${button('▶ Run on '+esc(where),'id="nb-run"'+(C.validate(rec).errors.length?' disabled data-held':''),'nb-button nb-primary')}<span id="nb-runstate" class="nb-note"></span></div>`+(plan.confirm?`<p class="nb-note nb-nolimit">No task limit: ${esc(plan.confirm.replace(/^Run /,'').replace(/\?$/,''))}. Run asks before it starts.</p>`:'')}</div>`;
const plan=C.runnable(rec), listed=C.compile(rec).errors.map(e=>e.message); // the red box's, not said twice
return `<div class="nb-runbox" id="nb-runbox">${plan.errors.length?plan.errors.filter(e=>!listed.includes(e)).map(e=>`<p class="nb-note">${esc(e)}</p>`).join(''):`<div class="nb-runline">${button('▶ Run on '+esc(where),'id="nb-run"'+(C.validate(rec).errors.length?' disabled data-held':''),'nb-button nb-primary')}<span id="nb-runstate" class="nb-note"></span></div>`+(plan.confirm?`<p class="nb-note nb-nolimit">No task limit: ${esc(plan.confirm.replace(/^Run /,'').replace(/\?$/,''))}. Run asks before it starts.</p>`:'')}</div>`;
};
// Prerequisites: what the recipe needs of each machine it runs on, asked when Review opens and on Check again
// (/new-run/prerequisites, nullius/prerequisites.py). Run waits until every row is ready; the run asks again as it starts.
Expand All @@ -1044,7 +1050,7 @@
const el=$('#nb-prereq'); if(!el)return;
const out=prereq.out, mark={ok:'✓',missing:'✕',install:'↓'};
const rows=m=>m.rows.map(x=>`<li class="nb-prereq-${x.state}"><span class="nb-prereq-mark" aria-hidden="true">${mark[x.state]}</span><span><strong>${esc(x.label)}</strong>${x.detail?` <small>${esc(x.detail)}</small>`:''}${x.state==='missing'&&x.install.length?`<code class="nb-prereq-fix">${x.install.map(esc).join('<br>')}</code>`:''}</span></li>`).join('');
const head=prereq.busy?'<span class="nb-note">checking…</span>':out&&out.ready?'<span class="nb-note nb-ok">Ready</span>':out?'<span class="nb-note nb-error">Missing something: Run waits</span>':'';
const head=prereqHead(out,prereq.busy,$('#nb-run'));
el.innerHTML=`<div class="nb-prereq-head"><h3>Prerequisites</h3>${head}${button('Check again','id="nb-prereq-again"'+(prereq.busy?' disabled':''),'nb-inlinebutton')}</div>`
+(out?(out.errors||[]).map(e=>`<p class="nb-note nb-error">${esc(e)}</p>`).join('')+(out.notes||[]).map(n=>`<p class="nb-notice">${esc(n)}</p>`).join('')
+out.machines.map(m=>`<div class="nb-prereq-machine">${out.machines.length>1?`<small>${esc(m.label)}</small>`:''}<ul>${rows(m)}</ul></div>`).join(''):'');
Expand Down
24 changes: 24 additions & 0 deletions app/ui_tests/test_command_builder_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,30 @@ def test_validation_knows_the_providers(self):
self.assertEqual([e for e in errs('r.provider="openrouter";r.urlEnv="API_URL"') if 'provider/model' in e], [])


class ReviewSaysEachThingOnce(CompilerCase):
"""Review lists a recipe's errors once, in its red box, and Prerequisites says Ready or Missing only beside a Run
that the machines alone hold: a Run held for a key or absent for errors says why itself."""

def test_the_prerequisites_head_speaks_only_beside_a_run_the_machines_hold(self):
out = self.js('const {prereqHead}=require(' + json.dumps(str(APP / 'static/builder/command-builder.js')) + ');'
'const run=held=>({hasAttribute:a=>a==="data-held"&&held}),ok={ready:true,machines:[{rows:[]}]},no={ready:false,machines:[{rows:[]}]};'
'process.stdout.write(JSON.stringify([prereqHead(ok,false,run(false)),prereqHead(no,false,run(false)),prereqHead(ok,false,run(true)),'
'prereqHead(no,false,run(true)),prereqHead({ready:false,machines:[],errors:[]},false,null),prereqHead(null,true,run(false)),prereqHead(null,false,run(false))]));')
self.assertIn('>Ready<', out[0]) # a key and a valid recipe: as before
self.assertIn('Missing something: Run waits', out[1])
self.assertEqual(out[2:5], ['', '', '']) # held for a key; no Run, the recipe has errors
self.assertIn('checking', out[5])
self.assertEqual(out[6], '')

def test_a_pinned_harbor_recipe_with_errors_leaves_them_to_the_red_box(self):
"""The Run box drops what C.compile lists (the red box): a pinned Harbor recipe's errors are all of those."""
out = self.js('const r=C.create("harbor");' + PIN + 'r.agents=[];r.tasks="-2";'
'const listed=C.compile(r).errors.map(e=>e.message),plan=C.runnable(r).errors;'
'process.stdout.write(JSON.stringify([listed.length,plan.length,plan.filter(e=>!listed.includes(e))]));')
self.assertTrue(out[0] and out[1], out)
self.assertEqual(out[2], [])


class ProviderFromSettings(CompilerCase):
"""The provider follows the keys set in Settings: a new recipe starts on
the first one set (OpenRouter, OpenAI, then a local endpoint, which its
Expand Down
8 changes: 8 additions & 0 deletions app/ui_tests/test_prerequisites_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ def test_a_standard_recipe_on_local_processes_needs_no_docker(self):
j = self.post("/new-run/prerequisites", {"recipe": rec}).get_json()
self.assertEqual((j["ready"], j["machines"][0]["rows"]), (True, []))

def test_a_recipe_with_errors_asks_no_machine_and_repeats_none_of_them(self):
"""The recipe's own errors are listed once on Review, by the page; Prerequisites asks no machine and says none."""
rec = {"version": 1, "harness": "standard", "name": "s", "title": "s", "benchmark": "gsm8k", "datasets": ["platinum"],
"others": ["original"], "provider": "openai", "model": "gpt-5-mini", "limit": -3, "where": "local"}
with patch.object(prerequisites, "check_here", lambda *a, **k: self.fail("machine asked")):
j = self.post("/new-run/prerequisites", {"recipe": rec}).get_json()
self.assertEqual((j["machines"], j["ready"], j["errors"]), ([], False, []))

def test_stella_memory_reaches_review_and_the_local_machine_check(self):
rec = {"version": 1, "harness": "standard", "name": "stella", "title": "Stella", "benchmark": "longmemeval",
"datasets": ["longmemeval_s"], "others": ["original"], "provider": "openai", "model": "gpt-4o",
Expand Down
4 changes: 2 additions & 2 deletions app/web/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ def new_run_prerequisites():
standard = recipe.get("harness") == standard_recipe.HARNESS
if standard:
out = standard_recipe.compile(recipe)
if out["errors"]:
return jsonify(machines=[], ready=False, errors=[e["message"] for e in out["errors"]])
if out["errors"]: # the recipe's own, listed once on Review: no machine is asked
return jsonify(machines=[], ready=False, errors=[])
wheres = [sh["where"] for sh in out["shards"]]
needs = (["engine"] if out["docker"] else []) + (list(boat.PROGRAMS) if recipe.get("backend") == "boat" else [])
h = out.get("host") or {}
Expand Down
Loading