File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -566,7 +566,27 @@ class PythonOutputs(TaskOutputs):
566566
567567
568568class PythonDef (TaskDef [PythonOutputsType ]):
569- pass
569+
570+ def _run (self , environment = None ):
571+ inputs = attrs_values (self )
572+ del inputs ["function" ]
573+ self .output_ = None
574+ output = self .function (** inputs )
575+ output_names = [f .name for f in attrs .fields (self .Outputs )]
576+ if output is None :
577+ self .output_ = {nm : None for nm in output_names }
578+ elif len (output_names ) == 1 :
579+ # if only one element in the fields, everything should be returned together
580+ self .output_ = {output_names [0 ]: output }
581+ elif isinstance (output , tuple ) and len (output_names ) == len (output ):
582+ self .output_ = dict (zip (output_names , output ))
583+ elif isinstance (output , dict ):
584+ self .output_ = {key : output .get (key , None ) for key in output_names }
585+ else :
586+ raise RuntimeError (
587+ f"expected { len (list_fields (self .Outputs ))} elements, "
588+ f"but { output } were returned"
589+ )
570590
571591
572592class WorkflowOutputs (TaskOutputs ):
You can’t perform that action at this time.
0 commit comments