Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions cellmap_flow/blockwise/blockwise_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,15 @@ def process_fn(self, block):
print(f"empty write roi: {write_roi}")
return

# Check if block is already processed before expensive inference computation
fill_value = getattr(self.output_arrays[0], 'fill_value', self.dtype(0))
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The fallback to self.dtype(0) assumes that zero represents unprocessed blocks, but this may not always be correct. Consider using a more explicit approach to determine the unprocessed state, or document this assumption clearly.

Copilot uses AI. Check for mistakes.
if not (self.output_arrays[0][write_roi] == fill_value).all():
Comment on lines +156 to +157
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic is inverted compared to the original check. The original code used if self.output_arrays[0][block.write_roi].any(): which returns early if any non-zero values exist. The new condition if not (self.output_arrays[0][write_roi] == fill_value).all(): also returns early when any values are not equal to fill_value, but this assumes fill_value represents 'unprocessed' state. If fill_value is 0 and processed blocks contain non-zero values, these conditions are equivalent. However, if fill_value is non-zero or processed blocks can contain the fill_value, this could cause incorrect behavior.

Suggested change
fill_value = getattr(self.output_arrays[0], 'fill_value', self.dtype(0))
if not (self.output_arrays[0][write_roi] == fill_value).all():
# Check if block is already processed before expensive inference computation
if self.output_arrays[0][write_roi].any():

Copilot uses AI. Check for mistakes.
return

chunk_data = self.inferencer.process_chunk(self.idi_raw, block.write_roi)

chunk_data = chunk_data.astype(self.dtype)

if self.output_arrays[0][block.write_roi].any():
return

for i, array in enumerate(self.output_arrays):

if chunk_data.shape == 3:
Expand Down Expand Up @@ -217,8 +219,8 @@ def run(self):
),
read_write_conflict=True,
fit="overhang",
max_retries=0,
timeout=None,
max_retries=2,
timeout=1800,
num_workers=self.workers,
)

Expand Down