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
4 changes: 3 additions & 1 deletion app/nullius/standard/proofs/prove.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def __init__(self, bench: dict, ds: dict, work: str, licences=None, options: Opt
self.up = install.upstream(bench)
self.data = install.dataset(bench, ds, self.up)
install.driver_packages(bench) # its driver.install, once: start() then finds it
self.files = {"NULLIUS_FILE_" + n.upper(): install.download(bench["files"][n]["url"], bench["files"][n]["sha256"])
for n in definitions.option_needs(bench, self.options)["files"]} # as a run gives its driver
self.bench, self.ds, self.work = bench, ds, work
self.licences = licences if licences is not None else run.Licences(bench)

Expand All @@ -86,7 +88,7 @@ def start(self, n: int) -> jsonl.Proc:
env = run.base_env(home, {**extra, **credentials, "NULLIUS_UPSTREAM": self.up or "", "NULLIUS_DATASET": self.data or "",
"NULLIUS_DATASET_ID": self.ds["id"], "PYTHONPATH": run.driver_path(), "PYTHONDONTWRITEBYTECODE": "1",
"NULLIUS_VERSION": str(self.bench.get("_version") or ""),
**run.option_env(self.options)})
**run.option_env(self.options), **self.files})
return jsonl.Proc(cmd, self.bench["_here"], env, os.path.join(self.work, f"driver-{n}.log")).start()


Expand Down
14 changes: 13 additions & 1 deletion app/tests/test_standard_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ def setUp(self):
src = f.read()
with open(os.path.join(here, "driver.py"), "w") as f:
f.write(src.replace('return {"units": list(WORDS)}',
'import os\n return {"units": list(WORDS) if os.environ.get("NULLIUS_OPTION_SITES") == "on" else []}'))
'import os\n if os.environ.get("NULLIUS_OPTION_WORDS") == "on" and not os.path.isfile(os.environ.get("NULLIUS_FILE_WORDS", "")):\n return {"units": []}\n'
' return {"units": list(WORDS) if os.environ.get("NULLIUS_OPTION_SITES") == "on" else []}'))
with open(os.path.join(here, "standard.json")) as f:
d = json.load(f)
d["options"] = {"sites": {"summary": "The sites.", "values": ["off", "on"], "default": "off"},
Expand Down Expand Up @@ -465,6 +466,17 @@ def test_the_options_reach_the_units_driver_and_each_controls_run(self):
self.assertEqual(dflt["units"]["problems"], ["units: no ids"])
self.assertEqual(dflt["nop"]["problems"], ["the units check failed: the control was not run"])

def test_the_files_an_option_needs_reach_the_units_driver(self):
words = os.path.join(self.tmp, "words.txt")
open(words, "w").close()
self.b["files"] = {"words": {"url": "https://example.invalid/words.txt", "sha256": "0" * 64}}
self.b["options"]["words"] = {"summary": "Words.", "values": ["off", "on"], "default": "off",
"needs": {"on": {"files": ["words"]}}}
with patch.object(install, "download", return_value=words) as got:
kit = self.prove(bench_options={"sites": "on", "words": "on"}, write=False)["kit"]
self.assertEqual(kit["units"]["units"], 3, kit["units"])
self.assertEqual({c.args for c in got.call_args_list}, {("https://example.invalid/words.txt", "0" * 64)})

def test_a_name_or_a_value_the_benchmark_does_not_allow_is_refused_before_anything_runs(self):
was = json.dumps(self.b.get("proven"))
for given, why in (({"sites": "maybe"}, "'maybe' is not one of off, on"), ({"nope": "x"}, "has no option 'nope'")):
Expand Down