-
Notifications
You must be signed in to change notification settings - Fork 4
Notifying GraphArrayView of updates #267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
c871ecc
153ca5a
4424166
1ff95fc
c09d934
26e9b01
38c075f
82cf59a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -815,6 +815,8 @@ def remove_node(self, node_id: int) -> None: | |||||||||||||||||||||
| node = session.query(self.Node).filter(self.Node.node_id == node_id).first() | ||||||||||||||||||||||
| if node is None: | ||||||||||||||||||||||
| raise ValueError(f"Node {node_id} does not exist in the graph.") | ||||||||||||||||||||||
| old_attrs = {key: getattr(node, key) for key in self.node_attr_keys()} | ||||||||||||||||||||||
| self.node_removed.emit(node_id, old_attrs) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if is_signal_on(self.node_removed): | ||||||||||||||||||||||
| old_attrs = {key: getattr(node, key) for key in self.node_attr_keys()} | ||||||||||||||||||||||
|
|
@@ -1830,6 +1832,14 @@ def update_node_attrs( | |||||||||||||||||||||
| old_attrs_by_id = {row[DEFAULT_ATTR_KEYS.NODE_ID]: row for row in old_df.rows(named=True)} | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| self._update_table(self.Node, node_ids, DEFAULT_ATTR_KEYS.NODE_ID, attrs) | ||||||||||||||||||||||
| new_df = self.filter(node_ids=updated_node_ids).node_attrs(attr_keys=[DEFAULT_ATTR_KEYS.NODE_ID, *attr_keys]) | ||||||||||||||||||||||
| new_attrs_by_id = { | ||||||||||||||||||||||
| row[DEFAULT_ATTR_KEYS.NODE_ID]: {key: row[key] for key in attr_keys} for row in new_df.rows(named=True) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+1836
to
+1838
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would this work?
Suggested change
Comment on lines
+1836
to
+1838
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
It seems polars has a function for this, rows_by_key I think I have this pattern in our codebase. I'll check later if they can all be refactored to use this. |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if is_signal_on(self.node_updated): | ||||||||||||||||||||||
| for node_id in updated_node_ids: | ||||||||||||||||||||||
| self.node_updated.emit(node_id, old_attrs_by_id[node_id], new_attrs_by_id[node_id]) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if is_signal_on(self.node_updated): | ||||||||||||||||||||||
| new_df = self.filter(node_ids=updated_node_ids).node_attrs( | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this work?