Skip to content

A re-sent VCF no longer changes a group analysis that wasn't reloaded, warns on node cards, and is labelled on every run page tab (#2929) - #2936

Merged
davmlaw merged 2 commits into
masterfrom
2929_resent_pin_group_samples
Nov 30, 2026
Merged

davmlaw merged 2 commits into
masterfrom
2929_resent_pin_group_samples

Conversation

@davmlaw

@davmlaw davmlaw commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Results and testing notes: #2929 (comment). Follow-up to #2930, from the agent-testing comment on #2929.

1. A group sample node reads the samples it loaded with

Cause. A group level SampleNode (extraction / specimen / patient) worked out its samples on every query (SampleNode._sample_group → get_sample_group), not when it loaded. Its counts and card come from the load, but the grid, grid columns and warnings came from whatever the group held at the time of the request. So when auto-launch left a locked analysis alone after a re-send, it still switched to the new sample at its unchanged node version, and called the sample it was locked on "not included". That is the opposite of the "counts are a cache of a query against an immutable node_version" rule in AnalysisNode.node_counts.

Fix. It uses the snapshot hook the node already has: _get_load_data ("snapshot anything else the node worked out at load") already writes the card warnings to NodeVersion.load_data. A group level SampleNode now also writes load_data["source_samples"] = {"source": "<level>:<pk>", "sample_ids": [...]}. SampleNode._get_loaded_sample_ids reads it back, and get_sample_group(..., loaded_sample_ids=) then:

  • keeps a loaded sample even though its VCF has been replaced (get_exclusion_reason(keep_replaced=True)). Archived, failed-import and wrong-build samples are still left out, because their data can't be read.
  • leaves out any sample that joined the group after the load, with the warning "VCF 'X' arrived after this node loaded - reload the node to read it". The cohort mixin's existing "VCF 'X' was replaced by VCF 'Y' … This node reads the earlier VCF" warning now fires on the group node too, because the replaced sample is still one of its samples.

Because the snapshot belongs to the NodeVersion, anything that bumps the version re-resolves the group: an edit, reload_analysis_nodes (auto-launch's in-place reload of an analysis nobody worked in, Analysis Settings → Force Reload All Nodes), or the sample-delete bump. The snapshot is keyed on the source, so an editor form that has just picked a different source (and drops _sample_group) resolves live. A NodeVersion loaded before this deploy has no snapshot and resolves live, as it does now, until its next reload.

Behaviour change beyond re-sends: a sample linked to a group after the node loaded (a second sequencing run for the same specimen, a late extraction match) now shows up after the node is reloaded, not straight away in the grid. Until then it is named in a warning. Before this change, such a sample appeared in the grid while the counts stayed stale. The analysis/AGENTS.md note on auto-launch says this now.

2. The card shows the replacement warning on nodes that weren't reloaded

Card warnings are load_data["warnings"], written at load, and nothing reloads an analysis that's left reading a replaced VCF. node_utils.update_node_warnings(nodes_qs) rewrites that key in place on each READY node's current version, with a jsonb_set that works the same way as update_analysis_tag_node_counts does for tag counts (no version bump, because the results haven't changed). The new task update_node_warnings_for_replaced_vcfs(vcf_id) is the third link in handle_vcf_import_success's chain, after the auto-launch reload. It finds the nodes through get_nodes_reading_sample_q: the sample → nodes Q that handle_sample_pre_delete already built, moved into node_utils so both callers use it. It also adds cohortnode__cohort__vcf. A node that isn't READY writes its own warnings when it loads. I picked this over adding live warnings in nodes_status, because that view is polled and would need every node's subclass loaded on every poll. Routed to analysis_workers.

3. Run page labels

New seqauto/tags/vcf_replaced_badge.html, used by the Data tab (run_vcf.html, the badge it already drew), by the Patients tab rows (run_sample_row.html, on both the sample and the VCF cells) and by the SampleSheet tab's sample cell. The SampleSheet query now prefetches sample__vcf.

Tests

  • analysis.tests.test_sample_node_levels: a loaded extraction node keeps its samples and grid cohorts across a re-send, with both warnings, and switches on a version bump (fails on the old SampleNode). Also: the warnings task rewrites the card warnings of a sample-level node and a group node left reading the replaced VCF.
  • seqauto.tests.test_sequencing_run_patients: the run page labels the replaced sample on the Patients and SampleSheet tabs.
  • Full suite with --keepdb --parallel 4: 4822 tests OK.

…, warns on the cards of nodes left reading it, and is labelled on every run page tab #2929

A group level SampleNode keeps the samples it loaded with on its NodeVersion (load_data["source_samples"]),
so a VCF re-sent or a sample linked afterwards is a warning until the node reloads, rather than changing
the grid of an analysis someone is working from. After a re-sent VCF imports, the nodes still reading the
VCF it replaced get their card warnings rewritten in place (update_node_warnings), as tag counts are. The
run page's Patients and SampleSheet tabs mark the replaced sample and VCF as the Data tab does.
…ing_sources_q over patients.sample_grouping.get_source_ids_for_samples, shared by related analyses, sample delete and the replaced VCF warnings #2929
@davmlaw
davmlaw merged commit e8181d1 into master Nov 30, 2026
4 checks passed
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.

1 participant