Skip to content

Commit

Permalink
fixup! functionality to ignore multiple dirtyprop from same source
Browse files Browse the repository at this point in the history
make sure later dirtyprops with lower mod_times do not modify op
  • Loading branch information
k-dominik committed Apr 25, 2023
1 parent 722f35c commit 9034a34
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lazyflow/slot.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,9 @@ def setDirty(self, *args, _mod_time: int = None, **kwargs):
try:
self.operator.propagateDirty(self.top_level_slot, self.subindex, roi)
finally:
self.operator._previous_dirty_mod_time_buffer = self.operator._pending_dirty_mod_time
self.operator._previous_dirty_mod_time_buffer = max(
self.operator._previous_dirty_mod_time_buffer, self.operator._pending_dirty_mod_time
)
self.operator._pending_dirty_mod_time = -1

def __iter__(self):
Expand Down
15 changes: 15 additions & 0 deletions tests/test_lazyflow/test_graph/test_dirty_modtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ def test_op_mod_time(graph):
assert op._pending_dirty_mod_time == -1


def test_op_lower_mod_time_does_not_modify(graph):
"""setDirty _mod_time modifies parent op correctly"""
op = MockOp(graph=graph)

assert op._pending_dirty_mod_time == -1

op.Input.setDirty((), _mod_time=42)
assert op._previous_dirty_mod_time_buffer == 42
assert op._pending_dirty_mod_time == -1

op.Input.setDirty((), _mod_time=41)
assert op._previous_dirty_mod_time_buffer == 42
assert op._pending_dirty_mod_time == -1


def test_op_mod_time_chain(graph):
"""mod_time is propagated to all ops in the chain"""
op1 = MockOp(graph=graph)
Expand Down

0 comments on commit 9034a34

Please sign in to comment.