File tree Expand file tree Collapse file tree 6 files changed +12
-12
lines changed
Expand file tree Collapse file tree 6 files changed +12
-12
lines changed Original file line number Diff line number Diff line change 340340 "source" : [
341341 " from pathlib import Path\n " ,
342342 " import tempfile\n " ,
343- " from pydra.utils import get_fields \n " ,
343+ " from pydra.utils import task_as_dict \n " ,
344344 " \n " ,
345345 " tmp_dir = Path(tempfile.mkdtemp())\n " ,
346346 " \n " ,
350350 " cp_file_with_size = ReloadedCpFileWithSize(in_file=a_file)\n " ,
351351 " outputs = cp_file_with_size(cache_root=tmp_dir / \" cache\" )\n " ,
352352 " \n " ,
353- " pprint(get_fields (outputs))"
353+ " pprint(task_as_dict (outputs))"
354354 ]
355355 }
356356 ],
Original file line number Diff line number Diff line change 22import inspect
33from typing import dataclass_transform
44import attrs
5- from pydra .utils .general import task_fields , get_fields
5+ from pydra .utils .general import task_fields , task_as_dict
66from pydra .compose import base
77from pydra .compose .base import (
88 ensure_field_objects ,
@@ -226,7 +226,7 @@ class PythonTask(base.Task[PythonOutputsType]):
226226
227227 def _run (self , job : "Job[PythonTask]" , rerun : bool = True ) -> None :
228228 # Prepare the inputs to the function
229- inputs = get_fields (self )
229+ inputs = task_as_dict (self )
230230 del inputs ["function" ]
231231 # Run the actual function
232232 returned = self .function (** inputs )
Original file line number Diff line number Diff line change 33from enum import Enum
44import attrs
55from pydra .engine import lazy
6- from pydra .utils .general import attrs_values , get_fields
6+ from pydra .utils .general import attrs_values , task_as_dict
77from pydra .utils .typing import is_lazy
88from pydra .engine .state import State , add_name_splitter , add_name_combiner
99
@@ -162,7 +162,7 @@ def combiner(self):
162162 def _check_if_outputs_have_been_used (self , msg ):
163163 used = []
164164 if self ._lzout :
165- for outpt_name , outpt_val in get_fields (self ._lzout ).items ():
165+ for outpt_name , outpt_val in task_as_dict (self ._lzout ).items ():
166166 if outpt_val ._type_checked :
167167 used .append (outpt_name )
168168 if used :
Original file line number Diff line number Diff line change 1919from pydra .engine .submitter import Submitter , NodeExecution
2020from pydra .utils .general import (
2121 attrs_values ,
22- get_fields ,
22+ task_as_dict ,
2323 task_fields ,
2424)
2525from pydra .utils .typing import is_lazy
@@ -147,7 +147,7 @@ def construct(
147147 constructor = input_values .pop ("constructor" )
148148 # Call the user defined constructor to set the outputs
149149 output_lazy_fields = constructor (** input_values )
150- if all (v is attrs .NOTHING for v in get_fields (outputs ).values ()):
150+ if all (v is attrs .NOTHING for v in task_as_dict (outputs ).values ()):
151151 if output_lazy_fields is None :
152152 raise ValueError (
153153 f"Constructor function for { task } returned None, must a lazy field "
@@ -160,7 +160,7 @@ def construct(
160160 "if any of the outputs are already set explicitly"
161161 )
162162 if unset_outputs := [
163- n for n , v in get_fields (outputs ).items () if v is attrs .NOTHING
163+ n for n , v in task_as_dict (outputs ).items () if v is attrs .NOTHING
164164 ]:
165165 raise ValueError (
166166 f"Mandatory outputs { unset_outputs } are not set by the "
Original file line number Diff line number Diff line change 11from .general import (
22 task_fields ,
3- get_fields ,
3+ task_as_dict ,
44 plot_workflow ,
55 show_workflow ,
66 task_help ,
1313__all__ = [
1414 "__version__" ,
1515 "task_fields" ,
16- "get_fields " ,
16+ "task_as_dict " ,
1717 "plot_workflow" ,
1818 "show_workflow" ,
1919 "task_help" ,
Original file line number Diff line number Diff line change @@ -352,7 +352,7 @@ def task_fields(task: "type[Task] | Task") -> _TaskFieldsList:
352352 )
353353
354354
355- def get_fields (obj , ** kwargs ) -> dict [str , ty .Any ]:
355+ def task_as_dict (obj , ** kwargs ) -> dict [str , ty .Any ]:
356356 """Get the values of an attrs object."""
357357 return {f .name : getattr (obj , f .name ) for f in task_fields (obj )}
358358
You can’t perform that action at this time.
0 commit comments