battery: the wrong-model null as a CI step of its own (battery.py nullmodel)
The battery job ran the ci tier and the wrong-model null in one step with one exit status, so a red job did not say which of the two failed. battery.py nullmodel runs the null on its own, in a run directory whose report is just that section, and exits 1 when a pair failed; run --no-nullmodel keeps it out of a --tier ci run. The workflow runs `run $SUBSET --no-nullmodel`, then (for a ci-tier run) `nullmodel` as a separate step that runs whatever the first did, and keeps both reports. The ci tier's own rows are unchanged; a plain `run --tier ci` still includes the null as before. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EizBKhTqrAYago9KJG3dA3
This commit is contained in:
1 parent
ee350f1f74
commit
eec8dcee9f
5 files changed
+90
-32
No files matched your search
@@ -7,17 +7,19 @@ name: Validation Battery
|
||||
# /data/battery (scratch, kept reports, PDB/COD caches, the full-run lock) read-write. The site
|
||||
# config below names only the open and inhouse arms; the private arm is never run here.
|
||||
#
|
||||
# A ci-tier run also runs the wrong-model null (tools/battery/nullmodel.json: five sets, each without
|
||||
# --model and with five wrong models - other open-arm entries' deposited coordinates, from the PDB
|
||||
# cache under /data/battery - 30 more rugnux runs, about 6 minutes); its pass/fail table is a section of
|
||||
# report.md of its own and leaves the ci-tier rows untouched.
|
||||
# A ci-tier run is followed by the wrong-model null, as a step of its own with its own pass/fail
|
||||
# (battery.py nullmodel; tools/battery/nullmodel.json: five sets, each without --model and with five
|
||||
# wrong models - other open-arm entries' deposited coordinates, from the PDB cache under
|
||||
# /data/battery - 30 more rugnux runs, about 6 minutes), in a run directory and report of its own, so
|
||||
# the ci-tier rows are those of a run without it.
|
||||
#
|
||||
# The job fails when a ci-tier set fails on lattice or space group, crashes or has no input - in any
|
||||
# run that includes those sets, so a manual full run fails on them too - or when a wrong-model pair
|
||||
# fails (the data or a decision moved, or the wrong model was not recognised as wrong). Every other failure and every
|
||||
# metric is reported, not judged: read the table at the end of the battery step and the report.
|
||||
# Only each run's report.md and battery.log are kept: report.md in /data/battery/ci_reports, both as
|
||||
# the job's artifact; the run directory itself is scratch.
|
||||
# The battery step fails when a ci-tier set fails on lattice or space group, crashes or has no input -
|
||||
# in any run that includes those sets, so a manual full run fails on them too. The wrong-model step
|
||||
# fails when a pair fails (the data or a decision moved, or the wrong model was not recognised as
|
||||
# wrong). Each step runs whatever the other did, so the job page says which of the two failed. Every
|
||||
# other failure and every metric is reported, not judged: read the table at the end of each step and
|
||||
# the reports. Only each run's report.md and log are kept: report.md in /data/battery/ci_reports,
|
||||
# both as the job's artifact; the run directories themselves are scratch.
|
||||
#
|
||||
# Runner side (/opt/gitea/config.yaml on that machine, then restart the runner):
|
||||
# runner.labels: + "jfjoch_battery:docker://gitea.psi.ch/leonarski_f/jfjoch_rocky8:2609"
|
||||
@@ -70,6 +72,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Build rugnux
|
||||
id: build
|
||||
shell: bash
|
||||
run: |
|
||||
rm -rf build && mkdir build && cd build
|
||||
@@ -109,24 +112,37 @@ jobs:
|
||||
run: |
|
||||
set -o pipefail
|
||||
# ends with one line per set (rugnux / reference, a tick or cross on the space group);
|
||||
# exits non-zero when a ci-tier set failed
|
||||
# exits non-zero when a ci-tier set failed. The wrong-model null is the next step.
|
||||
JFJOCH_BATTERY_SITE=/tmp/site.json /tmp/bvenv/bin/python tools/battery/battery.py run \
|
||||
--rugnux build/rugnux/rugnux --build-dir build --label "$LABEL" \
|
||||
--rugnux build/rugnux/rugnux --build-dir build --label "$LABEL" --no-nullmodel \
|
||||
$SUBSET 2>&1 | tee battery.log
|
||||
- name: Wrong-model null
|
||||
if: ${{ !cancelled() && steps.build.outcome == 'success' && contains(env.SUBSET, '--tier ci') }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -o pipefail
|
||||
# one line per pair; exits non-zero when a pair failed
|
||||
JFJOCH_BATTERY_SITE=/tmp/site.json /tmp/bvenv/bin/python tools/battery/battery.py nullmodel \
|
||||
--rugnux build/rugnux/rugnux --build-dir build --label "$LABEL-null" 2>&1 | tee nullmodel.log
|
||||
- name: Keep the report
|
||||
if: always()
|
||||
shell: bash
|
||||
run: |
|
||||
run=$(sed -n 's/^run directory //p' battery.log | head -1)
|
||||
[ -n "$run" ] && [ -f "$run/report.md" ] || { echo "no report"; exit 1; }
|
||||
mkdir -p battery_out /data/battery/ci_reports
|
||||
cp "$run/report.md" "battery_out/$(basename "$run").md"
|
||||
cp battery.log "battery_out/$(basename "$run").log"
|
||||
cp "$run/report.md" "/data/battery/ci_reports/$(basename "$run").md"
|
||||
# the report's own per-arm summary and failures, into the job log
|
||||
awk '/^## Summary/{p=1} /^### By population/{p=0} p' "$run/report.md"
|
||||
awk '/^### Failures/{p=1;print;next} /^### /{p=0} p' "$run/report.md"
|
||||
awk '/^## Wrong-model null/{p=1} /^## Summary/{p=0} p' "$run/report.md"
|
||||
missing=0
|
||||
for log in battery.log nullmodel.log; do
|
||||
[ -f "$log" ] || continue
|
||||
run=$(sed -n 's/^run directory //p' "$log" | head -1)
|
||||
[ -n "$run" ] && [ -f "$run/report.md" ] || { echo "no report for $log"; missing=1; continue; }
|
||||
cp "$run/report.md" "battery_out/$(basename "$run").md"
|
||||
cp "$log" "battery_out/$(basename "$run").log"
|
||||
cp "$run/report.md" "/data/battery/ci_reports/$(basename "$run").md"
|
||||
# the report's own per-arm summary and failures, or the wrong-model table, into the job log
|
||||
awk '/^## Summary/{p=1} /^### By population/{p=0} p' "$run/report.md"
|
||||
awk '/^### Failures/{p=1;print;next} /^### /{p=0} p' "$run/report.md"
|
||||
awk '/^## Wrong-model null/{p=1} /^## Summary/{p=0} p' "$run/report.md"
|
||||
done
|
||||
exit $missing
|
||||
- name: Upload report
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
|
||||
+10
-5
@@ -245,6 +245,7 @@ R=build/rugnux/rugnux
|
||||
$B run --rugnux $R # full battery: open + inhouse
|
||||
$B run --rugnux $R --tier smoke # 21 sets covering readers, symmetry, known hard cases
|
||||
$B run --rugnux $R --tier ci # 26 sets every recent release passed (CI, below), plus the wrong-model null
|
||||
$B nullmodel --rugnux $R # the wrong-model null on its own (CI's second step)
|
||||
$B run --rugnux $R --only 5reo,lyso_ref # named sets
|
||||
$B run --rugnux $R --arm private # the private arm, on its own
|
||||
```
|
||||
@@ -297,13 +298,14 @@ run's crash shows as one too.
|
||||
a ci-tier set in the run failed - a wrong lattice or space group, a timeout or a missing input - or
|
||||
when a pair of the wrong-model null (below) failed, and names those sets. This holds in any run that includes them (`--tier ci`, a full run, `--only` naming
|
||||
one), so a red CI job means the same thing whichever run it started. Nothing else fails a run: other
|
||||
sets' failures and every metric are reported, not judged.
|
||||
sets' failures and every metric are reported, not judged. CI runs the two as separate steps -
|
||||
`run --tier ci --no-nullmodel`, then `nullmodel` - so the job page shows which of them failed.
|
||||
|
||||
### The wrong-model null (with every ci-tier run)
|
||||
|
||||
`--model` must not change the processing, and a model that does not belong to the crystal must be
|
||||
recognised as not belonging. Every `--tier ci` run (and any run given `--nullmodel`) therefore also
|
||||
runs the sets of `nullmodel.json` once without `--model` and once with each of five WRONG models,
|
||||
recognised as not belonging. Every `--tier ci` run (and any run given `--nullmodel`; not one given
|
||||
`--no-nullmodel`) therefore also runs the sets of `nullmodel.json` once without `--model` and once with each of five WRONG models,
|
||||
and scores every wrong-model run against the no-model run of the same set (`nullmodel.py`):
|
||||
|
||||
- **(a) data**: `p.hkl` byte for byte; the `p.mtz` reflections value for value (space group, cell,
|
||||
@@ -315,7 +317,8 @@ and scores every wrong-model run against the no-model run of the same set (`null
|
||||
- **(c) a proper null**: `MODEL_FIT` is not `ACCEPTED` (`REJECTED`: the fit is no better than the same
|
||||
model in random orientations; `NOT_TESTED`: the model claimed no hand, indexing or setting, so no
|
||||
null was needed), `MODEL_DECISIONS_TAKEN` is `NONE` with no enantiomorph adopted,
|
||||
`CC_MODEL_CONFIRMED_TO_D_MIN` is `NONE`, and `R_FREE` sits where a random structure's does -
|
||||
`CC_MODEL_CONFIRMED_TO_D_MIN` is `NONE` (measured against its empirical null, see
|
||||
docs/RUGNUX_REPORT.md), and `R_FREE` sits where a random structure's does -
|
||||
0.586 for acentric reflections, 0.828 for centric (Wilson 1950); the scale, anisotropic B, bulk
|
||||
solvent and rigid body fitted on the working set can take only a few points off that, so the
|
||||
test is `R_FREE >= 0.50`.
|
||||
@@ -337,7 +340,9 @@ every model's size, identity, Q-score and reason. 9jq9 is NOT usable as a wrong
|
||||
is the same protein.
|
||||
|
||||
The pairs go to `nullmodel_results.json` in the run directory and to a **Wrong-model null** section
|
||||
at the top of the report; the sets' own rows in `results.json` are those of the run without it. It
|
||||
at the top of the report; the sets' own rows in `results.json` are those of the run without it.
|
||||
`battery.py nullmodel` runs the step alone, in a run directory of its own whose report is that section,
|
||||
and exits with status 1 when a pair failed. It
|
||||
adds 30 rugnux runs, about 6 minutes of rugnux on the RTX 5080 (measured: 6.1 min of WALL_TIME).
|
||||
|
||||
### Stress: hunting crashes that do not reproduce
|
||||
|
||||
@@ -13,8 +13,12 @@ Arms and where their truth comes from:
|
||||
Usage (README.md in this directory is the full guide):
|
||||
battery.py run --rugnux BIN [--label L] [--arm open,inhouse|private] [--only a,b | --tier smoke|ci]
|
||||
[--build-dir DIR] [--gpulock] [--threads N]
|
||||
[--model-check] [--nullmodel] [--baseline RUN|none]
|
||||
[--model-check] [--nullmodel | --no-nullmodel] [--baseline RUN|none]
|
||||
--tier ci also runs the wrong-model null (nullmodel.py)
|
||||
battery.py nullmodel --rugnux BIN [--label L] [--build-dir DIR] [--gpulock] [--threads N]
|
||||
the wrong-model null on its own, in a run directory of
|
||||
its own: exit 1 if a pair failed (CI runs it as its own
|
||||
step, after run --tier ci --no-nullmodel)
|
||||
battery.py stress --rugnux BIN (--only a,b | --tier T) [--repeat N] [--concurrent K]
|
||||
[--sanitizer memcheck|racecheck|synccheck|initcheck] [--launch-blocking]
|
||||
crash hunt: exit 1 if any run crashed
|
||||
@@ -578,6 +582,7 @@ def run_sets(site, sets, arms, binary_src, build_dir, label, opts, subset, basel
|
||||
print(f"run directory {run_dir}", flush=True)
|
||||
|
||||
results = []
|
||||
write_json(os.path.join(run_dir, "results.json"), results)
|
||||
# a kill by SIGTERM is recorded like Ctrl-C: the run directory then says it was aborted
|
||||
signal.signal(signal.SIGTERM, interrupted)
|
||||
try:
|
||||
@@ -643,7 +648,7 @@ def cmd_run(a, site):
|
||||
"gpulock": site["gpulock"] if a.gpulock else None, "extra_args": a.extra.split(),
|
||||
"runs_root": a.runs_root or site["runs_root"],
|
||||
# the wrong-model null rides along with every ci-tier run (and any run that asks for it)
|
||||
"nullmodel": (a.tier == "ci" or a.nullmodel) and "open" in arms}
|
||||
"nullmodel": (a.tier == "ci" or a.nullmodel) and not a.no_nullmodel and "open" in arms}
|
||||
if a.gpulock and not site.get("gpulock"):
|
||||
sys.exit("--gpulock: the site config names no gpulock")
|
||||
run_dir = run_sets(site, sets, arms, a.rugnux, a.build_dir, a.label, opts, subset,
|
||||
@@ -667,6 +672,25 @@ def cmd_run(a, site):
|
||||
if null_bad else [])))
|
||||
|
||||
|
||||
def cmd_nullmodel(a, site):
|
||||
"""The wrong-model null on its own: a run directory with no sets of its own and only
|
||||
nullmodel_results.json, its report holding just that section. Exits 1 when a pair failed."""
|
||||
opts = {"threads": a.threads, "timeout": a.timeout, "model_check": False,
|
||||
"pdb_cache": site.get("pdb_cache") or model_check.DEFAULT_CACHE,
|
||||
"cod_cache": site.get("cod_cache") or shelx_check.DEFAULT_CACHE, "shelxl": None,
|
||||
"gpulock": site["gpulock"] if a.gpulock else None, "extra_args": [],
|
||||
"runs_root": a.runs_root or site["runs_root"], "nullmodel": True}
|
||||
if a.gpulock and not site.get("gpulock"):
|
||||
sys.exit("--gpulock: the site config names no gpulock")
|
||||
run_dir = run_sets(site, [], ["open"], a.rugnux, a.build_dir, a.label, opts, "wrong-model null", None)
|
||||
rows = json.load(open(os.path.join(run_dir, "nullmodel_results.json")))
|
||||
bad = [r for r in rows if r["verdict"] != "pass"]
|
||||
print(f"\nwrong-model null: {len(rows) - len(bad)} of {len(rows)} pairs pass", flush=True)
|
||||
if bad:
|
||||
sys.exit(f"wrong-model null: {len(bad)} pair(s) failed: " +
|
||||
", ".join(f"{r['set']} --model {r['model']} ({r['reason']})" for r in bad))
|
||||
|
||||
|
||||
def stress_one(stress_dir, binary, e, i, opts):
|
||||
"""One stress job: set e, repetition i. Returns its line of stress.json."""
|
||||
wd = os.path.join(stress_dir, "work", e["arm"], e["id"], str(i))
|
||||
@@ -1004,11 +1028,22 @@ def main():
|
||||
"REFMAC (model_check.py; needs CCP4)")
|
||||
r.add_argument("--extra", default="", help="extra rugnux arguments, applied to every set")
|
||||
r.add_argument("--nullmodel", action="store_true",
|
||||
help="also run the wrong-model null (nullmodel.json; always on with --tier ci)")
|
||||
help="also run the wrong-model null (nullmodel.json; on by default with --tier ci)")
|
||||
r.add_argument("--no-nullmodel", action="store_true",
|
||||
help="not even with --tier ci (CI runs it as its own step: battery.py nullmodel)")
|
||||
r.add_argument("--baseline", help="earlier run directory to report the delta against (default: "
|
||||
"the site's persisted baseline; 'none' for no delta)")
|
||||
r.add_argument("--runs-root")
|
||||
|
||||
nm = sub.add_parser("nullmodel", help="the wrong-model null on its own; fail on any failed pair")
|
||||
nm.add_argument("--rugnux", required=True)
|
||||
nm.add_argument("--label", help="short name, part of the run directory's name")
|
||||
nm.add_argument("--build-dir", help="build tree whose CMakeCache.txt records the flags")
|
||||
nm.add_argument("--gpulock", action="store_true", help="queue each rugnux behind the site's GPU lock")
|
||||
nm.add_argument("--threads", type=int, default=0, help="-N for rugnux (default: its own choice)")
|
||||
nm.add_argument("--timeout", type=int, default=10800, help="per rugnux run, in s")
|
||||
nm.add_argument("--runs-root")
|
||||
|
||||
st = sub.add_parser("stress", help="run sets repeatedly / side by side / under compute-sanitizer; "
|
||||
"fail on any crash")
|
||||
st.add_argument("--rugnux", required=True)
|
||||
@@ -1081,7 +1116,7 @@ def main():
|
||||
report.SHELXL = shelx_check.find_shelxl(site.get("shelxl"))
|
||||
report.MANIFESTS = {arm: {e["id"]: e for e in load_sets(site, arm)}
|
||||
for arm, cfg in site["arms"].items() if os.path.exists(cfg["manifest"])}
|
||||
{"run": cmd_run, "stress": cmd_stress, "list": cmd_list, "compare": cmd_compare, "table": cmd_table, "report": cmd_report,
|
||||
{"run": cmd_run, "nullmodel": cmd_nullmodel, "stress": cmd_stress, "list": cmd_list, "compare": cmd_compare, "table": cmd_table, "report": cmd_report,
|
||||
"abort": cmd_abort, "recheck": cmd_recheck, "discover": cmd_discover, "refs": cmd_refs, "remap": cmd_remap}[a.cmd](a, site)
|
||||
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ wrong-model run with the no-model run of the same set:
|
||||
SOHNCKE group and SPACE_GROUP_ENANTIOMORPH, cell, resolution cut, twinning,
|
||||
warnings, ...), provenance lines aside
|
||||
(c) null the model is recognised as wrong: MODEL_FIT is not ACCEPTED, MODEL_DECISIONS_TAKEN is
|
||||
NONE, no enantiomorph adopted, CC_MODEL_CONFIRMED_TO_D_MIN is NONE (the report says a
|
||||
model cannot agree by accident with measurements it was never fitted to), and R_FREE
|
||||
NONE, no enantiomorph adopted, CC_MODEL_CONFIRMED_TO_D_MIN is NONE (no shell's
|
||||
CC(model, data) clears its empirical null), and R_FREE
|
||||
is where a random structure's is: 0.586 for acentric reflections, 0.828 for centric
|
||||
(Wilson 1950); the scale, anisotropic B, bulk solvent and rigid body fitted to the
|
||||
working set can only pull it a few points below that, so R_FREE >= RANDOM_R_FREE_MIN.
|
||||
|
||||
@@ -408,6 +408,8 @@ def build(run_dir, baseline=None, allow_incomplete=False):
|
||||
null_path = os.path.join(run_dir, "nullmodel_results.json")
|
||||
if os.path.exists(null_path):
|
||||
nullmodel.section(doc, json.load(open(null_path)))
|
||||
if not res: # the wrong-model null on its own (battery.py nullmodel): that section is the report
|
||||
return doc
|
||||
|
||||
doc.h(2, "Summary")
|
||||
head = ["arm", "sets", "pass", "of which alt", "fail", "crash", "unscored", "not run", "pass rate",
|
||||
|
||||
Reference in new issue
Block a user