Skip to content
Draft
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
1 change: 1 addition & 0 deletions app/nullius/catalogue/agents/digitalmate/agent.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"label": "DigitalMate",
"company": "ThinkFlowLab",
"summary": "DigitalMate's Personal Agent service, run as Hive Home with its owned WorkSwarm runtimes.",
"backends": ["container"],
"model": {
"apis": [
"chat"
Expand Down
12 changes: 7 additions & 5 deletions app/nullius/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,11 @@ def check(self, recipe: Union[dict, str], where=None) -> dict:
return self.request("POST", "/runs/check", self._run_body(recipe, where))

def start(self, recipe: Union[dict, str], where=None, name: Optional[str] = None, confirm: bool = False,
workspace: Optional[str] = None) -> dict:
"""Start a recipe; ``runs`` holds one run per machine. ``confirm``: the yes to the question ``check`` returns.
``workspace``: the one its jobs go into, made when there is none; the open one stays open."""
return self.request("POST", "/runs", self._run_body(recipe, where, name=name, confirm=confirm, workspace=workspace))
workspace: Optional[str] = None, reviewed: Optional[str] = None) -> dict:
"""Start a recipe; ``runs`` holds one run per machine, or of a suite one per member and participant. ``confirm``: the yes to the question ``check`` returns.
``workspace``: the one its jobs go into, made when there is none; the open one stays open.
``reviewed``: of a suite, the digest ``check`` returned, without which it is refused."""
return self.request("POST", "/runs", self._run_body(recipe, where, name=name, confirm=confirm, workspace=workspace, reviewed=reviewed))

def runs(self) -> list:
return self.request("GET", "/runs")
Expand Down Expand Up @@ -299,6 +300,7 @@ def main(argv=None) -> int:
p.add_argument("--name", help="the run's name (default: the recipe's name and the second)")
p.add_argument("--workspace", help="the workspace its jobs go into, made when there is none (default: the open one)")
p.add_argument("--yes", action="store_true", help="answer yes to the question the check returns")
p.add_argument("--reviewed", metavar="DIGEST", help="of a suite: the digest its check returned")
p.add_argument("--follow", action="store_true", help="print the log until the run ends; exit 4 unless it ends done")
sub.add_parser("runs", help="the runs the server follows")
p = sub.add_parser("status", help="one run: its state, stages and log")
Expand All @@ -316,7 +318,7 @@ def main(argv=None) -> int:
return EXIT_USAGE
try:
if a.cmd == "run":
out = nx.start(_recipe_arg(a.recipe), where=a.where, name=a.name, confirm=a.yes, workspace=a.workspace)
out = nx.start(_recipe_arg(a.recipe), where=a.where, name=a.name, confirm=a.yes, workspace=a.workspace, reviewed=a.reviewed)
if a.follow:
ok = True
for r in out["runs"]:
Expand Down
326 changes: 320 additions & 6 deletions app/nullius/execution.py

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions app/nullius/mcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@
"and the question to confirm.", {**_RECIPE, "where": _S}, ["recipe"],
lambda nx, a: nx.check(a["recipe"], a.get("where"))),
"start_run": ("Start a recipe. It spends model tokens and machine time: call check_run first, and set confirm only "
"when the person has agreed to the question it returned.", {**_RECIPE, "where": _S, "confirm": _B, **_WORKSPACE}, ["recipe"],
lambda nx, a: nx.start(a["recipe"], a.get("where"), confirm=a.get("confirm") is True, workspace=a.get("workspace"))),
"when the person has agreed to the question it returned.", {**_RECIPE, "where": _S, "confirm": _B, "reviewed": _S, **_WORKSPACE}, ["recipe"],
lambda nx, a: nx.start(a["recipe"], a.get("where"), confirm=a.get("confirm") is True, workspace=a.get("workspace"),
reviewed=a.get("reviewed"))),
"list_runs": ("The runs the server follows: state, stages, job ids.", {}, [], lambda nx, a: nx.runs()),
"get_run": ("One run: state, stages, and its log lines from `since` on.", {**_RUN, "since": _I}, ["run_id"],
lambda nx, a: nx.run(a["run_id"], a.get("since") or 0)),
Expand Down
84 changes: 81 additions & 3 deletions app/nullius/standard/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
from nullius.standard.calls import exchanges, relay
from nullius.standard.contract import definitions, match, ports, proofs
from nullius.standard.proofs import conform, fidelity, pins, prove
from nullius.standard.runner import job, merge, rerun, run, sets, shard
from nullius.standard.runner import job, merge, rerun, run, sets, shard, suites
from nullius.standard.runner import units as unit_list

ENV_FILE = paths.settings_file()
Expand Down Expand Up @@ -245,6 +245,13 @@ def cmd_list(a):
print(f" {'':<18} and the skills " + "; ".join(f"{', '.join(s)} of {p}" for p, s in d["needs_skills"].items()))
for note in ([] if kind == "benchmark" else older(d) + skills(d)):
print(f" {'':<18} {note}")
found, bad_suites = suites.load()
bad += bad_suites
if found:
print("suites:")
for s in found:
print(f" {s['ref']:<18} {suites.tasks(s)} tasks of {len({m['benchmark'] for m in s['members']})} benchmarks"
+ (f" · {s['left_out']} without an id left out" if s["left_out"] else ""))
t = match.table(got["benchmark"], got["agent"], got["module"])
print("pairs:")
for b, row in t.items():
Expand Down Expand Up @@ -309,6 +316,27 @@ def cmd_check(a):

@definitions.reading()
def cmd_fit(a):
s = suites.find(a.benchmark)
if s: # a suite: each agent runs every member that takes one, or none (suites.plan)
got = _all()[0]
ids = [m["id"] for m in s["members"]]
wrong = [x for x in a.dataset or () if x not in ids]
if wrong:
print(f"refused: {', '.join(wrong)} is no member of {s['ref']}: {', '.join(ids)}")
return 2
try:
for o in got["agent"]:
p = suites.plan(s, got, [o["_ref"]], chosen=a.dataset or None, backend=definitions.names.backend(a.backend or "local"))
own = [r for r in p["rows"] if not r["setup"]]
no = p["unfit"].get(o["_ref"]) or []
on = sorted({b for r in own for b in r["backend"].values() if b != "local"})
print(f" {'✗' if no else '✓'} {o['_ref']}: " + (f"{len(own) - len(no)} of {len(own)} benchmarks" if no else
"every member" + (f", on the {' and '.join(on)} backend" if on else ""))
+ "".join(f"\n {label}: {why}" for label, why in no))
except suites.Refused as e:
print("refused:", e)
return 2
return 0
b = definitions.get("benchmark", a.benchmark)
if not b:
sys.exit(f"no benchmark {a.benchmark!r}")
Expand Down Expand Up @@ -603,6 +631,10 @@ def _bench(key):


def cmd_run(a):
if suites.find(a.benchmark): # until the command launches through the builder's queue (docs/cli/run.md)
print(f"refused: {a.benchmark} is a suite: run it from the builder (New run), which starts its runs one after the other; "
f"nullius standard fit {a.benchmark} says which agents run it")
return 2
b = _bench(a.benchmark)
task_set, dataset, bench_options = None, a.dataset, options(a.bench_option)
if a.task_set is not None:
Expand All @@ -612,6 +644,33 @@ def cmd_run(a):
except sets.Refused as e:
print("refused:", e)
return 2
if a.set_hash and (task_set or {}).get("hash") != a.set_hash:
print(f"refused: --set-hash: the task set {a.task_set} is not the list this run was reviewed with: launch the suite again")
return 2
suite = suites.marked(a.suite) if a.suite else None
if a.suite:
# the mark is true of this run, or the run is refused: the suite as reviewed, its list, the launch that carries it
s = suite and suites.find(f"{suite['key']}@{suite['version']}")
try:
with open(os.path.join(os.path.dirname(os.path.abspath(a.jobs)), "plan.json"), encoding="utf-8") as fh:
launched = json.load(fh)
said = (launched.get("recipe") or {}).get("suite") or {}
launched = bool(launched.get("queue")) and said.get("mark") == a.suite
# the member, the participant and the options Review showed for this run, against what this command was given
bound = said.get("set_hash") == a.set_hash and said.get("bound") == {"benchmark": a.benchmark, "other": a.other, "model": a.model or "", "dataset": a.dataset,
"limit": a.limit, "backend": a.backend, "max_usd": a.max_usd}
except (OSError, ValueError, AttributeError):
launched = bound = False
why = ("KEY@VERSION:DIGEST:HASH:PIN, as a suite's launch writes it" if not suite else
f"no suite {suite['key']}@{suite['version']} here" if not s else
"the suite changed since Review: review it again" if s["hash"] != suite["hash"] else
f"a suite's run takes its suite's list, --set {suites.set_name(s)} --set-hash" if a.task_set != suites.set_name(s) or not a.set_hash else
"only a suite's own launch marks a run: run the suite from the builder (New run)" if not launched else
"the run is not the one reviewed (its list, member, participant, model, limit, cap or backend differs): review the suite again" if not bound else "")
if why:
print("refused: --suite:", why)
return 2
suite = dict(suite, members=[m["id"] for m in s["members"] if m["benchmark"] == b["key"] and m["dataset"] == dataset])
if a.other in definitions.CONTROLS:
other = definitions.control(b, a.other)
if other is None:
Expand All @@ -635,7 +694,13 @@ def cmd_run(a):
if why:
print("refused: constraints:", why)
return 2
if suite and suites.pin(b, None if a.other in definitions.CONTROLS + definitions.SETUPS else other) != suite["pin"]:
print(f"refused: --suite: {b['label']} or {a.other} is no longer what was reviewed (a version, a pin or a setting changed): review the suite again")
return 2
if a.backend == "boat" and definitions.boots_vms(b):
if suite: # that path plans from the dataset's count, not the list reviewed
print(f"refused: --suite: {b['label']} on Boat runs each task whole in a VM, which takes no selection of tasks yet")
return 2
return _boat_units(a, b, other)
# a cap counts each call at its model's price: the public list fetched first (Settings, Model prices); a machine
# that cannot reach it runs uncapped where a model has no price, and says so (run.Run)
Expand All @@ -654,7 +719,7 @@ def cmd_run(a):
try:
job, failed = run.run_and_report(b, other, model=a.model or "", provider=a.provider, dataset=dataset, limit=a.limit,
concurrency=a.concurrency, jobs_root=a.jobs, name=a.name, unsandboxed=a.unsandboxed, judge_model=a.judge_model, backend=a.backend,
boat_size=a.boat_size, relay_container=a.relay_container, simulator_model=a.simulator_model, options=options(a.option), shard=_shard(a.shard), launch=a.launch,
boat_size=a.boat_size, relay_container=a.relay_container, simulator_model=a.simulator_model, options=options(a.option), shard=_shard(a.shard), launch=a.launch, suite=suite,
shard_by=a.shard_by, licences=held, bench_options=bench_options, repeat=a.repeat, retries=a.retries,
remove_images=a.remove_images,
prices=prices(a.price), max_usd=a.max_usd, max_usd_per_unit=a.max_usd_per_unit, prices_unreachable=unreachable,
Expand Down Expand Up @@ -1555,6 +1620,8 @@ def main(argv=None):
c.add_argument("path", nargs="?")
f = sub.add_parser("fit", help="what can run a benchmark, and why the rest cannot")
f.add_argument("benchmark")
f.add_argument("--dataset", action="append", metavar="MEMBER", help="of a suite: the members taken, as the Dataset step ticks them (default: every member)")
f.add_argument("--backend", help="of a suite: the backend its runs are asked on (default: local)")
p = sub.add_parser("pins", help="compare image pins with registry tags without changing them")
p.add_argument("benchmark")
p.add_argument("--tag", help="tag to compare (default: embedded tag, or latest)")
Expand All @@ -1571,8 +1638,11 @@ def main(argv=None):
p = sub.add_parser(name, help=helps[name])
if name == "run":
p.add_argument("benchmark")
p.add_argument("other", help="an agent or a Module: KEY (its default version) or KEY@VERSION"
# of run, optional to the parser alone: a suite named with nothing after it is told the way to the builder (main)
p.add_argument("other", **({"nargs": "?"} if name == "run" else {}), help="an agent or a Module: KEY (its default version) or KEY@VERSION"
+ ("; or nop, oracle: a control the benchmark declares; or original, model: one of its setups" if name == "run" else ""))
if name == "run":
run_parser = p
p.add_argument("--model", required=name == "conform",
help="the model (a control needs none; original takes one of the paper's, its first by default)" if name == "run" else None)
p.add_argument("--provider", default="openai", choices=sorted(providers.PROVIDERS))
Expand Down Expand Up @@ -1609,6 +1679,12 @@ def main(argv=None):
p.add_argument("--set", dest="task_set", metavar="NAME",
help="only the units of this task set (nullius standard set): its dataset is the run's, the "
"options the run's own; the job's config records the set")
if name == "run":
p.add_argument("--set-hash", metavar="SHA256",
help="with --set: refused unless the set's list has this hash (a suite's run is bound to the list reviewed)")
p.add_argument("--suite", metavar="KEY@VERSION:DIGEST:HASH:PIN",
help="the suite launch this run is one of, written by that launch alone: refused unless the suite, its list, "
"the benchmark and the participant are what was reviewed; the job's config records it")
p.add_argument("--limit", type=int)
p.add_argument("--start-with", metavar="N|FILE|set:NAME|ids:ID,ID...",
help="plan the whole (the dataset, or what --units, --set, --limit name) and start with some of it: "
Expand Down Expand Up @@ -1861,6 +1937,8 @@ def main(argv=None):
for parser in (ap, *sub.choices.values(), *ss.choices.values()):
parser.allow_abbrev = False
a = ap.parse_args(argv)
if a.cmd == "run" and a.other is None and not suites.find(a.benchmark):
run_parser.error("the following arguments are required: other")
if a.cmd == "replay" and not a.list and (a.call is None or a.times is None or a.max_usd is None):
rp.error("--call N, --times K and --max-usd USD go together (or --list)")
if a.cmd == "replay" and a.list and (a.call is not None or a.dry_run):
Expand Down
4 changes: 4 additions & 0 deletions app/nullius/standard/contract/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1943,6 +1943,10 @@ def problems(d: dict, kind: str) -> List[str]:
if only is not None and (not isinstance(only, list) or not only or len(set(map(str, only))) != len(only)
or not all(isinstance(k, str) and _KEY.match(k) for k in only)):
bad.append("only_for: the keys of the benchmarks it is the reference agent of, each once")
only_on = d.get("backends")
if only_on is not None and (not isinstance(only_on, list) or not only_on or len(set(map(str, only_on))) != len(only_on)
or not all(k in names.BACKENDS for k in only_on)):
bad.append(f"backends: the backends it runs on alone, each once, of {', '.join(names.BACKENDS)}")
bad += _proven(d)
bad += _install(d)
bad += _env(d.get("env"))
Expand Down
Loading