Skip to content

fix: PR 39 review findings (G3-803, G3-777, G3-764) - #40

Merged
belkassaby merged 5 commits into
mainfrom
fix/G3-803-review-findings
Nov 17, 2026
Merged

belkassaby merged 5 commits into
mainfrom
fix/G3-803-review-findings

Conversation

@belkassaby

@belkassaby belkassaby commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes the ten findings and two notes in the PR 39 review (geneweaver-review.md), and the two warnings in the PR 40 review of 2026-11-17.

Base: this was stacked on #39 (feat/G3-803-tool-visualizations). #39 merged on 2026-11-05, so the PR now targets main, with main merged in (d513c236). One fix was needed after that merge; see Merging main.

Legacy and regressions

  • No legacy changes. No file under legacy/, no database function and no migration is touched.

  • Suites on the current head, run locally on Python 3.12:

    Suite Result
    API 737 passed, 30 skipped, 1 failed: test_first_party_subpackage_is_importable[client], because geneweaver.client isn't installed locally
    packages/db 55,986 passed
    packages/tools 300 passed, 5 skipped
    packages/tools-plugin 62 passed
    UI 409 passed

    Lint passes on the changed files.

  • Two fixes change ABBA's results on purpose (findings 6 and 8 below). Both were measured on dev, old against new, for anonymous, group-member, private-set-owner, admin and curator users.

UI (68193113)

# Finding Fix
1 JaccardSimilarity's Venn grid sized every set from its last pair, wrong under pairwise deletion Each cell is sized from its own pair. The diagonal uses the gene set's own size from the run's gene counts, with a note when a pair shows it smaller.
2 BooleanAlgebra species table labelled ids 8+ wrong (8 showed "Yeast"), because ids skip 7 Uses the shared id-keyed names: full names, as legacy's table shows them. The gene set page's species tag had the same off-by-one. It is fixed, its wrong entry for id 11 (Xenopus laevis instead of dog) is corrected, and ids 12–13 are added.
3 Suggestion paging skipped a row after an ID lookup Pages from the search's own offset, not the list length. A refused search also stops paging.
9 UpSet drew half-width bars when every set was empty (max(...) ?? 1 lets 0 through) || 1, here and in the MSET histogram.
10 Search filters didn't check the p/q range, and a 422 read as "not responding" The range is checked as the analysis cutoffs are. A refused search shows the API's reason.
note downloadSvg revoked the URL right after click() The URL is now revoked on the next tick.

API, database, tools (c75c400d, 84299b76)

4. threshold: "custom" with no cutoff. It used to mean "all genes" while being reported as thresholded. It is now refused with a 422.

8. ABBA used a third visibility rule.

  • Legacy's ABBA rule required every group of a gene set to be one of the user's. So it hid users' own private sets, the admin/curator view, and group-restricted sets in public tiers. It also matched any gene set with an empty group list for anyone, anonymous included (1,006 on dev, all private or untiered).

  • The fix: ABBA now uses geneweaver.db.query.readable, one set-based form of geneset_is_readable2 shared with search.

  • On dev it only adds gene sets. For seed Drd2/Drd1:

    User Matching gene sets before After
    Anonymous 5,190 5,647 (+457 in public tiers)
    Admin 5,375 7,190
    Curator 5,358 7,190

6. ABBA seed gene sets expanded to every identifier (as legacy does). Only symbols match the seed, but symbol synonyms matched other genes sharing them.

Seed Gene set size Seed genes before Seed genes after
GS821 163 2,158 1,064
GS167180 74 1,094 502
  • Now one preferred symbol per gene. The expansion query is shared, so this applies on the tools worker as well as in-process. It changes results: about 7–9k fewer matching gene sets for those seeds, and the search runs 2–3× faster.
  • Cap: seeds over 20,000 genes are refused with their size. The largest gene set on dev, 17,370 genes, still fits.
  • Repeats count once (review 2026-11-17, finding 1). ABBAInput cleaned its genes after pydantic checked the cap, and the API counted distinct genes but passed the raw list on. So a seed of exactly 20,000 genes, plus a typed gene it already held, was refused with 422. clean_genes now runs before the cap, and the API counts and passes the same cleaned list. The 1,000 typed-gene cap on ABBARequest counts distinct genes too.

5. ABBA's request time.

  • Before: each statement was bounded (240 s), but the request wasn't, and it runs about 20 statements plus 4 per result gene.
  • Now: ABBA_REQUEST_TIMEOUT_SECONDS (270, under the 300 s ingress) is one budget for the whole in-process request. It starts before the connection is leased.
  • What it covers (review 2026-11-17, finding 2, and Copilot): in c75c400 the budget started inside search(), so the access gate, the seed expansion and the three name lookups ran outside it. All of them now spend from it. Each statement's timeout is what's left, at most 240 s. A statement cancelled at the deadline answers 504 with the reason, not 500.
  • Worker: the path is unchanged, apart from the shared seed expansion in finding 6. It sets no request budget.

7. ABBA identity token.

  • Before: it signed only the user ID, so a copy could be replayed for any search, indefinitely.
  • Now: v2 also signs an expiry (6 h) and a digest of the search input. The label moves to v2, so an ABBA run submitted before the deploy and still in flight fails to verify.
  • Secret: the key is ABBA_IDENTITY_SECRET where set, else DB_PASSWORD as before. The API and tools worker read it from an optional geneweaver-abba-identity Secret, so nothing changes until that Secret is created.

Note: search() docstring. It no longer claims the connection is left clean. On the API's pooled connection, the search runs in a savepoint.

Merging main (3a458115)

While this PR was open, main added Similar gene sets, which signs its runs with ABBA's identity in its v1 form: sign(user, DB_PASSWORD), and DB_PASSWORD from the environment on the worker. The merge was textually clean, but the API call no longer matched v2's sign(), and the worker used an os import this PR had removed. Similar gene sets now signs and verifies exactly as ABBA does: for its input, with an expiry, keyed by ABBA_IDENTITY_SECRET or the database password. A test checks the dedicated secret and that a signature fits only the search it was made for.

After merge / deploy

…rs, refusals

From geneweaver-review.md (findings 1, 2, 3, 9, 10 and a note):

1. JaccardSimilarity's Venn grid drew each set at the size of its last
   pair. With pairwise deletion a cross-platform pair counts only the genes
   both platforms measure, so pairs disagree. Each cell is now sized from
   its own pair; the diagonal is the gene set's own size (the run's gene
   counts), noting when a pair shows it smaller.
2. BooleanAlgebra's species table named species by position: the ids skip
   7, so 8 (C. elegans) read "Yeast" and 9 read "Chicken". It now uses the
   shared, id-keyed names -- full names, as legacy's table showed them. The
   gene set page's species tag had the same off-by-one; it is keyed by id
   too, and gains 11-13.
3. Suggestion paging fetched the next page from the list's length, which
   an id lookup at its head (or a dropped repeat) put off by one or more,
   so a search row was never shown. It now tracks the search's own offset.
9. UpSet drew a half-width bar for every set when all were empty: d3's max
   of zeros is 0, not undefined, so `?? 1` let a [0, 0] domain through.
   `|| 1`, here and in the MSET histogram.
10. Search filters now check p- and q-value cutoffs are within 0..1, as the
   analysis cutoffs do; and a search the API refuses shows its reason
   instead of "The gene set search is not responding".
Note: a downloaded chart's object URL is revoked on the next turn, not
straight after click(), which some browsers cancel.
…t, identity

From geneweaver-review.md (findings 4-8 and a note). No legacy code,
database function or migration changes.

4. threshold "custom" with no cutoff validated and silently meant "all
   genes" while reported as thresholded. ThresholdOptions refuses it (422),
   as the analysis page already did.

8. ABBA matched gene sets by legacy's own rule: every group of a gene set
   had to be one of the user's. It hid a user's own private gene sets, an
   admin's or curator's view, and group-restricted gene sets in public
   tiers -- and matched any gene set with an empty group list for anyone,
   anonymous included (1,006 on dev, all private or untiered). ABBA now
   reads the rule search and a tool run use: geneweaver.db.query.readable,
   one set-based form of geneset_is_readable2, shared by search and ABBA.
   On dev it only adds gene sets: seed Drd2/Drd1, anonymous 5,190 -> 5,647
   (457 public-tier); an admin or curator 5,375 -> 7,190.

6. A seed gene set expanded to every identifier of every gene (legacy did
   the same). Only symbols match the seed, so the rest matched nothing,
   but symbol synonyms matched other genes sharing them: GS821 (163 genes)
   seeded 2,158 genes, GS167180 (74) seeded 1,094. Now one preferred symbol
   per gene: 1,064 and 502 (homonyms across species remain, as in legacy).
   This changes results -- ~7-9k fewer matching gene sets for those seeds
   -- and runs 2-3x faster. A seed over 20,000 genes is refused with its
   size (the largest gene set on dev, 17,370, still fits); ABBAInput caps
   genes at 20,000 for runs submitted to AsyncTask directly.

5. An in-process ABBA search bounded each statement (240 s) but not the
   request, which runs ~20 statements plus 4 per result gene, so a slow
   database could outlast the 300 s ingress. ABBA_REQUEST_TIMEOUT_SECONDS
   (270) now bounds the whole search: each statement's timeout shrinks to
   what is left, and running out answers 504 with the reason and frees the
   concurrency slot. The worker path sets no budget and is unchanged.

7. A signed ABBA identity covered only the user id, so one copied from a
   run's stored values could be replayed for any search, forever. v2 signs
   the user, an expiry (6 h) and a digest of the search's input. The key
   is ABBA_IDENTITY_SECRET where set, else DB_PASSWORD as before; the API
   and tools worker read it from an optional geneweaver-abba-identity
   Secret, so nothing changes until that Secret is created.

Note: search()'s docstring said it leaves the connection clean; on the
API's pooled connection its transaction is a savepoint, so the temp tables
and SET LOCAL last until the caller's transaction ends. Documented.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

An active moderate finding shows that metadata and preparation queries can exceed the intended request deadline, leaving the timeout budget unenforced and requiring code changes.

No open issues 🎉

What changed in this PR

This PR fixes the findings from the review of PR 39, which added charts for each analysis tool on the /next/analyze page. It covers the UI charts and search, the ABBA search in the API, database, and tools worker, and two deployment files. It does not touch legacy code, database functions, or migrations.

Changes:

  • UI: Fixes chart sizing and labels (UpSet, Jaccard, species names), search paging and p/q range checks, and shows the API's reason when a search is refused.
  • ABBA search: Uses one shared access rule, matches one preferred symbol per gene, caps seed size at 20,000 genes, and adds a 270-second request budget that returns 504 when exceeded.
  • Identity and config: The signed ABBA identity now covers the search input and expires after 6 hours. It uses an optional ABBA_IDENTITY_SECRET, falling back to DB_PASSWORD, and the deployments read it from an optional Secret.
File Description
ui/​src/​app/​search/​search-filters.ts Checks that p-value and q-value filters are between 0 and 1 before a search is sent.
ui/​src/​app/​search/​search-filters.spec.ts Tests the new p-value and q-value range checks.
ui/​src/​app/​search/​geneset-search-source.ts Pages from the search's own offset and stores the API's refusal reason.
ui/​src/​app/​pages/​analyze/​visualizations/​upset-plot.component.ts Uses || 1 so an all-empty set list no longer draws half-width bars.
ui/​src/​app/​pages/​analyze/​visualizations/​upset-plot.component.spec.ts Tests that empty gene sets draw zero-width bars.
ui/​src/​app/​pages/​analyze/​visualizations/​tool-result.component.ts Passes gene counts into the Jaccard Venn grid so the diagonal uses each set's true size.
ui/​src/​app/​pages/​analyze/​visualizations/​mset-histogram.component.ts Uses || 1 for the histogram's y-axis maximum.
ui/​src/​app/​pages/​analyze/​visualizations/​models.ts Sizes each Jaccard cell from its own pair and reads species names by id.
ui/​src/​app/​pages/​analyze/​visualizations/​models.spec.ts Tests per-pair sizing and species names by id.
ui/​src/​app/​pages/​analyze/​visualizations/​chart-utils.ts Revokes the download URL on the next tick, so the download is not cancelled.
ui/​src/​app/​pages/​analyze/​geneset-picker.component.ts Shows the API's refusal reason under the gene set search.
ui/​src/​app/​pages/​analyze/​geneset-picker.component.spec.ts Tests paging after an ID lookup and the refusal message.
ui/​src/​app/​components/​speciestag/​speciestag.component.ts Looks up species by id instead of list position, fixing the labels from id 8 on.
ui/​src/​app/​components/​speciestag/​speciestag.component.spec.ts Tests species names by id, including unknown ids.
tests/​services/​test_abba.py Tests the signed identity, the dedicated secret, the seed size cap, and the 504 timeout.
tests/​controllers/​test_tools.py Tests that an ABBA search out of time returns 504 with its reason.
src/​geneweaver/​api/​services/​abba.py Refuses seeds over 20,000 genes, signs the identity with the chosen secret, and maps timeouts to 504.
src/​geneweaver/​api/​core/​config_class.py Adds the request timeout (270 s) and the optional identity secret settings.
src/​geneweaver/​api/​controller/​tools.py Returns 504 with the timeout reason for an ABBA search that runs out of time.
packages/​tools/​tests/​unit/​test_thresholds.py Tests that custom with no cutoff is refused.
packages/​tools/​tests/​unit/​test_abba.py Tests the v2 identity (expiry and input digest) and the seed cap.
packages/​tools/​src/​geneweaver/​tools/​thresholds.py Refuses threshold: "custom" when no cutoff is given.
packages/​tools/​src/​geneweaver/​tools/​temporal/​activities.py Reads the identity key from the shared signing secret helper and passes the input to verify it.
packages/​tools/​src/​geneweaver/​tools/​abba/​search.py Adds a whole-search deadline, with each statement's timeout set to the time left.
packages/​tools/​src/​geneweaver/​tools/​abba/​schema.py Caps the seed gene list at 20,000 entries.
packages/​tools/​src/​geneweaver/​tools/​abba/​identity.py Version 2 identity: signs the expiry and a digest of the input, and checks both.
packages/​db/​tests/​unit/​test_abba.py Tests the shared access rule, one symbol per seed gene, and the deadline behaviour.
packages/​db/​src/​geneweaver/​db/​query/​search/​search.py Uses the shared readable-gene-set predicate instead of its own copy.
packages/​db/​src/​geneweaver/​db/​query/​readable.py New shared SQL predicate for which gene sets a user may read.
packages/​db/​src/​geneweaver/​db/​query/​abba.py Uses the shared access rule and one preferred symbol per seed gene.
packages/​db/​src/​geneweaver/​db/​abba.py Runs each ABBA statement under the remaining time budget and reports running out of time.
deploy/​k8s/​base/​tools-worker-deployment.yaml Adds the optional identity Secret to the tools worker.
deploy/​k8s/​base/​deployment.yaml Adds the optional identity Secret to the API.

Review effort: Lite

…ging main

main added Similar gene sets while this branch was open, signing with the v1
identity: sign(user, DB_PASSWORD) on the API and DB_PASSWORD from the
environment on the worker. This branch moved the identity to v2 (signed for the
input, expiring, keyed by ABBA_IDENTITY_SECRET where set), so after the merge
the API call no longer matched sign()'s signature and the worker referred to a
removed os import.

Similar gene sets now signs for its input with ABBA_IDENTITY_SECRET or the
database password, and the worker verifies with signing_secret() against the
run's input, exactly as for ABBA.
@belkassaby
belkassaby changed the base branch from feat/G3-803-tool-visualizations to main November 17, 2026 15:16
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Test Coverage Report

============================= test session starts ==============================
platform linux -- Python 3.11.18, pytest-8.4.2, pluggy-1.6.0
rootdir: /home/runner/work/geneweaver/geneweaver
configfile: pyproject.toml
plugins: asyncio-1.3.0, anyio-4.13.0, cov-4.1.0
asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 768 items

tests/controllers/test_api_standards.py ................................ [  4%]
........................................................................ [ 13%]
..............................................ssssssssssssssssssssssssss [ 22%]
ssss                                                                     [ 23%]
tests/controllers/test_genes.py .............                            [ 25%]
tests/controllers/test_genesets.py ..................................... [ 29%]
.....................                                                    [ 32%]
tests/controllers/test_genesets_search.py ................               [ 34%]
tests/controllers/test_monitor.py .                                      [ 34%]
tests/controllers/test_publications.py ........                          [ 35%]
tests/controllers/test_return_schemas.py .                               [ 36%]
tests/controllers/test_search.py ..                                      [ 36%]
tests/controllers/test_sessions.py ..................................... [ 41%]
....                                                                     [ 41%]
tests/controllers/test_species.py ....                                   [ 42%]
tests/controllers/test_tools.py ........................................ [ 47%]
...............                                                          [ 49%]
tests/core/test_security.py ...........                                  [ 50%]
tests/core/test_session.py ........................                      [ 53%]
tests/services/io/test_read_file_contents.py ...............             [ 55%]
tests/services/test_abba.py ................................             [ 60%]
tests/services/test_asynctask.py ......................                  [ 62%]
tests/services/test_gene.py ..............                               [ 64%]
tests/services/test_genset.py .......................................... [ 70%]
.................................................                        [ 76%]
tests/services/test_monitors.py ..                                       [ 76%]
tests/services/test_ontology.py ....                                     [ 77%]
tests/services/test_publications.py .......                              [ 78%]
tests/services/test_similar_genesets.py .......                          [ 79%]
tests/services/test_species.py .......                                   [ 80%]
tests/services/test_tool_inputs.py .................                     [ 82%]
tests/services/test_tools.py ........................................... [ 87%]
........................................................................ [ 97%]
........                                                                 [ 98%]
tests/test_namespace_integrity.py .............                          [100%]

=============================== warnings summary ===============================
tests/data/__init__.py:10
  /home/runner/work/geneweaver/geneweaver/tests/data/__init__.py:10: DeprecationWarning: read_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    geneset_response_json = importlib.resources.read_text("tests.data", "response_geneset_1234.json")

../../../../../opt/hostedtoolcache/Python/3.11.18/x64/lib/python3.11/importlib/resources/_legacy.py:80: 11 warnings
  /opt/hostedtoolcache/Python/3.11.18/x64/lib/python3.11/importlib/resources/_legacy.py:80: DeprecationWarning: open_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    with open_text(package, resource, encoding, errors) as fp:

tests/data/__init__.py:11
  /home/runner/work/geneweaver/geneweaver/tests/data/__init__.py:11: DeprecationWarning: read_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    geneset_w_gene_id_type_json = importlib.resources.read_text(

tests/data/__init__.py:15
  /home/runner/work/geneweaver/geneweaver/tests/data/__init__.py:15: DeprecationWarning: read_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    geneset_list_response_json = importlib.resources.read_text("tests.data", "geneset.json")

tests/data/__init__.py:17
  /home/runner/work/geneweaver/geneweaver/tests/data/__init__.py:17: DeprecationWarning: read_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    gene_homologus_ids_json = importlib.resources.read_text("tests.data", "homologus_ids.json")

tests/data/__init__.py:19
  /home/runner/work/geneweaver/geneweaver/tests/data/__init__.py:19: DeprecationWarning: read_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    gene_id_mapping_json = importlib.resources.read_text("tests.data", "gene_maping.json")

tests/data/__init__.py:21
  /home/runner/work/geneweaver/geneweaver/tests/data/__init__.py:21: DeprecationWarning: read_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    publications_json = importlib.resources.read_text("tests.data", "publications.json")

tests/data/__init__.py:23
  /home/runner/work/geneweaver/geneweaver/tests/data/__init__.py:23: DeprecationWarning: read_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    jwt_test_keys_json = importlib.resources.read_text("tests.data", "security_jwt_RS256_keys.json")

tests/data/__init__.py:25
  /home/runner/work/geneweaver/geneweaver/tests/data/__init__.py:25: DeprecationWarning: read_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    species_json = importlib.resources.read_text("tests.data", "species.json")

tests/data/__init__.py:27
  /home/runner/work/geneweaver/geneweaver/tests/data/__init__.py:27: DeprecationWarning: read_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    genes_json = importlib.resources.read_text("tests.data", "genes.json")

tests/data/__init__.py:29
  /home/runner/work/geneweaver/geneweaver/tests/data/__init__.py:29: DeprecationWarning: read_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    monitors_json = importlib.resources.read_text("tests.data", "monitors.json")

tests/data/__init__.py:31
  /home/runner/work/geneweaver/geneweaver/tests/data/__init__.py:31: DeprecationWarning: read_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    ontology_json = importlib.resources.read_text("tests.data", "ontology.json")

tests/controllers/test_sessions.py: 17 warnings
tests/core/test_session.py: 10 warnings
  /home/runner/work/geneweaver/geneweaver/.venv/lib/python3.11/site-packages/starlette/testclient.py:445: DeprecationWarning: Setting per-request cookies=<...> is being deprecated, because the expected behaviour on cookie persistence is ambiguous. Set cookies directly on the client instance instead.
    return super().request(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

---------- coverage: platform linux, python 3.11.18-final-0 ----------
Name                                              Stmts   Miss  Cover
---------------------------------------------------------------------
src/geneweaver/api/__init__.py                        5      2    60%
src/geneweaver/api/controller/__init__.py             0      0   100%
src/geneweaver/api/controller/api.py                 19      1    95%
src/geneweaver/api/controller/auth.py                95      1    99%
src/geneweaver/api/controller/genes.py               38      0   100%
src/geneweaver/api/controller/genesets.py           100      3    97%
src/geneweaver/api/controller/message.py             27      0   100%
src/geneweaver/api/controller/monitors.py            15      0   100%
src/geneweaver/api/controller/publications.py        34      0   100%
src/geneweaver/api/controller/search.py              20      0   100%
src/geneweaver/api/controller/species.py             16      0   100%
src/geneweaver/api/controller/tools.py               84      1    99%
src/geneweaver/api/controller/utilities.py            9      0   100%
src/geneweaver/api/core/__init__.py                   0      0   100%
src/geneweaver/api/core/config.py                     2      0   100%
src/geneweaver/api/core/config_class.py              44      0   100%
src/geneweaver/api/core/exceptions.py                13      1    92%
src/geneweaver/api/core/security.py                 139     20    86%
src/geneweaver/api/core/session.py                   37      1    97%
src/geneweaver/api/dependencies.py                   72     37    49%
src/geneweaver/api/main.py                            1      0   100%
src/geneweaver/api/schemas/__init__.py                0      0   100%
src/geneweaver/api/schemas/apimodels.py              62      6    90%
src/geneweaver/api/schemas/auth.py                   17      0   100%
src/geneweaver/api/schemas/messages.py               15     15     0%
src/geneweaver/api/schemas/score.py                  12     12     0%
src/geneweaver/api/schemas/search.py                 42      0   100%
src/geneweaver/api/schemas/tools.py                  60      1    98%
src/geneweaver/api/services/__init__.py               0      0   100%
src/geneweaver/api/services/abba.py                  77      1    99%
src/geneweaver/api/services/asynctask.py             90      1    99%
src/geneweaver/api/services/genes.py                 45      0   100%
src/geneweaver/api/services/geneset.py              184      5    97%
src/geneweaver/api/services/io.py                     4      0   100%
src/geneweaver/api/services/monitors.py              10      0   100%
src/geneweaver/api/services/parse/__init__.py         0      0   100%
src/geneweaver/api/services/publications.py          46      0   100%
src/geneweaver/api/services/pubmeds.py                0      0   100%
src/geneweaver/api/services/similar_genesets.py      47      0   100%
src/geneweaver/api/services/species.py               17      0   100%
src/geneweaver/api/services/tool_inputs.py           64      0   100%
src/geneweaver/api/services/tool_runner.py            8      0   100%
src/geneweaver/api/services/tools.py                277      2    99%
---------------------------------------------------------------------
TOTAL                                              1847    110    94%
Coverage HTML written to dir htmlcov

================ 738 passed, 30 skipped, 49 warnings in 13.77s =================

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The metadata setup queries run with a fixed timeout before deadline-aware handling, so a slow query can exceed the advertised request bound or produce an unhandled 500 instead of the documented 504.

1 open issue

Review effort: Lite

from geneweaver.db.query.membership import Thresholds
from psycopg.rows import tuple_row

deadline = None if deadline_seconds is None else time.monotonic() + deadline_seconds

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 84299b7. The three name lookups now go through the same deadline-aware execute_within as the pipeline, so each one gets only what is left of the budget, at most 240 s. The budget no longer starts in search(): the API takes one deadline before it leases the connection and passes it through the access gate, the seed expansion, the lookups and the pipeline. A statement Postgres cancels at the deadline is reported as ABBADeadlineExceeded, which the API answers with 504, not 500. Tests: test_the_name_lookups_are_bounded_by_the_deadline (packages/tools) and test_preparation_spends_the_same_budget_as_the_search / test_a_gate_query_cancelled_at_the_deadline_is_a_504 (tests/services).

…genes count once

Two warnings from the PR 40 review, and Copilot's comment on search.py.

The 270 s budget started inside search(), so the access gate, the seed
expansion and the three name lookups ran outside it, each under its own 240 s
statement timeout: a slow preparation could use up the ingress's 300 s before
the budget began, and a cancelled preparation query answered 500 instead of
504. The in-process request now takes one deadline before its connection is
leased, and every statement spends from it: each gate check, the seed
expansion, the name lookups and the pipeline get only what is left (at most
240 s each), and a statement cancelled at the deadline is ABBATimedOut (504).
The bounding moves out of abba() into geneweaver.db.abba (execute_within,
bound_next_statement, deadline_cancellation) so all of them share it, and the
gate takes a before_each hook. search() takes the deadline as an instant; the
worker passes none and runs as before.

ABBAInput cleaned its genes after pydantic checked the 20,000 cap, and the API
counted distinct genes but passed the raw list on, so a seed of exactly 20,000
genes plus a typed gene it already held was refused with 422. The cleaning now
runs before the cap (clean_genes, mode="before"), and the API counts and passes
the same cleaned list. ABBARequest's 1,000 typed-gene cap counts distinct genes
the same way.
@belkassaby
belkassaby requested a deployment to jax-cluster-dev-10--dev November 17, 2026 16:08 — with GitHub Actions Waiting
@belkassaby
belkassaby requested a deployment to jax-cluster-dev-10--dev November 17, 2026 16:12 — with GitHub Actions Waiting
@belkassaby
belkassaby merged commit bf702e4 into main Nov 17, 2026
11 of 13 checks passed

This branch is waiting to be deployed

1 waiting deployment
jax-cluster-dev-10--dev — 84299b76 Waiting Nov 17, 2026 by belkassaby via Deploy: Dev / deploy #99
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants