Skip to content

Batch handling of events#270

Draft
yfukai wants to merge 1 commit intoroyerlab:mainfrom
yfukai:batch_call_events
Draft

Batch handling of events#270
yfukai wants to merge 1 commit intoroyerlab:mainfrom
yfukai:batch_call_events

Conversation

@yfukai
Copy link
Contributor

@yfukai yfukai commented Mar 9, 2026

This pull request refactors the node addition and update event emission logic throughout the graph codebase to support batched operations and simplify signal handling. The main change is the introduction and use of new utility functions (emit_node_added_events, emit_node_updated_events, iter_node_added_events, iter_node_updated_events) that standardize how node events are emitted and processed, allowing for more efficient handling of bulk node operations and improved callback interfaces. Extensive tests have been added to verify correct batched event emission.

Event emission refactoring:

  • Replaced manual signal emission loops with the new emit_node_added_events and emit_node_updated_events utility functions in bulk_add_nodes and update_node_attrs methods across GraphView, RustWorkXGraph, and SQLGraph, ensuring consistent and batched event emission. [1] [2] [3] [4] [5] [6] [7]
  • Updated imports to use new event emission and iteration utilities in relevant files. [1] [2] [3] [4] [5]

Callback interface and batch processing:

  • Refactored callback signatures and internal logic in GraphArray and spatial filter classes to process batched node addition and update events using iter_node_added_events and iter_node_updated_events, improving efficiency and correctness for bulk operations. [1] [2] [3] [4] [5] [6] [7]

Testing improvements:

  • Added new tests to verify that batched node addition and update operations emit a single callback containing all relevant node IDs and attributes, both for base graphs and subgraphs. [1] [2]

Minor fixes:

  • Ensured correct conversion of node ID sequences in update_node_attrs methods for consistency. [1] [2]

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 77.00000% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.10%. Comparing base (4ed06c1) to head (6871c05).

Files with missing lines Patch % Lines
src/tracksdata/utils/_signal.py 66.66% 11 Missing and 5 partials ⚠️
src/tracksdata/graph/filters/_spatial_filter.py 72.00% 4 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #270      +/-   ##
==========================================
- Coverage   87.34%   87.10%   -0.24%     
==========================================
  Files          56       56              
  Lines        4703     4740      +37     
  Branches      829      831       +2     
==========================================
+ Hits         4108     4129      +21     
- Misses        379      390      +11     
- Partials      216      221       +5     

☔ 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.

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