-
Notifications
You must be signed in to change notification settings - Fork 7
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
Conversation
draco/core/task.py
Outdated
@@ -364,6 +369,10 @@ def finish(self): | |||
|
|||
def _process_output(self, output, input_tag=None): | |||
|
|||
# when output is None, there is nothing to write or check | |||
if output is None: | |||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think something more dramatic should happen here. This routine should only ever be called with a valid memh5 container, and so it's probably more appropriate to raise a specific exception than silently return None. Probably this test should be something more specific like not isinstance(output, memh5.MemDiskGroup)
(I am not entirely sure that's the appropriate class to test for).
The same is true of _nan_process_output
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used memh5.MemDiskGroup
and memh5.MemGroup
, but got this exception with the tests:
if not isinstance(output, memh5.MemDiskGroup) or not isinstance(
output, memh5.MemGroup
):
raise pipeline.PipelineRuntimeError(
> f"Task must output a valid memh5 container; given {type(output)}"
)
E caput.pipeline.PipelineRuntimeError: Task must output a valid memh5 container; given <class 'draco.core.containers.SiderealStream'>
Is the test realistically depicting the standard pipeline by returning a SiderealStream
container?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the test realistically depicting the standard pipeline by returning a
SiderealStream
container?
Yes.
The bug is in the boolean logic. You almost certainly want not (isinstance(output, memh5.MemDiskGroup) or isinstance(output, memh5.MemGroup)
or the more succinct not isinstance(output, (memh5.MemDiskgroup, memh5.MemGroup))
.
What you've written is equivalent to not (isinstance(output, MemDiskgroup) and isinstance(output, MemGroup))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Man, you are totally right, what was I doing, I was thinking in English.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH you probably don't want to check for MemGroup at least within the branch that deals with saving. Ultimately it calls output.save(...)
(within BasicContMixin.write_output
) and that only works on subclasses of MemDiskGroup
, but will fail if given a MemGroup
as it doesn't guarantee a save method exists.
e753419
to
5938eb8
Compare
- fixes bug where pipeline exceptions, if a task returns a None as a result to `.finish`
result to
.finish
I saw at least a few places where the pipeline would exception, if output was a
None
. In another part oftask.py
, theoutput
check is done before it is passed to_process_output
. I repeated that forfinish()
, but it also did not make sense to me for_process_output
to generally exception on aNone
. So I added the check there too.A
None
should be returned in these cases, because then_check_task_output
does the right thing: