aedes_flytable_update(): selective write, NA root_duplicated, return changed rows - #11
Merged
Merged
Conversation
The change-detection diff runs across all read columns, but the update wrote back the whole changed row -- so any row flagged for a root_id, supervoxel_id or root_duplicated change also rewrote its status and point_xyz cells with identical values. Narrow the write payload to _id, root_id, supervoxel_id, root_duplicated so the human-curated status column (and point_xyz) is never touched by this function.
Unchecked checkbox cells read back as NA, so comparing the stored root_duplicated column against the freshly computed logical column flagged every not-duplicated row as changed (NA vs FALSE). Coerce the stored column NA->FALSE before diffing so only genuine transitions (->TRUE, or TRUE->FALSE) are written.
Backported from crantr's crant_seatable_update(): capture the narrowed update payload as `toupdate` and return it invisibly so callers (and dry runs) can inspect exactly which rows/cells would change. The serial_id block no longer early-returns FALSE, so the data frame is returned on every path.
Return an invisible list(updated=, serial_ids=) instead of just the main changed-rows data frame, so the separate serial_id write stream is no longer hidden from the return value. serial_ids is NULL unless serial ids were (or would be) assigned.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three related fixes to
aedes_flytable_update(), found while porting this function tocrantr(crant_seatable_update).1. Only write columns that can change
The change set is computed correctly (diffing across all read columns), but the write step pushed back the whole changed row. This function only ever changes
root_id,supervoxel_idandroot_duplicated;point_xyzandstatusare read (to resolve supervoxels / computegood_status) but never modified, yet were rewritten with identical values on every touched row — including the human-curatedstatuscolumn. Fix narrows the payload:intersect(..., names(updated))keeps theupdate_dups = FALSEpath correct (noroot_duplicatedthere).2. Treat NA
root_duplicatedas FALSE in the diffThe scheduled Python updater only ever sets
root_duplicatedtoTRUE, so unchecked rows read back asNA. DiffingNAagainst the freshly computed logical column flagged every not-duplicated row as changed. Coerce the stored columnNA -> FALSEbefore diffing:Only genuine transitions (
-> TRUE, orTRUE -> FALSE) are written.3. Return what would be written
Previously returned
invisible(TRUE)/invisible(FALSE). Now returns, invisibly, a list capturing both write streams so nothing is hidden:serial_idsisNULLunless serial ids were (or, underdry_run, would be) assigned — i.e.NULLin the defaultupdate.serial_ids = FALSEpath. Theserial_idblock no longer early-returns, so the list is returned on every path.Note: this changes the return contract (logical → list).
@returndoc and.Rdupdated. Scripted callers branching on a truthy/FALSEreturn should switch to e.g.nrow(res$updated) > 0.All internal-only; no signature changes.
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com