Skip to content

Batch operation refactoring#297

Draft
yfukai wants to merge 1 commit into
royerlab:mainfrom
yfukai:batch_remove
Draft

Batch operation refactoring#297
yfukai wants to merge 1 commit into
royerlab:mainfrom
yfukai:batch_remove

Conversation

@yfukai
Copy link
Copy Markdown
Contributor

@yfukai yfukai commented May 29, 2026

Human summary

  • Adds batch_remove_*
  • Dropping duplicate codes by calling bulk_add_... inside add_...
  • Batch handling of events; replaces Batch handling of events #270

Copilot Summary

This pull request introduces bulk mutation operations and refactors node and edge addition/removal logic across the graph array and graph view classes. The changes improve efficiency, ensure atomic validation, and unify signal emission for both single and bulk operations. The most important updates are summarized below.

Bulk mutation API additions

  • Added bulk_remove_nodes and bulk_remove_edges methods to BaseGraph, RustWorkXGraph, and GraphView, enabling efficient removal of multiple nodes or edges at once with atomic validation and proper signal emission. [1] [2] [3] [4] [5]
  • Introduced low-level local mutation helpers (_bulk_add_nodes_local, _bulk_remove_nodes_local, _bulk_add_edges_local, _bulk_remove_edges_local) in RustWorkXGraph to centralize and optimize node/edge manipulation logic.

Signal emission and event handling improvements

  • Refactored signal emission for node addition and update to use new utility functions (emit_node_added_events, emit_node_updated_events), ensuring consistent and efficient signal handling for both single and bulk operations. [1] [2] [3] [4] [5]
  • Updated the GraphArray event handlers to support bulk node add/update events by iterating over event sequences, improving compatibility with the new bulk APIs. [1] [2]

Codebase and API consistency

  • Refactored single-node add/remove methods to internally use the new bulk primitives, reducing code duplication and ensuring consistent behavior. [1] [2] [3] [4]
  • Improved error handling in ID mapping logic to ensure user-facing errors are consistent between single and bulk operations.

@yfukai yfukai mentioned this pull request May 29, 2026
11 tasks
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.92308% with 81 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.55%. Comparing base (a4f7607) to head (0bfa2ec).

Files with missing lines Patch % Lines
src/tracksdata/graph/_graph_view.py 58.62% 13 Missing and 11 partials ⚠️
src/tracksdata/graph/_base_graph.py 8.33% 22 Missing ⚠️
src/tracksdata/utils/_signal.py 66.66% 11 Missing and 5 partials ⚠️
src/tracksdata/graph/_rustworkx_graph.py 93.10% 4 Missing and 4 partials ⚠️
src/tracksdata/graph/filters/_spatial_filter.py 72.00% 4 Missing and 3 partials ⚠️
src/tracksdata/graph/_sql_graph.py 94.11% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #297      +/-   ##
==========================================
- Coverage   87.75%   86.55%   -1.20%     
==========================================
  Files          57       57              
  Lines        4947     5131     +184     
  Branches      872      920      +48     
==========================================
+ Hits         4341     4441     +100     
- Misses        381      442      +61     
- Partials      225      248      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yfukai yfukai mentioned this pull request May 29, 2026
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.

2 participants