Skip to content

Commit d27d653

Browse files
committed
fix(edits): use a valid timestamp when locks are overridden, instead of None; add fallback for get earliest ts
1 parent e45f5f8 commit d27d653

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

pychunkedgraph/graph/chunkedgraph.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,9 +1022,13 @@ def get_earliest_timestamp(self):
10221022
from datetime import timedelta
10231023

10241024
for op_id in range(100):
1025-
_, timestamp = self.client.read_log_entry(op_id)
1025+
_log, timestamp = self.client.read_log_entry(op_id)
10261026
if timestamp is not None:
10271027
return timestamp - timedelta(milliseconds=500)
1028+
if _log:
1029+
return self.client._read_byte_row(serializers.serialize_uint64(op_id))[
1030+
attributes.OperationLogs.Status
1031+
][-1].timestamp
10281032

10291033
def get_operation_ids(self, node_ids: typing.Sequence):
10301034
response = self.client.read_nodes(node_ids=node_ids)

pychunkedgraph/graph/operation.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from .cutting import run_multicut
3232
from .exceptions import PreconditionError
3333
from .exceptions import PostconditionError
34-
from .utils.generic import get_bounding_box as get_bbox
34+
from .utils.generic import get_bounding_box as get_bbox, get_valid_timestamp
3535
from ..logging.log_db import TimeIt
3636

3737

@@ -432,6 +432,8 @@ def execute(
432432
lock.locked_root_ids,
433433
np.array([lock.operation_id] * len(lock.locked_root_ids)),
434434
)
435+
if timestamp is None:
436+
timestamp = get_valid_timestamp(timestamp)
435437

436438
log_record_before_edit = self._create_log_record(
437439
operation_id=lock.operation_id,
@@ -865,7 +867,7 @@ def __init__(
865867
self.path_augment = path_augment
866868
self.disallow_isolating_cut = disallow_isolating_cut
867869
self.do_sanity_check = do_sanity_check
868-
if np.any(np.in1d(self.sink_ids, self.source_ids)):
870+
if np.any(np.isin(self.sink_ids, self.source_ids)):
869871
raise PreconditionError(
870872
"Supervoxels exist in both sink and source, "
871873
"try placing the points further apart."
@@ -914,8 +916,8 @@ def _apply(
914916
supervoxels = np.concatenate(
915917
[agg.supervoxels for agg in l2id_agglomeration_d.values()]
916918
)
917-
mask0 = np.in1d(edges.node_ids1, supervoxels)
918-
mask1 = np.in1d(edges.node_ids2, supervoxels)
919+
mask0 = np.isin(edges.node_ids1, supervoxels)
920+
mask1 = np.isin(edges.node_ids2, supervoxels)
919921
edges = edges[mask0 & mask1]
920922
if len(edges) == 0:
921923
raise PreconditionError("No local edges found.")

pychunkedgraph/graph/utils/generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def time_min():
9898

9999
def get_valid_timestamp(timestamp):
100100
if timestamp is None:
101-
timestamp = datetime.datetime.utcnow()
101+
timestamp = datetime.datetime.now(datetime.timezone.utc)
102102
if timestamp.tzinfo is None:
103103
timestamp = pytz.UTC.localize(timestamp)
104104
# Comply to resolution of BigTables TimeRange

0 commit comments

Comments
 (0)