Skip to content

fix: include single-node skeletons in selective summary refresh - #10

Draft
afonsobspinto wants to merge 1 commit into
metacellfrom
feature/fix-single-node-selective-summary
Draft

afonsobspinto wants to merge 1 commit into
metacellfrom
feature/fix-single-node-selective-summary

Conversation

@afonsobspinto

Copy link
Copy Markdown
Member

Purpose

Draft for internal review before opening against upstream catmaid/CATMAID:dev. This fix is already included in feature/new-ingestion (PR #7). This PR isolates the shared CATMAID migration and its regression test; it contains no batch-importer or provenance changes.

Problem and resulting behavior

refresh_skeleton_summary_table_selectively() joins node metadata to cable lengths computed from parent-child pairs. A skeleton with only a root has no such pair, so the inner join omits it. Refreshing a selected singleton therefore cannot recreate its missing summary or correct an existing stale summary.

Normal interactive creation takes a different path: on_insert_treenode_update_summary_and_edges() handles a root by joining it to itself, creating a zero-length edge and a summary with one node. That is why creating a single-node skeleton already works while selective regeneration fails.

Operation Before After
Create a root through the normal API Summary has one node and zero cable length. Same.
Delete its derived summary, then selectively refresh that skeleton Summary remains missing. Summary is recreated with num_nodes=1, cable_length=0, and node-derived metadata.
Selectively refresh an existing incorrect singleton summary Stale values remain. Count, length and edit metadata are refreshed.

Changes

  • Migration 0126_fix_single_node_selective_summary replaces the cable-length inner join with a LEFT JOIN and uses COALESCE(len.cable_length, 0).
  • The reversible migration restores the exact prior function definition from immutable migration 0076; historical migrations are not edited.
  • A regression test exercises missing-summary creation and stale-summary updates for a singleton alongside a multi-node skeleton, and verifies an unrelated skeleton's summary remains unchanged.

Apply with python manage.py migrate. This changes the shared PostgreSQL function; it does not add a table or automatically regenerate every project's summaries.

Validation

The exact migration and regression test were previously validated on feature/new-ingestion: all 5 skeleton-summary tests passed on isolated PostgreSQL 16/PostGIS, and migration rollback/reapplication was verified.

For this isolated branch, Python syntax and git diff --check pass. A fresh database rerun is pending because the local Docker runtime is currently unavailable.

python manage.py test catmaid.tests.test_skeleton_summary_tables

The summary-test baseline, migration 0076, and dependency 0125 currently match upstream dev. After internal review, cherry-pick this single commit onto current upstream dev; adjust migration numbering/dependencies if upstream advances first.

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