@@ -898,12 +898,27 @@ def _from_task(cls, task: "Task[ShellDef]") -> Self:
898898 setattr (outputs , fld .name , None )
899899 else :
900900 raise ValueError (
901- f"file system path(s) provided to mandatory field { fld .name !r} ,"
902- f"{ resolved_value } , does not exist, this is likely due to an "
901+ f"file system path(s) provided to mandatory field { fld .name !r} , "
902+ f"' { resolved_value } ' , does not exist, this is likely due to an "
903903 f"error in the { task .name !r} task"
904904 )
905905 return outputs
906906
907+ # @classmethod
908+ # def _from_defaults(cls) -> Self:
909+ # """Create an output object from the default values of the fields"""
910+ # defaults = {}
911+ # for field in attrs_fields(cls):
912+ # if isinstance(field.default, attrs.Factory):
913+ # defaults[field.name] = field.default.factory()
914+ # elif TypeParser.contains_type(FileSet, field.type):
915+ # # Will be set by the templating code
916+ # defaults[field.name] = attrs.NOTHING
917+ # else:
918+ # defaults[field.name] = field.default
919+
920+ # return cls(**defaults)
921+
907922 @classmethod
908923 def _resolve_default_value (cls , fld : shell .out , output_dir : Path ) -> ty .Any :
909924 """Resolve path and glob expr default values relative to the output dir"""
@@ -991,20 +1006,24 @@ def _resolve_value(
9911006 call_args_val [argnm ] = fld
9921007 elif argnm == "output_dir" :
9931008 call_args_val [argnm ] = task .output_dir
1009+ elif argnm == "executable" :
1010+ call_args_val [argnm ] = task .definition .executable
9941011 elif argnm == "inputs" :
9951012 call_args_val [argnm ] = task .inputs
9961013 elif argnm == "stdout" :
9971014 call_args_val [argnm ] = task .return_values ["stdout" ]
9981015 elif argnm == "stderr" :
9991016 call_args_val [argnm ] = task .return_values ["stderr" ]
1017+ elif argnm == "self" :
1018+ pass # If the callable is a class
10001019 else :
10011020 try :
10021021 call_args_val [argnm ] = task .inputs [argnm ]
10031022 except KeyError as e :
10041023 e .add_note (
1005- f"arguments of the callable function from { fld .name } "
1024+ f"arguments of the callable function from { fld .name !r } "
10061025 f"has to be in inputs or be field or output_dir, "
1007- f"but { argnm } is used"
1026+ f"but { argnm !r } is used"
10081027 )
10091028 raise
10101029 return callable_ (** call_args_val )
@@ -1040,7 +1059,7 @@ def cmdline(self) -> str:
10401059 the current working directory."""
10411060 # Skip the executable, which can be a multi-part command, e.g. 'docker run'.
10421061 values = attrs_values (self )
1043- values .update (template_update (self ))
1062+ values .update (template_update (self , output_dir = Path . cwd () ))
10441063 cmd_args = self ._command_args (values = values )
10451064 cmdline = cmd_args [0 ]
10461065 for arg in cmd_args [1 :]:
@@ -1221,22 +1240,6 @@ def _format_arg(self, field: shell.arg, values: dict[str, ty.Any]) -> list[str]:
12211240 cmd_el_str = ""
12221241 return split_cmd (cmd_el_str )
12231242
1224- def _generated_output_names (self , stdout : str , stderr : str ):
1225- """Returns a list of all outputs that will be generated by the task.
1226- Takes into account the task input and the requires list for the output fields.
1227- TODO: should be in all Output specs?
1228- """
1229- # checking the input (if all mandatory fields are provided, etc.)
1230- self ._check_rules ()
1231- output_names = ["return_code" , "stdout" , "stderr" ]
1232- for fld in list_fields (self ):
1233- # assuming that field should have either default or metadata, but not both
1234- if is_set (fld .default ):
1235- output_names .append (fld .name )
1236- elif is_set (self .Outputs ._resolve_output_value (fld , stdout , stderr )):
1237- output_names .append (fld .name )
1238- return output_names
1239-
12401243 def _rule_violations (self ) -> list [str ]:
12411244
12421245 errors = super ()._rule_violations ()
0 commit comments