Skip to content

Commit 62b7ad2

Browse files
authored
Fix WorkUnit shard cleanup even when in-memory WorkUnit was filtered (#77)
1 parent 5df3743 commit 62b7ad2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/kbmod_wf/task_impls/kbmod_search.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ def run_search(self):
7474
wu = WorkUnit.from_sharded_fits(wu_filename, directory_containing_shards, lazy=False)
7575
self.logger.debug("Loaded work unit")
7676

77+
# We may filter out images for the in-memory WorkUnit later on in search, but we would
78+
# still like to cleanup shards for any filtered out images, hence we need to store the
79+
# original WorkUnit size.
80+
orig_wu_size = len(wu)
81+
7782
#! Seems odd that we extract, modify, and reset the config in the workunit.
7883
#! Can we just modify the config in the workunit directly?
7984
if self.search_config_filepath is not None:
@@ -114,7 +119,7 @@ def run_search(self):
114119
self.logger.warning(f"Failed to remove {self.input_wu_filepath}: {e}")
115120

116121
# Delete the individual shards for this WorkUnit, one existing for each image.
117-
for i in range(len(wu)):
122+
for i in range(orig_wu_size):
118123
shard_path = os.path.join(directory_containing_shards, f"{i}_{wu_filename}")
119124
try:
120125
os.remove(shard_path)

0 commit comments

Comments
 (0)