Repository navigation
Fix: Stitched HCA bundles are indexed as many links replicas that differ only in link order (#8393, #8259, #8294) - #8418
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8418 +/- ##
========================================
Coverage 84.99% 85.00%
========================================
Files 170 170
Lines 26068 26085 +17
========================================
+ Hits 22157 22174 +17
Misses 3911 3911 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
7c28fc8 to
5399925
Compare
| source_contents = [row['content'] for row in links_jsons] | ||
| # The stitched bundles are in the iteration order of a set, which | ||
| # varies between processes. | ||
| stitched.sort(key=itemgetter('links_id')) |
There was a problem hiding this comment.
This comment was written by Claude Code.
stitched is a new list, created by the unpacking above, so sorting it in place leaves the caller's list untouched and has the same effect as sorted(). The file uses .sort() for a list it owns (rows.sort(key=itemgetter(pk_column)) in _emulate_bundle) and sorted() for an iterable (sorted(iter_rows, key=key) in _query_unique_sorted).
7c28fc8 to
54f6951
Compare
The `stitched` attribute of a canned HCA bundle is a set of the UUIDs of the entities that were stitched into that bundle. The canned TDR HCA bundle 4426adc5 also listed, for each stitched file, the UUID of that file's manifest entry. The plugin only ever adds an entity's own UUID, so the canner cannot have produced those six surplus entries. They were inert, because `Bundle.not_stitched` matches the set against each entity's `document_id`, which a manifest entry UUID never equals. The surplus went unnoticed because `_test_fetch_bundle` compared every other attribute of a canned bundle against that of the emulated one, but not `stitched`. It now does. The canned DSS bundles carry the same surplus, tracked in #8423. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The comment stated that the manifest and the metadata of a bundle are both sorted by entity UUID. The assertions below it compare dictionaries, which are equal regardless of the order of their entries, so nothing verified that claim. The claim was inaccurate, too. The entries are grouped by entity type and only sorted by UUID within such a group. The order of the groups is that of a set's iteration. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A plugin groups those entries by entity type, in the iteration order of a set, which varies with Python's hash seed. Canning one bundle twice could therefore yield two files that differ only in the order of their entries. The canner now sorts both by entity reference. The entries of the canned TDR HCA bundles are reordered accordingly. They are otherwise unchanged, and so are the other attributes of those bundles. Only the canned file is normalized. The order of the entries of a bundle in memory still varies between processes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The canned bundles of `test_subgraph_stitching` formed a chain, so the plugin retrieved them one at a time, in the order the chain dictated. The order of the merged links only varies when one batch holds more than one bundle, a shape that fixture could not produce. The root bundle now consumes a second file, produced by a new bundle whose own input is a cell suspension rather than a file. That bundle is therefore self-contained, and the traversal retrieves it together with the first upstream bundle, in one batch. A batch is a set, whose iteration order varies between processes, so this test now fails in roughly half of all runs, until the commit that merges the links in a deterministic order. The new bundle, its process and the file it produces are synthetic. All other entities they reference already exist in the canned tables. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The stitched bundles of one batch are the elements of a set, so the order in which the plugin emits them, and with it the order of the merged links, varies between processes. The preceding commit made the fixture produce such a batch, but a single run of the test still covers only whichever order that process happens to produce. The new test merges the links of the stitched bundles in every permutation and expects the result of the canned bundle each time. It fails until the next commit, which merges them in a deterministic order. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The TDR HCA plugin merged the links in the order in which it retrieved the stitched bundles. That is the iteration order of a set and differs between indexer invocations, so every partition of a stitched bundle could produce a links replica with a different content hash. In prod, one bundle has 101 replicas that differ only in the order of their links. The links of the root bundle now come first, followed by those of the other bundles in the order of their UUID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A test used to drop the tables it had created, so that the next test of the class could create them again in the same emulator. Dropping them grew more expensive the longer that emulator had been in use, from 4.7s in the first test of a class to 11.6s in the fifth, and dominated the run time of both affected test classes. A test now gets an emulator of its own and discards it afterwards. Launching one costs 0.3s and makes dropping the tables unnecessary. Running test_tdr and test_anvil together takes 59s instead of 142s, for the same 29 tests. Replacing the nineteen table deletions with a single deletion of the dataset was tried first. That deletion degrades just like the ones it replaces, so it saved only 12%. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
dc5a004 to
43bf9f7
Compare
|
(Posted by Claude Code) Security design review
Every box is checked: this PR affects none of the listed categories, and no vulnerability was identified. The notes below are informational, recording what was examined in reaching that conclusion. Informational: the change to Informational: replica coordinates comprise entity type, entity ID and content hash, and a replica carries its bundle's source. Collapsing the duplicate Informational: the six UUIDs removed from the canned bundle's Informational: the new fixture rows are synthetic, reference the mock source Informational: the BigQuery emulator container is now created per test rather than per test class, and killed in |
Generated with Claude Code
Linked issues: #8393, #8259, #8294
Author
A01PR is assigned to the authorA02Status of PR is In progressA03PR is a draftA04Target branch isdevelopA05Name of PR branch matchesissues/<GitHub handle of author>/<issue#>-<slug>A06PR is linked to all issues it (partially) resolvesA07Status of linked issues is In progressA08PR description links to linked issuesA09PR title matches1 that of a linked issue or comment in PR explains why they're differentA10PR title references all linked issuesA11N/AFor each linked issue, there is at least one commit whose title references that issueResolved as freebees.1 when the issue title describes a problem, the corresponding PR
title is
Fix:followed by the issue titleAuthor (partiality)
B01Addedptag to titles of partial commitsB02This PR is labeledpartialor completely resolves all linked issuesB03This PR partially resolves each of the linked issues or does not have thepartiallabelAuthor (reindex)
C01Addedrtag to commit title or the changes introduced by this PR will not require reindexing of any deploymentC02This PR is labeledreindex:devor the changes introduced by it will not require reindexing ofdevC03This PR is labeledreindex:anvildevor the changes introduced by it will not require reindexing ofanvildevC04This PR is labeledreindex:anvilprodor the changes introduced by it will not require reindexing ofanvilprodC05This PR is labeledreindex:prodor the changes introduced by it will not require reindexing ofprodC06This PR is labeledreindex:partialand its description documents the specific reindexing procedure fordev,anvildev,anvilprodandprodor requires a full reindex or carries none of the labelsreindex:dev,reindex:anvildev,reindex:anvilprodandreindex:prodAuthor (mirror)
D01This PR is labeledmirror:devor the changes introduced by it will not require mirroring ofdevD02This PR is labeledmirror:anvildevor the changes introduced by it will not require mirroring ofanvildevD03This PR is labeledmirror:anvilprodor the changes introduced by it will not require mirroring ofanvilprodD04This PR is labeledmirror:prodor the changes introduced by it will not require mirroring ofprodD05This PR is labeledmirror:partialand its description documents the specific mirroring procedure fordev,anvildev,anvilprodandprodor requires a full mirroring or carries none of the labelsmirror:dev,mirror:anvildev,mirror:anvilprodandmirror:prodAuthor (API changes)
E01This PR and its linked issues are labeledAPIor this PR does not modify a REST APIE02Addeda(A) tag to commit title for backwards (in)compatible changes or this PR does not modify a REST APIE03Updated REST API version number inapp.pyor this PR does not modify a REST APIAuthor (upgrading deployments)
F01Ranmake docker_images.jsonand committed the resulting changes or this PR does not modifyazul_docker_images, or any other variables referenced in the definition of that variableF02Documented upgrading of deployments in UPGRADING.rst or this PR does not require upgrading deploymentsF03Addedutag to commit title or this PR does not require upgrading deploymentsF04This PR is labeledupgradeor does not require upgrading deploymentsF05This PR is labeleddeploy:sharedor does not modifydocker_images.json, and does not require deploying thesharedcomponent for any other reasonF06This PR is labeleddeploy:gitlabor does not require deploying thegitlabcomponentF07This PR is labeleddeploy:runneror does not require deploying therunnerimageAuthor (hotfixes)
G01AddedFtag to main commit title or this PR does not include permanent fix for a temporary hotfixG02Reverted the temporary hotfixes for any linked issues or the none of the stable branches (anvilprodandprod) have temporary hotfixes for any of the issues linked to this PRAuthor (before every review)
H01Rebased PR branch ondevelop, squashed fixups from prior reviewsH02Ranmake requirements_updateor this PR does not modifypyproject.tomlH03AddedRtag to commit title or this PR does not modifyuv.lockH04This PR is labeledreqsor does not modifyuv.lockH05make integration_testpasses in personal deployment or this PR does not modify functionality that could affect the IT outcomeH06PR is awaiting requested review from a peerH07Status of PR is Review requestedH08PR is assigned to only the peer and the authorPeer reviewer (after approval)
Note that after requesting changes, the PR must be assigned to only the author.
J01Actually approved the PRJ02PR is not a draftJ03PR is awaiting requested review from system administratorJ04Status of PR is Review requestedJ05PR is assigned to only the system administrator and the authorSystem administrator (after approval)
K01Actually approved the PRK02Labeled linked issues asdemoorno demoK03Commented on linked issues about demo expectations or all linked issues are labeledno demoK04Decided if PR can be labeledno sandboxK05A comment to this PR details the completed security design reviewK06PR title is appropriate as title of merge commitK07N reviewslabel is accurateK08Status of PR is ApprovedK09PR is assigned to only the operator and the authorOperator
L01Checkedreindex:…labels andrcommit title tagL02Checkedmirror:…labelsL03Checked that demo expectations are clear or all linked issues are labeledno demoL04Squashed PR branch and rebased ontodevelopL05Sanity-checked historyL06Pushed PR branch to GitHubOperator (deploy
.sharedand.gitlabcomponents)M01Ran_select dev.shared && CI_COMMIT_REF_NAME=develop make -C terraform/shared apply_keep_unusedor this PR is not labeleddeploy:sharedM02Ran_select dev.gitlab && CI_COMMIT_REF_NAME=develop make -C terraform/gitlab apply(an error from _login_docker_gitlab is benign if the instance was stopped for backup) or this PR is not labeleddeploy:gitlabM03Ran_select anvildev.shared && CI_COMMIT_REF_NAME=develop make -C terraform/shared apply_keep_unusedor this PR is not labeleddeploy:sharedM04Ran_select anvildev.gitlab && CI_COMMIT_REF_NAME=develop make -C terraform/gitlab apply(an error from _login_docker_gitlab is benign if the instance was stopped for backup) or this PR is not labeleddeploy:gitlabM05Checked the items in the next section or this PR is labeleddeploy:gitlabM06PR is assigned to only the system administrator and the author or this PR is not labeleddeploy:gitlabSystem administrator (post-deploy of
.gitlabcomponent)N01Background migrations fordev.gitlabare complete or this PR is not labeleddeploy:gitlabN02Background migrations foranvildev.gitlabare complete or this PR is not labeleddeploy:gitlabN03PR is assigned to only the operator and the authorOperator (deploy runner image)
P01Ran_select dev.gitlab && make -C terraform/gitlab/runneror this PR is not labeleddeploy:runnerP02Ran_select anvildev.gitlab && make -C terraform/gitlab/runneror this PR is not labeleddeploy:runnerOperator (sandbox build)
Q01Addedsandboxlabel or PR is labeledno sandboxQ02Pushed PR branch to GitLabdevor PR is labeledno sandboxQ03Pushed PR branch to GitLabanvildevor PR is labeledno sandboxQ04Build passes insandboxdeployment or PR is labeledno sandboxQ05Build passes inanvilboxdeployment or PR is labeledno sandboxQ06Reviewed build logs for anomalies insandboxdeployment or PR is labeledno sandboxQ07Reviewed build logs for anomalies inanvilboxdeployment or PR is labeledno sandboxQ08Applied upgrade instructions from UPGRADING.rst tosandboxor this PR is not labeledupgrade, or upgrade instructions do not apply tosandboxQ09Applied upgrade instructions from UPGRADING.rst toanvilboxor this PR is not labeledupgrade, or upgrade instructions do not apply toanvilboxQ10Insandbox, deleted the catalogs specified in the notes or this PR is missing either thereindex:partialor thereindex:devlabel, or bothQ11Inanvilbox, deleted the catalogs specified in the notes or this PR is missing either thereindex:partialor thereindex:anvildevlabel, or bothQ12Insandbox, deindexed the sources sepcified in the notes or this PR is missing either thereindex:partialor thereindex:devlabel, or bothQ13Inanvilbox, deindexed the sources sepcified in the notes or this PR is missing either thereindex:partialor thereindex:anvildevlabel, or bothQ14Insandbox, indexed the sources specified in the notes or this PR is missing either thereindex:partialor thereindex:devlabel, or bothQ15Inanvilbox, indexed the sources specified in the notes or this PR is missing either thereindex:partialor thereindex:anvildevlabel, or bothQ16Insandbox, indexed the catalogs specified in the notes or this PR is missing either thereindex:partialor thereindex:devlabel, or bothQ17Inanvilbox, indexed the catalogs specified in the notes or this PR is missing either thereindex:partialor thereindex:anvildevlabel, or bothQ18Started full reindex insandboxor this PR is not labeledreindex:devor it is labeled reindex:partialQ19Started full reindex inanvilboxor this PR is not labeledreindex:anvildevor it is labeled reindex:partialQ20Checked for failures insandboxor this PR is not labeledreindex:devQ21Checked for failures inanvilboxor this PR is not labeledreindex:anvildevQ22Started mirroring insandboxor this PR is not labeledmirror:devQ23Started mirroring inanvilboxor this PR is not labeledmirror:anvildevQ24Checked for failures insandboxor this PR is not labeledmirror:devQ25Checked for failures inanvilboxor this PR is not labeledmirror:anvildevOperator (merge the branch)
R01All status checks passed and the PR is mergeableR02The title of the merge commit starts with the title of this PRR03Added PR # reference to merge commit titleR04Collected commit title tags in merge commit title but only includedpif the PR is also labeledpartialR05Pushed merge commit to GitHubR06Status of PR is Merged lowerR07Status of blocked issues is Triage or no issues are blocked on the linked issuesOperator (main build)
S01Pushed merge commit to GitLabdevS02Pushed merge commit to GitLabanvildevS03Build passes on GitLabdevS04Reviewed build logs for anomalies on GitLabdevS05Build passes on GitLabanvildevS06Reviewed build logs for anomalies on GitLabanvildevS07Applied upgrade instructions from UPGRADING.rst todevor this PR is not labeledupgrade, or upgrade instructions do not apply todevS08Applied upgrade instructions from UPGRADING.rst toanvildevor this PR is not labeledupgrade, or upgrade instructions do not apply toanvildevS09Notified developers to apply upgrade instructions from UPGRADING.rst to their personal deployments or this PR is not labeledupgrade, or upgrade instructions do not apply to personal deploymentsS10Ran_select dev.shared && make -C terraform/shared applyor this PR is not labeleddeploy:sharedS11Ran_select anvildev.shared && make -C terraform/shared applyor this PR is not labeleddeploy:sharedS12Deleted PR branch from GitHubS13PR is assigned to only the operatorS14Deleted PR branch from GitLabdevS15Deleted PR branch from GitLabanvildevS16Status of linked issues is Lower, or Triage, if PR is partialOperator (reindex)
T01Indev, deleted the catalogs specified in the notes or this PR is missing either thereindex:partialor thereindex:devlabel, or bothT02Inanvildev, deleted the catalogs specified in the notes or this PR is missing either thereindex:partialor thereindex:anvildevlabel, or bothT03Indev, deindexed the sources sepcified in the notes or this PR is missing either thereindex:partialor thereindex:devlabel, or bothT04Inanvildev, deindexed the sources sepcified in the notes or this PR is missing either thereindex:partialor thereindex:anvildevlabel, or bothT05Indev, indexed the sources specified in the notes or this PR is missing either thereindex:partialor thereindex:devlabel, or bothT06Inanvildev, indexed the sources specified in the notes or this PR is missing either thereindex:partialor thereindex:anvildevlabel, or bothT07Indev, indexed the catalogs specified in the notes or this PR is missing either thereindex:partialor thereindex:devlabel, or bothT08Inanvildev, indexed the catalogs specified in the notes or this PR is missing either thereindex:partialor thereindex:anvildevlabel, or bothT09Started full reindex indevor this PR is not labeledreindex:devor it is labeled reindex:partialT10Started full reindex inanvildevor this PR is not labeledreindex:anvildevor it is labeled reindex:partialT11Checked for, triaged and possibly requeued messages in both fail queues indevor this PR is not labeledreindex:devor it is labeled reindex:partialT12Checked for, triaged and possibly requeued messages in both fail queues inanvildevor this PR is not labeledreindex:anvildevor it is labeled reindex:partialT13Emptied fail queues indevor this PR is not labeledreindex:devor it is labeled reindex:partialT14Emptied fail queues inanvildevor this PR is not labeledreindex:anvildevor it is labeled reindex:partialT15Restarted the Data Browser pipeline for the ucsc/hca/dev branch on GitLab indev, and it succeeded or this PR is not labeledreindex:devT16N/ARestarted the Data Browser pipeline for the ucsc/lungmap/dev branch on GitLab inor this PR is not labeleddev, and it succeededreindex:devT17Restarteddeploy_browserjob in the GitLab pipeline for this PR indev, and it succeeded or this PR is not labeledreindex:devT18Restarted the Data Browser pipeline for the ucsc/anvil/anvildev branch on GitLab inanvildev, and it succeeded or this PR is not labeledreindex:anvildevT19Restarteddeploy_browserjob in the GitLab pipeline for this PR inanvildev, and it succeeded or this PR is not labeledreindex:anvildevOperator (mirroring)
U01Started mirroring indevor this PR is not labelledmirror:devU02Started mirroring inanvildevor this PR is not labelledmirror:anvildevU03Checked for, triaged and possibly requeued messages in mirror fail queue indevor this PR is not labelledmirror:devU04Checked for, triaged and possibly requeued messages in mirror fail queue inanvildevor this PR is not labelledmirror:anvildevU05Emptied mirror fail queue indevor this PR is not labelledmirror:devU06Emptied mirror fail queue inanvildevor this PR is not labelledmirror:anvildevOperator
V01Propagated theupgrade,API,deploy:shared,deploy:gitlab,deploy:runner,reindex:partial,reindex:anvilprod,reindex:prod,mirror:partial,mirror:anvilprodandmirror:prodlabels to any open promotion PRs or this PR carries none of these labels, or is not included in an open promotion PRV02Propagated any specific instructions related to those labels, from the description of this PR to that of any open promotion PRs or this PR carries none of those labels, or is not included in an open promotion PRV03PR is assigned to no oneShorthand for review comments
Lline is too longWline wrapping is wrongQbad quotesFother formatting problem