Analysis nodes: mark a Classifications (or All Variants) node out of date when the data behind its snapshot changes, checked cheaply when the analysis is viewed

Open
#2,677 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
django, python, redis
Domain
backend, databases

Research direction

Start with ClassificationQuerySet.variant_q() in classification/models/classification.py and trace NodeVersion, nodes_status, and PopulationNode._get_live_data_sources() to understand existing snapshot and status checks. The proposal spans node loading, polling, background rechecks, cache behavior, and reported analyses; define the cross-node design and measure recheck cost on a production-sized classification table. Done means changed result sets are labeled without reloading nodes, while unchanged sets only update their stamps.

Written by the indexing model from the issue text.

Description

Analysis enhancement

🤖 Written by Claude

Raised from the #1789 review. Not scheduled.

Problem

A Classifications node's result is a snapshot. ClassificationQuerySet.variant_q() (classification/models/classification.py:235) turns the variant IDs into a list when the node loads. That list is kept in the node's stored pks (NodeVersion.variant_ids) or in its cached Q, so the grid and the count agree. When classifications change afterwards (new, reclassified, withdrawn), nothing on the canvas says the node is out of date:

  • ClassificationsNode.get_warnings() ("N new or changed classifications since last save - press save to include them") only shows in the node editor. The card badge (#347) shows warnings stored in NodeVersion.load_data when the node loaded. A node loads straight after it's saved, when hardly anything is newer than node.modified, so that stored copy is almost always empty.
  • The warning counts every Classification modified since the save, whether or not this user can see it, and whatever its build or lab. On a busy server it is nearly always on.
  • AllVariantsNode ("N new variants in the database since last save") has the same problem.

⚡ (markLiveDataCount(), set from _get_live_data_sources()) is a different state: the count is worked out against live data and may differ from the grid. It doesn't fit a snapshot that has gone out of date.

Proposal

Add an out-of-date state alongside ⚡. Detect it cheaply when an analysis is viewed. Never reload anything automatically.

  1. Record a version at load. When a node that reads changing data loads, store a version for each source on its NodeVersion, for example a number from the latest Classification.modified. This works like the stamp PopulationNode._get_live_data_sources() stores.
  2. Cheap test when polled. nodes_status compares stored stamps with the current ones, with one query per source per poll rather than one per node. If nothing has moved, nothing more happens.
  3. Re-check in the background when a stamp moves. Re-run only the node's own part (_classifications_q() as the analysis owner), not its parents or children, and compare the variant set with the stored one.
    • Same set: update the stamp only. Leave the node version alone, so the cached results of the nodes below are kept. update_analysis_tag_node_counts() already recounts tag counts without bumping the version in the same way.
    • Different set: mark the node as out of date with the change, e.g. "+2 / −1 since save". Nodes below it show "upstream out of date". Nothing reloads until the user saves.
  4. Variants dropping out get the stronger warning. A variant leaving the result (withdrawn, or reclassified to a significance the node excludes) matters more than one coming in.
  5. Replace the editor-only warnings in ClassificationsNode and AllVariantsNode with this. Comparing result sets also fixes the scope problem, because only changes that alter this node's output count.

Make it a general node hook (a stamp per source, plus a cheap recheck) rather than something only the Classifications node has.

Things to keep in mind

  • Reported analyses: never change anything on an analysis that may have been reported from. Only label it.
  • Redis cache evictions: if a large node's cached Q is evicted, it is rebuilt from live data, and the grid can then disagree with the stored count without anything showing. Running the version check when the Q is rebuilt would catch this too.
  • Cost: the background recheck runs the classification part of the node as the analysis owner. It should be timed against a production-sized classification table before adding it to every view of an analysis.
Dominant language
Python
Stars
31
Forks
4
Avg merge
4h 52m
Merged PRs (30d)
183

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SACGF/variantgrid

All issues in SACGF/variantgrid

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.