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 340
340
"source" : [
341
341
" from pathlib import Path\n " ,
342
342
" import tempfile\n " ,
343
- " from pydra.utils import get_fields \n " ,
343
+ " from pydra.utils import task_as_dict \n " ,
344
344
" \n " ,
345
345
" tmp_dir = Path(tempfile.mkdtemp())\n " ,
346
346
" \n " ,
350
350
" cp_file_with_size = ReloadedCpFileWithSize(in_file=a_file)\n " ,
351
351
" outputs = cp_file_with_size(cache_root=tmp_dir / \" cache\" )\n " ,
352
352
" \n " ,
353
- " pprint(get_fields (outputs))"
353
+ " pprint(task_as_dict (outputs))"
354
354
]
355
355
}
356
356
],
Original file line number Diff line number Diff line change 2
2
import inspect
3
3
from typing import dataclass_transform
4
4
import attrs
5
- from pydra .utils .general import task_fields , get_fields
5
+ from pydra .utils .general import task_fields , task_as_dict
6
6
from pydra .compose import base
7
7
from pydra .compose .base import (
8
8
ensure_field_objects ,
@@ -226,7 +226,7 @@ class PythonTask(base.Task[PythonOutputsType]):
226
226
227
227
def _run (self , job : "Job[PythonTask]" , rerun : bool = True ) -> None :
228
228
# Prepare the inputs to the function
229
- inputs = get_fields (self )
229
+ inputs = task_as_dict (self )
230
230
del inputs ["function" ]
231
231
# Run the actual function
232
232
returned = self .function (** inputs )
Original file line number Diff line number Diff line change 3
3
from enum import Enum
4
4
import attrs
5
5
from 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
7
7
from pydra .utils .typing import is_lazy
8
8
from pydra .engine .state import State , add_name_splitter , add_name_combiner
9
9
@@ -162,7 +162,7 @@ def combiner(self):
162
162
def _check_if_outputs_have_been_used (self , msg ):
163
163
used = []
164
164
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 ():
166
166
if outpt_val ._type_checked :
167
167
used .append (outpt_name )
168
168
if used :
Original file line number Diff line number Diff line change 19
19
from pydra .engine .submitter import Submitter , NodeExecution
20
20
from pydra .utils .general import (
21
21
attrs_values ,
22
- get_fields ,
22
+ task_as_dict ,
23
23
task_fields ,
24
24
)
25
25
from pydra .utils .typing import is_lazy
@@ -147,7 +147,7 @@ def construct(
147
147
constructor = input_values .pop ("constructor" )
148
148
# Call the user defined constructor to set the outputs
149
149
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 ()):
151
151
if output_lazy_fields is None :
152
152
raise ValueError (
153
153
f"Constructor function for { task } returned None, must a lazy field "
@@ -160,7 +160,7 @@ def construct(
160
160
"if any of the outputs are already set explicitly"
161
161
)
162
162
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
164
164
]:
165
165
raise ValueError (
166
166
f"Mandatory outputs { unset_outputs } are not set by the "
Original file line number Diff line number Diff line change 1
1
from .general import (
2
2
task_fields ,
3
- get_fields ,
3
+ task_as_dict ,
4
4
plot_workflow ,
5
5
show_workflow ,
6
6
task_help ,
13
13
__all__ = [
14
14
"__version__" ,
15
15
"task_fields" ,
16
- "get_fields " ,
16
+ "task_as_dict " ,
17
17
"plot_workflow" ,
18
18
"show_workflow" ,
19
19
"task_help" ,
Original file line number Diff line number Diff line change @@ -352,7 +352,7 @@ def task_fields(task: "type[Task] | Task") -> _TaskFieldsList:
352
352
)
353
353
354
354
355
- def get_fields (obj , ** kwargs ) -> dict [str , ty .Any ]:
355
+ def task_as_dict (obj , ** kwargs ) -> dict [str , ty .Any ]:
356
356
"""Get the values of an attrs object."""
357
357
return {f .name : getattr (obj , f .name ) for f in task_fields (obj )}
358
358
You can’t perform that action at this time.
0 commit comments