Skip to content

Commit

Permalink
feat: log operation_id in errors
Browse files Browse the repository at this point in the history
  • Loading branch information
akhileshh committed Sep 12, 2023
1 parent 7f412e0 commit 9a56813
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions pychunkedgraph/graph/edits.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ def add_edges(

def _process_l2_agglomeration(
cg,
operation_id: int,
agg: types.Agglomeration,
removed_edges: np.ndarray,
parent_ts: datetime.datetime = None,
Expand All @@ -318,7 +319,8 @@ def _process_l2_agglomeration(

cross_edges = agg.cross_edges.get_pairs()
parents = cg.get_parents(cross_edges[:, 0], time_stamp=parent_ts, raw_only=True)
assert np.unique(parents).size == 1, "got cross edges from more than one l2 node"
err = f"got cross edges from more than one l2 node; op {operation_id}"
assert np.unique(parents).size == 1, err
root = cg.get_root(parents[0], time_stamp=parent_ts, raw_only=True)

# inactive edges must be filtered out
Expand Down Expand Up @@ -381,7 +383,7 @@ def remove_edges(
for id_ in l2ids:
agg = l2id_agglomeration_d[id_]
ccs, graph_ids, cross_edges = _process_l2_agglomeration(
cg, agg, removed_edges, parent_ts
cg, operation_id, agg, removed_edges, parent_ts
)
new_parents = cg.id_client.create_node_ids(chunk_id_map[agg.node_id], len(ccs))

Expand Down Expand Up @@ -429,6 +431,7 @@ def remove_edges(
parent_ts=parent_ts,
)
new_roots = create_parents.run()
raise RuntimeError("haha")
create_parents.create_new_entries()
return new_roots, new_l2_ids, updated_entries + create_parents.new_entries

Expand Down Expand Up @@ -575,7 +578,8 @@ def _create_new_parents(self, layer: int):
mask = np.isin(cc_ids, all_old_ids)
old_ids = cc_ids[mask]
new_ids = _get_flipped_ids(self._old_new_id_d, cc_ids[mask])
assert np.all(~mask), f"got old ids {old_ids} -> {new_ids}"
err = f"got old ids {old_ids} -> {new_ids}; op {self._operation_id}"
assert np.all(~mask), err
if len(cc_ids) == 1:
# skip connection
parent_layer = self.cg.meta.layer_count
Expand Down Expand Up @@ -634,7 +638,8 @@ def _update_root_id_lineage(self):
former_roots = _get_flipped_ids(self._new_old_id_d, new_roots)
former_roots = np.unique(former_roots)

assert len(former_roots) < 2 or len(new_roots) < 2, "new roots are inconsistent"
err = f"new roots are inconsistent; op {self._operation_id}"
assert len(former_roots) < 2 or len(new_roots) < 2, err
for new_root_id in new_roots:
val_dict = {
attributes.Hierarchy.FormerParent: former_roots,
Expand Down Expand Up @@ -684,9 +689,10 @@ def create_new_entries(self) -> List:
for id_ in new_ids:
val_dict = val_dicts.get(id_, {})
children = self.cg.get_children(id_)
err = f"parent layer less than children; op {self._operation_id}"
assert np.max(
self.cg.get_chunk_layers(children)
) < self.cg.get_chunk_layer(id_), "Parent layer less than children."
) < self.cg.get_chunk_layer(id_), err
val_dict[attributes.Hierarchy.Child] = children
self.new_entries.append(
self.cg.client.mutate_row(
Expand Down

0 comments on commit 9a56813

Please sign in to comment.