From d94fbbe9bc801e16a1ee32ea5836bac3189c46ce Mon Sep 17 00:00:00 2001 From: Akhilesh Halageri Date: Mon, 20 Oct 2025 22:43:19 +0000 Subject: [PATCH] feat: include old roots in pubsub info --- pychunkedgraph/app/segmentation/common.py | 1 + pychunkedgraph/graph/operation.py | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pychunkedgraph/app/segmentation/common.py b/pychunkedgraph/app/segmentation/common.py index 70642c9ce..3250248f2 100644 --- a/pychunkedgraph/app/segmentation/common.py +++ b/pychunkedgraph/app/segmentation/common.py @@ -334,6 +334,7 @@ def publish_edit( "operation_id": int(result.operation_id), "new_lvl2_ids": result.new_lvl2_ids.tolist(), "new_root_ids": result.new_root_ids.tolist(), + "old_root_ids": result.old_root_ids.tolist(), } exchange = os.getenv("PYCHUNKEDGRAPH_EDITS_EXCHANGE", "pychunkedgraph") diff --git a/pychunkedgraph/graph/operation.py b/pychunkedgraph/graph/operation.py index d0d0e172a..09acaa6a8 100644 --- a/pychunkedgraph/graph/operation.py +++ b/pychunkedgraph/graph/operation.py @@ -45,7 +45,9 @@ class GraphEditOperation(ABC): "parent_ts", "privileged_mode", ] - Result = namedtuple("Result", ["operation_id", "new_root_ids", "new_lvl2_ids"]) + Result = namedtuple( + "Result", ["operation_id", "new_root_ids", "new_lvl2_ids", "old_root_ids"] + ) def __init__( self, @@ -478,10 +480,19 @@ def execute( new_root_ids, new_lvl2_ids, affected_records, + root_ids, ) return result - def _write(self, lock, timestamp, new_root_ids, new_lvl2_ids, affected_records): + def _write( + self, + lock: locks.RootLock, + timestamp: datetime, + new_root_ids: np.ndarray, + new_lvl2_ids: np.ndarray, + affected_records: list, + old_root_ids: np.ndarray, + ): """Helper to persist changes after an edit.""" new_root_ids = np.array(new_root_ids, dtype=basetypes.NODE_ID) new_lvl2_ids = np.array(new_lvl2_ids, dtype=basetypes.NODE_ID) @@ -522,6 +533,7 @@ def _write(self, lock, timestamp, new_root_ids, new_lvl2_ids, affected_records): operation_id=lock.operation_id, new_root_ids=new_root_ids, new_lvl2_ids=new_lvl2_ids, + old_root_ids=old_root_ids, )