@@ -388,7 +388,8 @@ def make_task_def(
388388 klass : type
389389 The class created using the attrs package
390390 """
391- from pydra .engine .specs import TaskDef
391+ from pydra .engine .specs import TaskDef , WorkflowDef
392+ from pydra .engine .core import Task , WorkflowTask
392393
393394 spec_type ._check_arg_refs (inputs , outputs )
394395
@@ -399,6 +400,7 @@ def make_task_def(
399400 f"{ reserved_names } are reserved and cannot be used for { spec_type } field names"
400401 )
401402 outputs_klass = make_outputs_spec (out_type , outputs , outputs_bases , name )
403+ task_type = WorkflowTask if issubclass (spec_type , WorkflowDef ) else Task
402404 if klass is None or not issubclass (klass , spec_type ):
403405 if name is None :
404406 raise ValueError ("name must be provided if klass is not" )
@@ -417,13 +419,19 @@ def make_task_def(
417419 name = name ,
418420 bases = bases ,
419421 kwds = {},
420- exec_body = lambda ns : ns .update ({"Outputs" : outputs_klass }),
422+ exec_body = lambda ns : ns .update (
423+ {
424+ "Outputs" : outputs_klass ,
425+ "Task" : task_type ,
426+ }
427+ ),
421428 )
422429 else :
423430 # Ensure that the class has it's own annotations dict so we can modify it without
424431 # messing up other classes
425432 klass .__annotations__ = copy (klass .__annotations__ )
426433 klass .Outputs = outputs_klass
434+ klass .Task = task_type
427435 # Now that we have saved the attributes in lists to be
428436 for arg in inputs .values ():
429437 # If an outarg input then the field type should be Path not a FileSet
@@ -769,7 +777,11 @@ def extract_function_inputs_and_outputs(
769777 type_hints = ty .get_type_hints (function )
770778 input_types = {}
771779 input_defaults = {}
780+ has_varargs = False
772781 for p in sig .parameters .values ():
782+ if p .kind is p .VAR_POSITIONAL or p .kind is p .VAR_KEYWORD :
783+ has_varargs = True
784+ continue
773785 input_types [p .name ] = type_hints .get (p .name , ty .Any )
774786 if p .default is not inspect .Parameter .empty :
775787 input_defaults [p .name ] = p .default
@@ -779,11 +791,12 @@ def extract_function_inputs_and_outputs(
779791 f"Input names ({ inputs } ) should not be provided when "
780792 "wrapping/decorating a function as "
781793 )
782- if unrecognised := set (inputs ) - set (input_types ):
783- raise ValueError (
784- f"Unrecognised input names ({ unrecognised } ) not present in the signature "
785- f"of the function { function !r} "
786- )
794+ if not has_varargs :
795+ if unrecognised := set (inputs ) - set (input_types ):
796+ raise ValueError (
797+ f"Unrecognised input names ({ unrecognised } ) not present in the signature "
798+ f"of the function { function !r} "
799+ )
787800 for inpt_name , type_ in input_types .items ():
788801 try :
789802 inpt = inputs [inpt_name ]
0 commit comments