diff options
| author | Pjotr Prins <pjotr.public01@thebird.nl> | 2026-11-15 13:47:21 +0000 |
|---|---|---|
| committer | Pjotr Prins <pjotr.public01@thebird.nl> | 2026-11-15 13:47:21 +0000 |
| commit | 2bfb2187d14e2bec6532633277c642e67c33f56c (patch) | |
| tree | 3ed58816930348282d8c42792d2a40841984f4ba | |
| parent | 9bb67549beb69c294b70210c38ff70a676a261ec (diff) | |
| download | genenetwork4-2bfb2187d14e2bec6532633277c642e67c33f56c.tar.gz | |
monitor: a check may decline to run, and the genotype plot follows the real flow
Two separate faults behind one red line. The check posted `{group, markers: []}`,
which is not this endpoint's request at all -- /plot/genotypes draws the numbers
it is sent (`marker`, `genotypes`, `values`), it looks nothing up -- and the
trait it picked (BXDPublish 10001, LOD 2.93) is *below* the fence that
/peak-genotypes enforces (LOD >= 3), so even a correct payload would earn a
422. So: checks can now build their body from earlier replies (`body` may be a
callable), and can decline with a reason (`Skip`) instead of going red --
calling a deliberately fenced endpoint's 422 a failure trains a reader to
ignore red. The check now walks the documented chain: a published trait whose
LRS is at least 14, its peak-genotypes calls, its values, then the plot.
Full monitor after: 38 ok, 0 failed, 1 skipped, 0 busy.
| -rwxr-xr-x | bin/monitor-gn4 | 76 |
1 files changed, 72 insertions, 4 deletions
diff --git a/bin/monitor-gn4 b/bin/monitor-gn4 index b1a6083..cc86764 100755 --- a/bin/monitor-gn4 +++ b/bin/monitor-gn4 @@ -67,6 +67,15 @@ TIMEOUTS = { OK, FAIL, SKIP, BUSY = "ok", "FAIL", "skip", "busy" +class Skip(Exception): + """A check that cannot be exercised here, and why. + + Not a failure: an endpoint fenced by design (a hit only exists above a LOD + threshold) has nothing to answer on a fixture that has no hit, and calling + that red would train a reader to ignore red. + """ + + class Reply: """One HTTP exchange, reduced to what the report needs.""" @@ -166,8 +175,23 @@ class Check: self.judge = judge self.hint = hint + def body_for(self, client): + """The body to post: a dict, or built from earlier replies. + + A callable is how a check exercises a flow (values + genotypes -> plot) + instead of inventing a payload, and it is where a fixture that cannot + support the check says so with `Skip`. + """ + if callable(self.body): + return self.body(client) + return self.body + def run(self, client): - reply = client.call(self.method, self.path, self.body, self.timeout) + try: + body = self.body_for(client) + except Skip as reason: + return Result(self, None, SKIP, str(reason)) + reply = client.call(self.method, self.path, body, self.timeout) verdict, why = self._judge(reply) return Result(self, reply, verdict, why) @@ -282,6 +306,7 @@ class Discovery: self.trait = self.samples = None self.genotype_version = self.symbol = None self.attribute = self.pmid = self.probeset = self.marker = None + self.plot_trait = self.plot_locus = None self.notes = [] def run(self): @@ -314,6 +339,21 @@ class Discovery: if tid: self.trait = str(tid) break + # The genotype plot is fenced: /peak-genotypes only answers inside a + # confirmed hit (LOD >= 3, i.e. LRS >= 13.8), so a plot check needs a + # trait that has one or it earns an honest 422. Trait 10001 sits at + # LOD 2.93 and is exactly the near-miss that made this look broken. + for trait in traits: + lrs = trait.get("lrs", trait.get("LRS")) + tid = trait.get("id") or trait.get("trait_id") or trait.get("name") + if not tid or not isinstance(lrs, (int, float)) or lrs < 14: + continue + locus = trait.get("locus") or trait.get("Locus") + if not locus: + continue + self.plot_trait = str(tid) + self.plot_locus = str(locus) + break if self.trait: values = self.client.call( "GET", "/traits/%s/%s/values" % (self.publish, self.trait)).json @@ -577,13 +617,41 @@ def build_checks(found, tiers): if "plots" in tiers: add(Check("plot-genotypes", "plots", "POST", "/plot/genotypes", - "python plotter (GENOTYPE_PLOTTER)", - body={"group": found.group, "markers": []}, - expect=200, hint="GENOTYPE_PLOTTER and python3")) + "peak-genotypes + values -> svg (GENOTYPE_PLOTTER)", + body=genotype_plot_body(found), expect=200, + hint="GENOTYPE_PLOTTER and python3")) return checks +def genotype_plot_body(found): + """Build the plot's payload the way a client has to: the two GETs first. + + /plot/genotypes does not look anything up -- it draws the numbers sent to + it -- so the honest check is the flow: peak-genotypes (which re-runs the + R/qtl scan and is fenced) then the trait's values. + """ + def build(client): + if not found.plot_trait or not found.plot_locus: + raise Skip("no published trait with LOD >= 3 to plot a hit for") + calls = client.call( + "GET", "/groups/%s/traits/%s/peak-genotypes?marker=%s" + % (found.group, found.plot_trait, found.plot_locus), timeout=120) + if calls.status != 200: + code, detail = calls.fields() + raise Skip("trait %s at %s is not a confirmed hit: %s %s" + % (found.plot_trait, found.plot_locus, + code or calls.status, str(detail)[:90])) + animals = (calls.json or {}).get("data", {}).get("animals") or [] + values = client.call( + "GET", "/groups/%s/traits/%s/values" + % (found.group, found.plot_trait)) + return {"marker": found.plot_locus, + "genotypes": animals, + "values": (values.json or {}).get("data") or []} + return build + + def bnw_matrix(): """A tiny deterministic network: four variables, five samples, two edges. |
