about summary refs log tree commit diff
path: root/test/python/test_mapping_methods.py
diff options
context:
space:
mode:
authorPjotr <wrk@bosa.lan>2026-11-10 19:03:50 +0000
committerPjotr <wrk@bosa.lan>2026-11-10 19:03:50 +0000
commitbb3a5454c76d9ad7542f884fb14f89998d978553 (patch)
treec5601c2cf9a0b65b0e68882418a9906b6e2b44b0 /test/python/test_mapping_methods.py
parentfc99de3a5e8dfe2f54ac7e34e7422672baaa97bc (diff)
downloadgenenetwork4-bb3a5454c76d9ad7542f884fb14f89998d978553.tar.gz
baskets: a user's own column of values, in their own SQLite file
The next phase is changing data, and the constraint is that MariaDB is
never written to. A basket is the storage half of that: take a trait's
values, edit some of them (or build a covariate column that does not
exist), keep the column under a name, and map that instead.

  * POST /baskets stores a complete column; GET /baskets lists yours;
    GET /baskets/{name} its metadata; GET /baskets/{name}/values the
    cells; PATCH /baskets/{name} replaces the column with a new revision;
    DELETE removes it.
  * POST /compute/qtl2 takes "basket": "<name>" in place of `samples`,
    and both at once is a 422 rather than a silent choice. The mapping
    code below it is untouched -- a basket resolves to the same
    (name, value) pairs a client would have posted.
  * One SQLite file per user: BASKET_DIR/<sha256(token sub)>.sqlite, 0600,
    WAL, busy_timeout. `GET /baskets` only ever lists the caller's own;
    the file name is a hash, so a directory listing does not name users.
  * The full column is stored, not a diff -- the caller has the original
    beside it, and a mapping needs one complete column.
  * Text with a parsed copy beside it: raw (what was typed), value (the
    number or NULL), status (ok/missing/bad). "NA" and 0 stay different
    claims, and a column with something that is neither a number nor a
    missing marker (NA, x, -, ., ?) is refused with the samples named --
    silently dropping it would change a trait without saying so.
  * A revision and a digest: an edit bumps the revision and changes the
    digest, and a mapping reply records both ("Basket 'wbc-edit'
    revision 2 (digest 9559a70e...)"), so two runs on one name cannot
    look alike. A result cache must key on the digest, not the name.

The loop, end to end on BXD trait 10001: 34 values posted as a basket,
one bumped by 5 and one marked NA, revision 2 mapped with /compute/qtl2
-- 3730 rows, peak chr8 112.9 Mb, and the reply's note naming the
revision and digest.

tests/baskets.rs walks that loop (create, list, values, patch, map by
name, delete) and the refusals: a non-number named in the error, a name
that cannot become a path, an unknown basket, and basket-plus-samples.
Unit tests cover parsing (NA/x/-/. vs NaN/inf vs "twelve"), the digest
changing on edit, per-user isolation, and name validation.

rqtl/gemma take the same 10-line change next -- their `samples` shapes
differ, so they are a separate commit rather than a rushed one.
Diffstat (limited to 'test/python/test_mapping_methods.py')
0 files changed, 0 insertions, 0 deletions