diff options
| author | Pjotr Prins <pjotr.public01@thebird.nl> | 2026-10-04 18:19:38 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-10-04 18:19:38 +0000 |
| commit | adc173c1f3c78da487827122262573e753284260 (patch) | |
| tree | 9f9f5a378a3cc5ea6a0af9b02bd446eb5af39045 /test/python/test_dev_token.py | |
| parent | ea3633cf3e00047ca3906406c270d9f04acd2241 (diff) | |
| download | genenetwork4-adc173c1f3c78da487827122262573e753284260.tar.gz | |
Add GET /traits/{dataset}/... spanning ProbeSet and Publish data
A new, additional endpoint family that addresses both trait categories
the same way -- (dataset, trait) -- matching GeneNetwork2's own generic
wqflask.api.router.trait_sample_data/get_trait_info, rather than the
two category-specific shapes genenetwork4 already has
(/datasets/{dataset}/probesets... and /groups/{group}/traits...), which
are unchanged and keep working exactly as before.
- db::resolve_trait_dataset(name) resolves a dataset name against
ProbeSetFreeze first, then the new db::PublishDataset (a PublishFreeze
row, via the new get_publish_freeze_by_name) -- whichever matches
decides the category. This means only dataset names are ever
"guessed" across categories, not trait names/ids, which is the much
smaller and safer surface: GN2's own equivalent tries ProbeSet.Name
and PublishXRef.Id against the same bare trait string and silently
falls back, which can return the wrong trait on a same-named
collision. get_publish_freeze_by_name accepts a PublishFreeze's own
Name/ShortName/Id or its owning group's Name/InbredSetName/FullName/
Id, mirroring GN2's own flexible matching (e.g. "BXDPublish" or
"BXD").
- GET /traits/{dataset}: list every trait in a dataset, tagged by
category.
- GET /traits/{dataset}/{trait}: one trait's metadata. A non-numeric
trait against a Publish dataset is a 404 (can't match a
PublishXRef.Id), not a 500.
- GET /traits/{dataset}/{trait}/values: that trait's per-strain values.
TraitValue and ProbeSetValue are already identical in shape, so this
unifies with no information loss, unlike the metadata endpoint above.
Metadata responses are a tagged union ({"category": "probeset"|
"publish", ...}) wrapping ProbeSetInfo/TraitInfo unchanged, rather than
a lossy common-fields schema -- the two share little beyond
mean/locus/lrs/additive. utoipa generates this as a oneOf with a
category discriminator, verified against /openapi.json.
Gated the same way as /datasets/{dataset}/probesets..., extended to
Publish data for the first time: /groups/{group}/traits itself is
still not gated, but reaching the same data through /traits/{group}
now requires a token and checks PublishFreeze.public/confidentiality.
No gn-auth-side change was needed -- POST /auth/data/authorisation
already dispatches *Publish-suffixed dataset names to its phenotype
resource resolver (gn_auth/auth/authorisation/data/phenotypes.py),
the exact mechanism this integration already relies on for mRNA data.
auth::VIEW_RESOURCE_PRIVILEGE moves from routes::datasets (private) to
routes::auth (pub) so routes::traits can reuse it instead of
duplicating the string.
tests/traits.rs and its Python mirror cover both categories (including
both ways of addressing a Publish dataset), the 401/403/404 cases, and
the non-numeric-trait-against-Publish-dataset edge case, run against a
real gn-auth instance. The Publish branch's deny path itself is only
exercised via gn-auth's "unlinked dataset" fallback (already proven for
ProbeSet) -- no non-public PublishFreeze exists in the database this
was tested against.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XDDpXvZBQat9uSgDeEMJ8d
Diffstat (limited to 'test/python/test_dev_token.py')
0 files changed, 0 insertions, 0 deletions
