55from functools import reduce
66import logging
77import multiprocessing as mp
8- from typing import Callable , Iterable
8+ from typing import Callable
99from datetime import datetime
1010from collections import defaultdict , deque
1111
1212import fastremap
1313import numpy as np
1414from tqdm import tqdm
15- from pychunkedgraph .graph import ChunkedGraph , cache as cache_utils
16- from pychunkedgraph .graph .attributes import Connectivity
15+ from pychunkedgraph .graph import attributes , ChunkedGraph , cache as cache_utils
1716from pychunkedgraph .graph .chunks .utils import chunks_overlapping_bbox , get_neighbors
1817from pychunkedgraph .graph .cutting_sv import (
1918 build_kdtrees_by_label ,
2019 pairwise_min_distance_two_sets ,
2120 split_supervoxel_helper ,
2221)
23- from pychunkedgraph .graph .attributes import Hierarchy , OperationLogs
2422from pychunkedgraph .graph .edges import Edges
2523from pychunkedgraph .graph .types import empty_2d
2624from pychunkedgraph .graph import basetypes
@@ -281,9 +279,9 @@ def _add_new_edges(cg: ChunkedGraph, edges_tuple: tuple, time_stamp: datetime =
281279 for chunk_id in np .unique (chunks ):
282280 val_dict = {}
283281 mask = chunks_arr [:, 0 ] == chunk_id
284- val_dict [Connectivity .SplitEdges ] = edges [mask ]
285- val_dict [Connectivity .Affinity ] = affinites [mask ]
286- val_dict [Connectivity .Area ] = areas [mask ]
282+ val_dict [attributes . Connectivity .SplitEdges ] = edges [mask ]
283+ val_dict [attributes . Connectivity .Affinity ] = affinites [mask ]
284+ val_dict [attributes . Connectivity .Area ] = areas [mask ]
287285 rows .append (
288286 cg .client .mutate_row (
289287 serializers .serialize_uint64 (chunk_id , fake_edges = True ),
@@ -396,13 +394,15 @@ def copy_parents_and_add_lineage(
396394 parents = set ()
397395 old_new_map = {k : list (v ) for k , v in old_new_map .items ()}
398396 parent_cells_map = cg .client .read_nodes (
399- node_ids = list (old_new_map .keys ()), properties = Hierarchy .Parent
397+ node_ids = list (old_new_map .keys ()), properties = attributes . Hierarchy .Parent
400398 )
401399 for old_id , new_ids in old_new_map .items ():
402400 for new_id in new_ids :
403401 val_dict = {
404- Hierarchy .FormerIdentity : np .array ([old_id ], dtype = basetypes .NODE_ID ),
405- OperationLogs .OperationID : operation_id ,
402+ attributes .Hierarchy .FormerIdentity : np .array (
403+ [old_id ], dtype = basetypes .NODE_ID
404+ ),
405+ attributes .OperationLogs .OperationID : operation_id ,
406406 }
407407 result .append (
408408 cg .client .mutate_row (serializers .serialize_uint64 (new_id ), val_dict )
@@ -413,17 +413,19 @@ def copy_parents_and_add_lineage(
413413 result .append (
414414 cg .client .mutate_row (
415415 serializers .serialize_uint64 (new_id ),
416- {Hierarchy .Parent : cell .value },
416+ {attributes . Hierarchy .Parent : cell .value },
417417 time_stamp = cell .timestamp ,
418418 )
419419 )
420- val_dict = {Hierarchy .NewIdentity : np .array (new_ids , dtype = basetypes .NODE_ID )}
420+ val_dict = {
421+ attributes .Hierarchy .NewIdentity : np .array (new_ids , dtype = basetypes .NODE_ID )
422+ }
421423 result .append (
422424 cg .client .mutate_row (serializers .serialize_uint64 (old_id ), val_dict )
423425 )
424426
425427 children_cells_map = cg .client .read_nodes (
426- node_ids = list (parents ), properties = Hierarchy .Child
428+ node_ids = list (parents ), properties = attributes . Hierarchy .Child
427429 )
428430 for parent , children_cells in children_cells_map .items ():
429431 assert len (children_cells ) == 1 , children_cells
@@ -437,7 +439,7 @@ def copy_parents_and_add_lineage(
437439 result .append (
438440 cg .client .mutate_row (
439441 serializers .serialize_uint64 (parent ),
440- {Hierarchy .Child : children },
442+ {attributes . Hierarchy .Child : children },
441443 time_stamp = cell .timestamp ,
442444 )
443445 )
0 commit comments