diff options
| author | Pjotr <wrk@bosa.lan> | 2026-11-07 15:06:54 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-11-07 15:06:54 +0000 |
| commit | 4831e5aebb81e7280d017bc57145aa1a7453e661 (patch) | |
| tree | 7db66a392a3c0ca78b30f3c8fb1a7db6070684c4 /docs | |
| parent | bd14783d3f32abecf8d50bfd352e3695363ea5e2 (diff) | |
| download | genenetwork4-4831e5aebb81e7280d017bc57145aa1a7453e661.tar.gz | |
compute: proxy /compute/* for any valid token
R/qtl and GEMMA are part of the service now, so the blanket 403 goes:
the handlers already require an AuthToken, which is the whole gate
("token_only", not resource-checked). What that buys and costs is now
written down rather than implied -- any token holder can name
server-side paths for R and gemma to read, and the public-data-only
restriction on traits/datasets does not apply here at all.
The box also has to be able to run them: PATH must carry Rscript,
gemma-wrapper and gemma, *and* R_LIBS_SITE must point at the profile's
site-library or scripts/rqtl_wrapper.R dies on `there is no package
called 'optparse'` -- which reads like a token or proxy fault and is
neither.
Verified through nginx with a token: POST /gn4/compute/rqtl 200 in 0.4s
with the fixture's marker rows, POST /gn4/compute/gemma 200 in 2.1s with
7 320 marker rows (identical to the documented run's first row),
GET /gn4/compute/gemma/status/<id> ending in "GN4: computation
complete", /compute/correlation 200; all four 401 without a token.
* etc/nginx-vesuvio.pu.ac.ke.conf: drop the /compute 403 locations, keep
them commented as the way back; timeouts/body-size comments now apply.
* docs/www/ai-instruction.md: new §4a, "Running QTL mapping (compute)" --
shapes, server-side paths, ?id= + status polling, what to do with a 504.
* docs/www/operator-checklist.md: compute moves from "must be off" to
"proxied, know what it grants", plus what the box needs (PATH,
R_LIBS_SITE, ravanan) and the measured results.
* docs/nginx.md: same, in the deployment and checking sections.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/nginx.md | 12 | ||||
| -rw-r--r-- | docs/www/ai-instruction.md | 55 | ||||
| -rw-r--r-- | docs/www/operator-checklist.md | 54 |
3 files changed, 102 insertions, 19 deletions
diff --git a/docs/nginx.md b/docs/nginx.md index 414d0e4..0908615 100644 --- a/docs/nginx.md +++ b/docs/nginx.md @@ -139,11 +139,11 @@ set. For the `vesuvio.pu.ac.ke/gn4` deployment as configured, [`etc/nginx-vesuvio.pu.ac.ke.conf`](../etc/nginx-vesuvio.pu.ac.ke.conf) is the same thing as a complete, drop-in file -- TLS, log format, the `/gn4` -redirect, and the `/compute/` and `/get-test-token` refusals. Note that -it refuses `/compute/*`: those endpoints take server-side file paths, so -they belong on the internal listener only (see the operator checklist in -[`docs/www/operator-checklist.md`](www/operator-checklist.md)); drop the two -`location` lines only if every token holder may read the server's files. +redirect, and the `/get-test-token` refusal. `/compute/*` (R/qtl, GEMMA) +is proxied and gated on a valid token, at the cost of letting any token +holder name server-side paths for R and gemma to read — the operator +checklist in [`docs/www/operator-checklist.md`](www/operator-checklist.md) +covers that trade, what the box needs installed, and how to re-block it. `http2 on;` needs nginx >= 1.25.1; on older versions use `listen 443 ssl http2;`. The block above (minus the `ssl_*` lines and the TLS @@ -272,7 +272,7 @@ curl -s $R https://vesuvio.pu.ac.ke/gn4/version # the version envelope curl -s $R -o /dev/null -w '%{http_code}\n' -X POST \ https://vesuvio.pu.ac.ke/gn4/get-test-token # 404: not registered curl -s $R -o /dev/null -w '%{http_code}\n' -X POST \ - https://vesuvio.pu.ac.ke/gn4/compute/correlation # 403: refused here + https://vesuvio.pu.ac.ke/gn4/compute/correlation # 401: proxied, token needed ``` A 502 instead means nginx is fine and genenetwork4 is not listening on diff --git a/docs/www/ai-instruction.md b/docs/www/ai-instruction.md index 6b5a418..e7390d8 100644 --- a/docs/www/ai-instruction.md +++ b/docs/www/ai-instruction.md @@ -233,15 +233,60 @@ answers `403 forbidden`. visible even for datasets whose **values** you may not read. * The search index holds public documents only, so search never reveals private traits — it simply does not return them. -* There are **no write endpoints**. -* Server-side computation is **not exposed**: `POST /compute/*` (GEMMA, - R/qtl, ravanan) runs jobs against the server's own filesystem and is - refused with `403` by the front end. Do not attempt it; the `403` is - the answer, not a permissions problem to work around. +* There are **no write endpoints** — nothing in the API changes data. +* Server-side computation *is* available to any valid token, but it is + not about public data: see §4a. If your task needs private data or server-side computation, stop and ask a human: that needs an account and a grant, not a different URL. +## 4a. Running QTL mapping (compute) + +`POST /gn4/compute/rqtl` (R/qtl scanone) and `POST /gn4/compute/gemma` +(GEMMA, kinship then LOCO GWAS) run **on the server**, against files on +the server's own filesystem. A valid token is the only requirement: they +are not dataset-checked, so nothing about §4 applies — but the paths you +name have to be paths the server can read, which in practice means ones +you were given or ones under the deployment's own data directory. You +cannot upload a genotype file. + +```sh +curl -s -H "$AUTH" -H 'Content-Type: application/json' \ + -X POST "$API/compute/rqtl" -d '{ + "genotype_file": "/path/on/the/server/rqtl_sample1.geno", + "trait_name": "mytrait", + "samples": [{"name": "BXD1", "value": 9.5}, …] + }' +``` + +`/compute/gemma` takes `genotype_file`, `snps_file` and `trait_values` +(one value per sample, `null` for missing), optionally `lmm` +(default 9). `/compute/correlation` is a stub that returns canned data. + +These are **synchronous and slow**: seconds on the fixtures, minutes on +real data, and `/compute/gemma/ravanan` additionally waits on ravanan +(and on a cluster when it is slurm-backed). So: + +* add `?id=<run-id>` to the `POST` (letters, digits, `-`, `_`, 1–64 + characters, unique) and read progress on a second connection with + `GET /compute/….status/<run-id>?peek=<pointer>`; pass the `pointer` + back on each poll. `lines` is empty when nothing is new; unknown run + ids are `404`. A run whose last line is `GN4: computation complete` + has finished; +* do not retry a slow `POST` — a second identical submission starts a + second computation (and `?id=` reuse is a `409`); +* run one job at a time unless you know the box can take more; a GEMMA + run is CPU-bound and minutes long; +* the timeout you see may be the proxy's, not the computation's: if a + `504` arrives, the job may still complete and still be readable + through its status endpoint. + +Responses are the usual envelope; `data` is positional with the column +names in `meta.columns` (`chr`, `rs`, `ps`, … for GEMMA; `name`, `chr`, +`pos`, `lod` for R/qtl), because the rows are many and repeated keys +would dominate. `notes` carries the exact command line that ran, which +is the fastest way to see what your request turned into. + ## 5. Errors and what to do Errors are RFC 7807-style JSON (`type`, `title`, `status`, `code`, diff --git a/docs/www/operator-checklist.md b/docs/www/operator-checklist.md index 629df7b..5a2581b 100644 --- a/docs/www/operator-checklist.md +++ b/docs/www/operator-checklist.md @@ -30,13 +30,17 @@ xapian index XAPIAN_DB_PATH registered), bind to `127.0.0.1`, and the `location = /gn4/get-test-token { return 404; }` refusal in the nginx config. * `POST /compute/*` (`/compute/gemma`, `/compute/gemma/ravanan`, - `/compute/rqtl`, `/compute/correlation`) — these take **server-side - file paths** (`genotype_file`, `snps_file`) and run gemma/ravanan/R on - them; with a token they are an arbitrary-read (and -execution) - surface. They are `token_only`, not resource-checked. The nginx config - answers `403` for `/gn4/compute` and `/gn4/compute/…`; keep that - unless every token holder may read the box's filesystem. Same for - `/compute/*/status/{id}`, which tails run logs by name. + `/compute/rqtl`, `/compute/correlation`) is **now proxied** — R/qtl and + GEMMA are part of the service, gated on a valid token (see "Compute" + below). Understand what that grants: those handlers take **server-side + file paths** (`genotype_file`, `snps_file`) and run R/gemma on them, so + every token holder can ask the box to read its own filesystem. It is + `token_only`, not resource-checked: the public-data-only restriction + that applies to traits and datasets does **not** apply here. The nginx + config comments show how to re-block it + (`location /gn4/compute/ { return 403; }`) if that is no longer + wanted. `/compute/*/status/{id}` tails run logs by name and shares the + same gate. * The auth stub on `:8081` is not a dev leftover — without gn-auth it *is* the auth server — but it must stay reachable from genenetwork4 only: **never** route it publicly. Its signing key @@ -110,6 +114,40 @@ When gn-auth lands, only the source of tokens changes: `--mint-only`, and tokens gain gn-auth's own lifetime (7–14 days, bounded by JWKS rotation) and its per-user grants. +## Compute: what the box needs + +R/qtl and GEMMA run as child processes, so the genenetwork4 process's +environment has to be able to find them. From a plain shell it is not +enough to have the binary in a store path — the R packages matter too. +The deployment shell gives both: + +```sh +P=$(guix shell -D -f guix.scm -- bash -c 'echo $GUIX_ENVIRONMENT') +PATH=$P/bin:$PATH R_LIBS_SITE=$P/site-library/ genenetwork4 …other env… +``` + +- `$P/bin` carries `Rscript`, `gemma-wrapper` and `gemma`; +- `R_LIBS_SITE=$P/site-library/` is what lets `scripts/rqtl_wrapper.R` + load `optparse`, `qtl`, `stringi` and `stringr`. Without it the request + fails with `rqtl_failed` and `there is no package called 'optparse'` + — an environment problem, not a token or proxy problem. + +`/compute/gemma/ravanan` additionally needs `ravanan` and `ccwl` on +`PATH`, and with `RAVANAN_BATCH_SYSTEM=slurm-api` a reachable slurmrestd +(see `docs/ravanan-slurm.md`). + +Verified through the proxy with a token: `POST /gn4/compute/rqtl` +returned 200 in 0.4 s with the fixture's marker rows, `POST +/gn4/compute/gemma` 200 in 2.1 s with 7 320 marker rows, and +`GET /gn4/compute/gemma/status/<id>` ended with `GN4: computation +complete`. Without a token both are `401`. + +Two operational consequences: the nginx `proxy_read_timeout` (3600 s) +must stay generous, since a real mapping takes minutes; and each request +is CPU-bound on the box, so rate-limit per token or keep the audience +small — `limit_req` in the config is one way, but it keys on address, +not token. + ## Data exposure * Public rule: `public > 0 && confidentiality < 1`, or older than five @@ -152,7 +190,7 @@ GET /gn4/search?q=alcohol&limit=3 200 state: complete GET /gn4/datasets/{non-public}/… 403 GET /gn4/species/nope 404 links rewritten to /gn4/… POST /gn4/get-test-token 404 -POST /gn4/compute/correlation 403 +POST /gn4/compute/correlation 200 with a token / 401 without http://…/ 301 -> https://… ``` |
