Skip to content

Commit 539ad26

Browse files
committed
Cleanly delete temporary files.
- Addresses Backproject errors during pipeline due to permissions error. #9 - Now cleans out all memory maps to allow deletion of temporary files. - Also (silently, for now) leaves temporary files there if they can't be deleted. May figure out good approach to log that doesn't clog up the progress bar in future. This should allow the backproject pipeline to successfully write single files and MIPs, though I haven't tested that.
1 parent b2d5478 commit 539ad26

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

python/ouroboros/pipeline/backproject_pipeline.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -328,17 +328,14 @@ def _process(self, input_data: any) -> tuple[any, None] | tuple[None, any]:
328328
# Update the progress bar
329329
self.update_progress(0.5 + i / len(chunks_and_boxes) / 2)
330330

331-
# Close all the memmaps
332-
for volume_memmap in volume_memmaps:
333-
del volume_memmap
331+
# Close all the memmaps - All 3 needed to allow deletion of temporary files.
332+
del volume # Delete volume view created during .tif file writing.
333+
del intersection_volume # Delete volume view created during .tif file writing.
334+
del volume_memmaps[:] # Delete all the memmaps.
334335

335-
# Delete the temporary volume files
336-
shutil.rmtree(
337-
join_path(
338-
config.output_file_folder,
339-
format_backproject_tempvolumes(config.output_file_name),
340-
)
341-
)
336+
# Delete the temporary volume files.
337+
# Errors ignored because leaving a temporary file around is better than failing. Could add logging.
338+
shutil.rmtree(temp_folder_path, ignore_errors=True)
342339

343340
self.add_timing("export", time.perf_counter() - start)
344341

@@ -365,7 +362,7 @@ def _process(self, input_data: any) -> tuple[any, None] | tuple[None, any]:
365362
delete_intermediate=False,
366363
compression=config.backprojection_compression,
367364
metadata=metadata,
368-
resolution=resolution, # XY Resolution
365+
resolution=resolution, # XY Resolution
369366
resolutionunit=resolutionunit,
370367
)
371368
except BaseException as e:

0 commit comments

Comments
 (0)