diff --git a/app/static/builder/command-builder-core.js b/app/static/builder/command-builder-core.js index cc605a60..554b4986 100644 --- a/app/static/builder/command-builder-core.js +++ b/app/static/builder/command-builder-core.js @@ -827,7 +827,7 @@ // another page and coming back finds the recipe as it was left. Pure halves: // the page owns the storage. A draft does not come back when the page was // opened for something else - a prefill from a run, or a run's own recipe. - const OPENED_FOR = ['run','like','dataset','model','agent','n_tasks','standard','other']; + const OPENED_FOR = ['run','like','saved','dataset','model','agent','n_tasks','standard','other']; function packDraft(state) { return JSON.stringify({version: 1, at: new Date().toISOString(), recipe: state.recipe, step: state.step, steps: STEPS.length, first: 'benchmark', tab: state.tab, saved: state.saved || ''}); } diff --git a/app/static/builder/command-builder.js b/app/static/builder/command-builder.js index 43154614..9efc2e29 100644 --- a/app/static/builder/command-builder.js +++ b/app/static/builder/command-builder.js @@ -113,6 +113,7 @@ let opened = '', savedId = ''; // savedId: the saved recipe this page holds, which a save updates (renames) if (schema.loadRecipe) { try { recipe = C.fromJSON(schema.loadRecipe); step = REVIEW; opened = 'Opened the recipe of run “' + schema.loadRun + '”. Run gives it a new name.'; } catch (e) { opened = 'This run’s recipe cannot be read: ' + e.message; } } else if (schema.loadLike) { const o = C.fromJob(schema.loadLike); recipe = o.recipe; step = REVIEW; opened = o.notes.join(' '); } + else if (schema.loadSaved) { try { recipe = C.fromJSON(schema.loadSaved.recipe); savedId = schema.loadSaved.id; step = REVIEW; opened = 'Loaded “' + schema.loadSaved.name + '”.'; } catch (e) { opened = 'This saved recipe cannot be read: ' + e.message; } } // An unsupported draft opens nothing; its rejection is shown as a toast. else { let d = null; try { d = C.unpackDraft(localStorage.getItem(draftKey), query); } catch {} if (d && d.recipe) { recipe = d.recipe; step = d.step; tab = d.tab; savedId = d.saved; } else if (d && d.gone) opened = d.gone; } const saveDraft = () => { try { localStorage.setItem(draftKey, C.packDraft({recipe, step, tab, saved: savedId})); } catch {} }; diff --git a/app/static/builder/recipes.css b/app/static/builder/recipes.css new file mode 100644 index 00000000..a08e2f55 --- /dev/null +++ b/app/static/builder/recipes.css @@ -0,0 +1,19 @@ +/* The Recipes page: one row per saved recipe; Info and Delete in one dialog (the Launches page's, runs/launches.css). */ +.rcp-head { justify-content: space-between; align-items: center; } +.rcp-name { overflow-wrap: anywhere; } /* a name wraps, never cut */ +.rcp-warn { display: flex; align-items: center; gap: 4px; margin-top: 2px; font-size: 12.5px; color: var(--patch_failed_tests); cursor: help; } +.rcp-warn .ic { width: 14px; height: 14px; } +.rcp-val { display: block; max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* the whole value is its tooltip */ +#recipes td[data-col="name"] { white-space: normal; } +dialog.std-how.launch-delete.wide { width: min(56rem, calc(100vw - 32px)); } +.launch-delete .rcp-problems { list-style: none; padding: 0; margin: 12px 0 0; } +.rcp-problems li { display: flex; gap: 8px; align-items: baseline; padding: 6px 10px; margin-top: 4px; border-radius: 8px; font-size: 13px; + background: color-mix(in srgb, var(--patch_failed_tests) 12%, var(--surface)); } +.rcp-problems .ic { width: 14px; height: 14px; color: var(--patch_failed_tests); align-self: center; } +.rcp-step h3 em { font-style: normal; margin-right: 8px; } +.rcp-row { display: grid; grid-template-columns: minmax(7rem, 12rem) 1fr; gap: 12px; padding: 4px 0; border-top: 1px solid var(--border-soft); } +.rcp-row small { color: var(--text-dim); } +.rcp-row span { overflow-wrap: anywhere; } +.rcp-json { max-height: 22rem; overflow: auto; margin: 4px 0 0; padding: 10px 12px; border: 1px solid var(--border-soft); border-radius: 8px; + background: var(--surface-2); font-size: 12px; line-height: 1.5; } +@media (max-width: 640px) { .rcp-row { grid-template-columns: 1fr; gap: 0; } } diff --git a/app/static/builder/recipes.js b/app/static/builder/recipes.js new file mode 100644 index 00000000..500101db --- /dev/null +++ b/app/static/builder/recipes.js @@ -0,0 +1,102 @@ +/* The Recipes page (templates/builder/recipes.html): each saved recipe step by step, and what the builder's own + check of a loaded recipe says this Nullius cannot run of it - the recipe core's for a Harbor recipe (fromJSON, + validate, providerBlocker), the compile of its Review step for a standard one, done by the server for the page. */ +(function () { + 'use strict'; + const STEPS = ['benchmark', 'runner', 'dataset', 'agent', 'model', 'limits', 'where']; + // {rows: [[step, title, value]], problems: [[step, message]]}; a recipe the core cannot read is its one problem. + function described(C, raw, compiled) { + let r; + const benchmark = typeof raw.benchmark === 'string' ? raw.benchmark : ''; + try { r = C.fromJSON(raw); } catch (e) { return {rows: [], benchmark, problems: [[C.STEP.runner, e.message]]}; } + const out = C.isStandard(r) ? compiled || {review: [], errors: []} : {review: C.review(r), errors: C.validate(r).errors}; + const blocked = C.providerBlocker(r); + return {rows: out.review, benchmark, problems: [...out.errors.map(e => [e.step, e.message]), ...(blocked ? [[C.STEP.model, blocked]] : [])]}; + } + // A step's cell: the values of its review rows, in order; with none (a recipe its check stopped early), the benchmark it names. + const cell = (C, d, key) => d.rows.length ? d.rows.filter(([s]) => s === C.STEP[key]).map(([, , v]) => v).join(' · ') : key === 'benchmark' ? d.benchmark : ''; + const said = (C, problems) => problems.map(([s, m]) => C.STEPS[s] + ': ' + m).join('\n'); + // The first free name of a copy of `name`, among `taken`. + function copyName(name, taken) { + for (let n = 1; ; n++) { const t = name + (n === 1 ? ' (copy)' : ' (copy ' + n + ')'); if (!taken.includes(t)) return t; } + } + if (typeof module === 'object' && module.exports) { module.exports = {described, cell, said, copyName, STEPS}; return; } + + const page = JSON.parse(document.getElementById('rcp-data').textContent), schema = page.schema; + const C = window.NulliusRecipe(schema), byId = Object.fromEntries(page.recipes.map(x => [x.id, x])); + const esc = s => String(s).replace(/[&<>"']/g, c => ({'&': '&', '<': '<', '>': '>', '"': '"', "'": '''})[c]); + const notify = (m, error = false) => window.nulliusNotify(m, {error}); + // A write's notice survives the reload that shows its result. + const KEY = 'nullius.recipes.said'; + const reload = m => { try { sessionStorage.setItem(KEY, m); } catch {} location.reload(); }; + try { const m = sessionStorage.getItem(KEY); sessionStorage.removeItem(KEY); if (m) notify(m); } catch {} + const call = async (url, method, body) => { + const res = await nulliusFetch(url, {method, headers: {'Content-Type': 'application/json', 'X-CSRF-Token': schema.csrf}, body: JSON.stringify(body)}); + const j = await res.json().catch(() => ({})); + if (!res.ok || j.ok === false) throw Error(j.error || 'HTTP ' + res.status); + return j; + }; + + // The cells, before the table toolkit reads the rows (tables.js wires them once the page is read). + const info = {}; + for (const tr of document.querySelectorAll('#recipes tbody tr')) { + const item = byId[tr.dataset.recipe], d = info[item.id] = described(C, item.recipe, page.compiled[item.id]); + for (const key of STEPS) { const span = tr.querySelector(`[data-col="${key}"] .rcp-val`), v = cell(C, d, key); span.textContent = v; span.title = v; } + if (d.problems.length) { const w = tr.querySelector('.rcp-warn'); w.hidden = false; w.title = said(C, d.problems); } + tr.dataset.search = [item.name, ...STEPS.map(k => cell(C, d, k))].join(' '); + } + + const dialog = document.getElementById('rcp-dialog'); + let opener = null; + const show = (html, wide) => { dialog.innerHTML = html; dialog.classList.toggle('wide', wide); dialog.showModal(); }; + dialog.addEventListener('close', () => opener?.focus()); + dialog.addEventListener('click', e => { // the backdrop, not the dialog's own padding + const r = dialog.getBoundingClientRect(); + if (e.target === dialog && (e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom)) dialog.close(); + }); + const head = (t, x) => `

${esc(t)}

${x ? '' : ''}
`; + function details(item) { + const d = info[item.id], shown = STEPS.map(k => C.STEP[k]); + const warn = d.problems.length ? `` : ''; + const steps = shown.map((s, n) => `

0${n + 1}${esc(C.STEPS[s])}

${d.rows.filter(([i]) => i === s).map(([, t, v]) => `
${esc(t)}${esc(v)}
`).join('')}
`).join(''); + show(head(item.name, true) + warn + steps + `

JSON

${esc(JSON.stringify(item.recipe, null, 2))}
`, true); + } + function ask(item) { + show(head('Delete recipe ' + item.name) + `
`, false); + } + function download(item) { + const url = URL.createObjectURL(new Blob([JSON.stringify(item.recipe, null, 2) + '\n'], {type: 'application/json'})), a = document.createElement('a'); + a.href = url; a.download = (item.recipe.name || 'recipe') + '.json'; a.click(); setTimeout(() => URL.revokeObjectURL(url), 1000); + } + document.addEventListener('click', async e => { + const b = e.target.closest('[data-act], [data-close], [data-delete], #rcp-import'); + if (!b || b.getAttribute('aria-disabled') === 'true') return; + const item = byId[b.closest('[data-recipe]')?.dataset.recipe]; + if (b.dataset.close !== undefined) return dialog.close(); + if (b.dataset.act === 'info') { opener = b; return details(item); } + if (b.dataset.act === 'delete') { opener = b; return ask(item); } + if (b.dataset.act === 'export') return download(item); + try { + if (b.dataset.act === 'duplicate') { + const name = copyName(item.name, page.recipes.map(x => x.name)); + await call('/new-run/recipes', 'POST', {recipe: {...item.recipe, title: name}}); + reload('Saved “' + name + '”.'); + } else if (b.dataset.delete) { + await call('/new-run/recipes/' + encodeURIComponent(b.dataset.delete), 'DELETE', {}); + reload('Deleted “' + byId[b.dataset.delete].name + '”.'); + } else if (b.id === 'rcp-import') document.getElementById('rcp-file').click(); + } catch (err) { notify((b.dataset.delete ? 'Not deleted: ' : 'Not saved: ') + err.message, true); } + }); + document.getElementById('rcp-file').addEventListener('change', async e => { + const file = e.target.files[0]; + e.target.value = ''; + if (!file) return; + let body; + try { body = JSON.parse(await file.text()); } catch { return notify('Not imported: ' + file.name + ' is not JSON.', true); } + try { + const j = await call('/new-run/recipes/import', 'POST', body), n = j.added.length; + const skipped = j.skipped.map(x => '“' + x.name + '”'); + reload([n ? 'Imported ' + n + ' recipe' + (n > 1 ? 's' : '') + '.' : '', skipped.length ? 'Already saved: ' + skipped.join(', ') + '.' : ''].filter(Boolean).join(' ')); + } catch (err) { notify(err.message, true); } + }); +})(); diff --git a/app/static/style.css b/app/static/style.css index 0350949b..5e903da3 100644 --- a/app/static/style.css +++ b/app/static/style.css @@ -1248,6 +1248,7 @@ input[type=text].invalid:focus { box-shadow: inset 0 0 0 1px var(--bad); } background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim); border-radius: 8px; padding: .65rem .85rem; font-size: .85rem; margin-bottom: 1rem; } +.page-title + .alert { margin-top: 1rem; } /* the gap the controls row leaves when a table shows */ .alert .mono { color: var(--text); } .alert.error { background: color-mix(in srgb, var(--agent_error) 12%, var(--surface)); diff --git a/app/templates/base.html b/app/templates/base.html index e55e3bbe..f76cacf0 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -55,6 +55,9 @@ + + + @@ -213,6 +216,7 @@ Workspaces Launches + Recipes Settings diff --git a/app/templates/builder/recipes.html b/app/templates/builder/recipes.html new file mode 100644 index 00000000..93f9ab4b --- /dev/null +++ b/app/templates/builder/recipes.html @@ -0,0 +1,48 @@ +{% from '_tables.html' import table, cell, greyed %} +{% extends "base.html" %} +{% block title %}Recipes — Nullius{% endblock %} +{% block crumb %}/ recipes{% endblock %} +{% block head %} +{# its dialog #} + +{% endblock %} +{#- A recipe's row: its step cells and its search are filled by builder/recipes.js. #} +{% macro recipe_tr(x) %} data-recipe="{{ x.id }}"{% endmacro %} + +{% block body %} +{% set local, why = builder_data.local, builder_data.recipesWhy %} +

Recipes

+ +
+ +{% if recipes %} +{#- a column per step of the run builder, 01 to 07, by its key in command-builder-core.js (STEP) #} +{% set cols = [dict(key='name', label='Name', sticky=true, menu=false, width='expand'), dict(key='benchmark', label='Benchmark'), dict(key='runner', label='Runner'), + dict(key='dataset', label='Dataset'), dict(key='agent', label='Agent'), dict(key='model', label='Model'), dict(key='limits', label='Limits'), + dict(key='where', label='Where'), dict(key='saved', label='Saved', type='num', align='left'), dict(key='actions', label='Actions', blank=true)] %} +{% call(x, c) table('recipes', cols, recipes, recipe_tr, search='Search by name, benchmark or agent', columns=true, empty='No recipe matches.', noun='recipes') %} + {%- if c.key == 'name' %}{% call cell(c, sort=x.name) %}{{ x.name }} + {% endcall %} + {%- elif c.key == 'saved' %}{% call cell(c, sort=x.saved[:19]|replace('-', '')|replace(':', '')|replace('T', ''), class='mono faint nowrap') %}{{ x.saved[:16]|replace('T', ' ') }}{% endcall %} + {%- elif c.key == 'actions' %}{% call cell(c, class='acts-col') %} + + + {%- if local %} + {%- else %}{{ greyed('Duplicate ' ~ x.name, 'Duplicate', why, 'dup-' ~ x.id, icon='copy', class='icon-btn') }}{% endif %} + + {%- if local %} + {%- else %}{{ greyed('Delete ' ~ x.name, 'Delete recipe', why, 'del-' ~ x.id) }}{% endif %} + {% endcall %} + {%- else %}{% call cell(c) %}{% endcall %} + {%- endif %} +{% endcall %} +{% else %} +
No saved recipe yet.{% if local %} Build one {% endif %}
+{% endif %} + + +{% endblock %} +{% block scripts %} + + +{% endblock %} diff --git a/app/ui_tests/test_recipes_page.py b/app/ui_tests/test_recipes_page.py new file mode 100644 index 00000000..5749f8c0 --- /dev/null +++ b/app/ui_tests/test_recipes_page.py @@ -0,0 +1,122 @@ +"""The Recipes page (/recipes): the saved recipes as a table, a column per builder step; Import, Duplicate and +Delete greyed for a browser on another machine; Open in the run builder (/new-run?saved=); and, under Node, +the warning its script draws from the builder's own check of each recipe.""" +from __future__ import annotations + +import json +import os +import shutil +import subprocess +import tempfile +import unittest +from contextlib import ExitStack +from pathlib import Path +from unittest.mock import patch + +from nullius.recipes import store +from .test_routes import web + +REMOTE = {"REMOTE_ADDR": "10.0.0.2"} +STATIC = Path(__file__).resolve().parents[1] / "static" / "builder" +STEPS = ["Benchmark", "Runner", "Dataset", "Agent", "Model", "Limits", "Where"] + + +def recipe(title, name="r", **kw): + return dict({"version": 1, "harness": "harbor", "name": name, "title": title}, **kw) + + +class RecipesPage(unittest.TestCase): + def setUp(self): + self.stack = ExitStack(); self.addCleanup(self.stack.close) + self.tmp = tempfile.mkdtemp(prefix="nullius-recipes-"); self.addCleanup(shutil.rmtree, self.tmp, True) + self.stack.enter_context(patch.dict(os.environ, {"NULLIUS_HOME": self.tmp})) + self.stack.enter_context(patch.dict(web.app.config, TESTING=True)) + self.client = web.app.test_client() + + def page(self, **kw): + r = self.client.get("/recipes", **kw); self.addCleanup(r.close) + self.assertEqual(r.status_code, 200) + return r.get_data(as_text=True) + + def test_the_page_has_its_link_a_column_per_step_and_a_row_per_recipe(self): + html = self.page() + self.assertIn('href="/recipes" data-label="Recipes"', html) + self.assertIn('No saved recipe yet. Build one', html) + self.assertIn("No saved recipe yet.", self.page(environ_base=REMOTE)) # it could not save one + self.assertIn('id="rcp-import">", 1)[1].split("<", 1)[0] for h in html.split("")[1].split("")[0].split("')[1].split("")[0]) + self.assertEqual((schema["loadSaved"]["id"], schema["loadSaved"]["recipe"]["agents"]), (item["id"], ["oracle"])) + r = self.client.get("/new-run", query_string={"saved": "0" * 16}); self.addCleanup(r.close) + self.assertEqual(r.status_code, 404) + + +class MissingParts(unittest.TestCase): + """The page's script over the data the page embeds: each recipe's steps and what the builder's check says.""" + + @classmethod + def setUpClass(cls): + cls.node = shutil.which("node") + if not cls.node: + raise unittest.SkipTest("Node is required for the page's script") + + def setUp(self): + self.stack = ExitStack(); self.addCleanup(self.stack.close) + self.tmp = tempfile.mkdtemp(prefix="nullius-recipes-"); self.addCleanup(shutil.rmtree, self.tmp, True) + self.stack.enter_context(patch.dict(os.environ, {"NULLIUS_HOME": self.tmp})) + self.stack.enter_context(patch.dict(web.app.config, TESTING=True)) + + def described(self): + r = web.app.test_client().get("/recipes"); self.addCleanup(r.close) + data = json.loads(r.get_data(as_text=True).split('")[0]) + program = ("const D=" + json.dumps(data) + ";const C=require(" + json.dumps(str(STATIC / "command-builder-core.js")) + ")(D.schema);" + "const P=require(" + json.dumps(str(STATIC / "recipes.js")) + ");const out={};" + "for(const x of D.recipes){const d=P.described(C,x.recipe,D.compiled[x.id]);" + "out[x.name]={cells:P.STEPS.map(k=>P.cell(C,d,k)),said:P.said(C,d.problems)};}" + "out.copy=[P.copyName('a',['a']),P.copyName('a',['a','a (copy)'])];process.stdout.write(JSON.stringify(out));") + return json.loads(subprocess.run([self.node, "-"], input=program, capture_output=True, text=True, check=True).stdout) + + def test_a_recipe_naming_what_this_nullius_lacks_says_so_and_names_it(self): + store.save(recipe("kept", benchmark="swe-bench-verified", agents=["oracle", "nop"])) + store.save(recipe("gone agent", benchmark="swe-bench-verified", agents=["oracle", "no-such-agent"])) + store.save({"version": 1, "harness": "standard", "name": "s", "title": "gone benchmark", "benchmark": "no-such-bench"}) + store.save(recipe("gone runner", harness="weird")) + out = self.described() + self.assertEqual(out["kept"]["cells"][3], "oracle, nop") + self.assertNotIn("Agent:", out["kept"]["said"]) + self.assertIn("Agent: no-such-agent is not an agent this builder offers", out["gone agent"]["said"]) + self.assertTrue(out["gone agent"]["cells"][3].endswith("no-such-agent")) + self.assertIn("Benchmark: Choose a benchmark of the standard.", out["gone benchmark"]["said"]) + self.assertEqual(out["gone benchmark"]["cells"][0], "no-such-bench") + self.assertTrue(out["gone runner"]["said"].startswith("Runner: ")) + self.assertEqual(out["copy"], ["a (copy)", "a (copy 2)"]) + + +if __name__ == "__main__": + unittest.main() diff --git a/app/web/builder.py b/app/web/builder.py index e2b33bfe..e190398f 100644 --- a/app/web/builder.py +++ b/app/web/builder.py @@ -30,6 +30,46 @@ @app.route("/new-run") def new_run(): """Build a Harbor recipe; never execute it from this route.""" + data = _builder_data() + # ?run=: the recipe a run of this application was started from, + # opened as it was. ?like=, the job page's "New run like + # this": that recipe when the run kept one, else what the job recorded - + # its launch, its Harbor and what its trials say ran - for the recipe core + # to rebuild a recipe from (fromJob). ?saved=: a saved recipe, as the + # Saved recipes dialog loads it. Individual query fields also prefill the form. + like = request.args.get("like") + run = request.args.get("run") or (like if like and _kept_recipe(like) else None) + if run: + ex = execution.for_job(run) + if ex is None or not ex.plan.recipe: + abort(404) + data["loadRecipe"] = ex.plan.recipe + data["loadRun"] = run + elif like: + job = shared._find_job(shared._jobs_for_request(), like) + if job is None: + abort(404) + data["loadLike"] = {"job": job.job_id, "agent": job.agent_name, "launch": job.launch, + "harbor": {"version": job.harbor_version, "editable": job.harbor_editable}, + "env": next((t.env_type for t in job.trials if t.env_type), "")} + elif request.args.get("saved"): + data["loadSaved"] = next((x for x in recipe_store.listing() if x["id"] == request.args["saved"]), None) + if data["loadSaved"] is None: + abort(404) + return render_template("builder/new_run.html", builder_data=data) + + +@app.route("/recipes") +def recipes_page(): + """The saved recipes as a table, a column per step. The page checks each one as the builder checks a loaded + recipe: a Harbor one in the recipe core, a standard one by the compile of its Review step, done here.""" + items = recipe_store.listing() + compiled = {x["id"]: _standard_compile(x["recipe"]) for x in items if x["recipe"].get("harness") == standard_recipe.HARNESS} + return render_template("builder/recipes.html", recipes=items, compiled=compiled, builder_data=_builder_data()) + + +def _builder_data() -> dict: + """What the recipe core reads (command-builder-core.js): the vocabulary, this machine and Settings.""" data = command_builder.payload(catalog.load(), shared._load_jobs()) # Execution sets these credential variables from Settings. data["credentialVars"] = {"key": "API_TOKEN", "url": "API_URL"} @@ -62,27 +102,7 @@ def new_run(): data["csrf"] = shared._csrf_token() data["local"] = shared_local_client() data["recipesWhy"] = WRITE_HERE - # ?run=: the recipe a run of this application was started from, - # opened as it was. ?like=, the job page's "New run like - # this": that recipe when the run kept one, else what the job recorded - - # its launch, its Harbor and what its trials say ran - for the recipe core - # to rebuild a recipe from (fromJob). Individual query fields also prefill the form. - like = request.args.get("like") - run = request.args.get("run") or (like if like and _kept_recipe(like) else None) - if run: - ex = execution.for_job(run) - if ex is None or not ex.plan.recipe: - abort(404) - data["loadRecipe"] = ex.plan.recipe - data["loadRun"] = run - elif like: - job = shared._find_job(shared._jobs_for_request(), like) - if job is None: - abort(404) - data["loadLike"] = {"job": job.job_id, "agent": job.agent_name, "launch": job.launch, - "harbor": {"version": job.harbor_version, "editable": job.harbor_editable}, - "env": next((t.env_type for t in job.trials if t.env_type), "")} - return render_template("builder/new_run.html", builder_data=data) + return data @app.route("/new-run/runner", methods=["POST"]) @@ -97,14 +117,18 @@ def new_run_runner(): if len(json.dumps(recipe)) > 200_000: abort(413) if recipe.get("harness") == standard_recipe.HARNESS: - out = standard_recipe.compile(recipe, docker_unusable=execute.docker_problem, boat_unusable=boat.unusable, - boat_size_problem=execute.boat_size_problem, unpriced=execute.unpriced) - # served_models: each model field's model as the run sends it, which Served by lists the providers of - return {k: out[k] for k in ("errors", "notes", "review", "jobs", "confirm", "served_models")} + return _standard_compile(recipe) return {"errors": [{"step": providers.STEP["runner"], "message": providers.GONE}], "notes": [], "review": []}, 404 +def _standard_compile(recipe: dict) -> dict: + out = standard_recipe.compile(recipe, docker_unusable=execute.docker_problem, boat_unusable=boat.unusable, + boat_size_problem=execute.boat_size_problem, unpriced=execute.unpriced) + # served_models: each model field's model as the run sends it, which Served by lists the providers of + return {k: out[k] for k in ("errors", "notes", "review", "jobs", "confirm", "served_models")} + + @app.route("/new-run/prerequisites", methods=["POST"]) def new_run_prerequisites(): """What the recipe needs of each machine it runs on, and whether that diff --git a/docs/builder.md b/docs/builder.md index 1b169e73..834f5cf5 100644 --- a/docs/builder.md +++ b/docs/builder.md @@ -93,6 +93,15 @@ a declared model list keeps those published choices. | A run's recipe | `runs//run.json` | Job page, *New run like this*: the same recipe, at Review | | A job's record | Its `config.json` and `lock.json` | *New run like this* without a kept recipe: rebuilt, what it cannot carry named | +The **Recipes** page (Manage, *Recipes*) lists the saved recipes, a column per +step. Each row opens its recipe in the builder, shows it step by step with its +JSON (*Info*), duplicates it under a free name, exports its JSON or deletes it. +*Import* adds a recipe file, or a list, and refuses the whole file when one +recipe is bad. A row whose recipe names something this Nullius does not have, +such as a benchmark, an agent or a provider without a key, shows *Cannot run +here*. Its tooltip gives the builder's reason for each step. Import, Duplicate +and Delete work only from a browser on the application host. + ## Run ![Run](diagrams/builder-run.svg)