File tree Expand file tree Collapse file tree 2 files changed +27
-11
lines changed Expand file tree Collapse file tree 2 files changed +27
-11
lines changed Original file line number Diff line number Diff line change @@ -200,17 +200,20 @@ def _run_task(self):
200
200
self .output_ = None
201
201
output = cp .loads (self .inputs ._func )(** inputs )
202
202
output_names = [el [0 ] for el in self .output_spec .fields ]
203
- self .output_ = {}
204
- if len (output_names ) > 1 :
205
- if len (output_names ) == len (output ):
206
- self .output_ = dict (zip (output_names , output ))
203
+ if output is None :
204
+ self .output_ = dict ((nm , None ) for nm in output_names )
205
+ else :
206
+ if len (output_names ) == 1 :
207
+ # if only one element in the fields, everything should be returned together
208
+ self .output_ = {output_names [0 ]: output }
207
209
else :
208
- raise Exception (
209
- f"expected { len (self .output_spec .fields )} elements, "
210
- f"but { len (output )} were returned"
211
- )
212
- else : # if only one element in the fields, everything should be returned together
213
- self .output_ [output_names [0 ]] = output
210
+ if isinstance (output , tuple ) and len (output_names ) == len (output ):
211
+ self .output_ = dict (zip (output_names , output ))
212
+ else :
213
+ raise Exception (
214
+ f"expected { len (self .output_spec .fields )} elements, "
215
+ f"but { output } were returned"
216
+ )
214
217
215
218
216
219
class ShellCommandTask (TaskBase ):
Original file line number Diff line number Diff line change @@ -309,7 +309,7 @@ def raise_exception(c, d):
309
309
assert pytest .raises (Exception , bad_funk )
310
310
311
311
312
- def test_result_none ():
312
+ def test_result_none_1 ():
313
313
""" checking if None is properly returned as the result"""
314
314
315
315
@mark .task
@@ -321,6 +321,19 @@ def fun_none(x):
321
321
assert res .output .out is None
322
322
323
323
324
+ def test_result_none_2 ():
325
+ """ checking if None is properly set for all outputs """
326
+
327
+ @mark .task
328
+ def fun_none (x ) -> (ty .Any , ty .Any ):
329
+ return None
330
+
331
+ task = fun_none (name = "none" , x = 3 )
332
+ res = task ()
333
+ assert res .output .out1 is None
334
+ assert res .output .out2 is None
335
+
336
+
324
337
def test_audit_prov (tmpdir ):
325
338
@mark .task
326
339
def testfunc (a : int , b : float = 0.1 ) -> ty .NamedTuple ("Output" , [("out" , float )]):
You can’t perform that action at this time.
0 commit comments