Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(task): if finish task output is None, it should not be processed #155

Merged
merged 2 commits into from
Aug 6, 2021
Merged
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
15 changes: 15 additions & 0 deletions draco/core/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,11 @@ def finish(self):

output = self.process_finish()

# Return immediately if output is None to skip writing phase.
if output is None:
self.log.info(f"Leaving finish for task {class_name}")
return None

output = self._process_output(output)

self.log.info(f"Leaving finish for task {class_name}")
Expand All @@ -364,6 +369,11 @@ def finish(self):

def _process_output(self, output, input_tag=None):

if not isinstance(output, memh5.MemDiskGroup):
raise pipeline.PipelineRuntimeError(
f"Task must output a valid memh5 container; given {type(output)}"
)

# Set the tag according to the format
output.attrs["tag"] = self.tag.format(
count=self._count, tag=output.attrs.get("tag", input_tag or self._count)
Expand Down Expand Up @@ -410,6 +420,11 @@ def _nan_process_output(self, output):
# Process the output to check for NaN's
# Returns the output or, None if it should be skipped

if not isinstance(output, memh5.MemDiskGroup):
raise pipeline.PipelineRuntimeError(
f"Task must output a valid memh5 container; given {type(output)}"
)

if self.nan_check:
nan_found = self._nan_check_walk(output)

Expand Down