File tree Expand file tree Collapse file tree 4 files changed +6
-13
lines changed Expand file tree Collapse file tree 4 files changed +6
-13
lines changed Original file line number Diff line number Diff line change 162
162
"metadata" : {},
163
163
"outputs" : [],
164
164
"source" : [
165
- " from pydra.utils import fields_dict \n " ,
165
+ " from pydra.utils import task_fields \n " ,
166
166
" \n " ,
167
167
" Cp = shell.define(\n " ,
168
168
" \" cp <in_fs_objects:fs-object+> <out|out_dir:directory> \"\n " ,
172
172
" \" --tuple-arg <tuple_arg:int,str=(1,'bar')> \"\n " ,
173
173
" )\n " ,
174
174
" \n " ,
175
- " print(f\" '--int-arg' default: {fields_dict (Cp)[' int_arg'] .default}\" )"
175
+ " print(f\" '--int-arg' default: {task_fields (Cp). int_arg.default}\" )"
176
176
]
177
177
},
178
178
{
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
- fields_values ,
22
+ task_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 fields_values (outputs ).values ()):
150
+ if all (v is attrs .NOTHING for v in task_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 fields_values (outputs ).items () if v is attrs .NOTHING
163
+ n for n , v in task_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
- fields_dict ,
4
3
plot_workflow ,
5
4
show_workflow ,
6
5
task_help ,
15
14
"show_workflow" ,
16
15
"task_help" ,
17
16
"print_help" ,
18
- "fields_dict" ,
19
17
]
Original file line number Diff line number Diff line change @@ -349,16 +349,11 @@ def task_fields(task: "type[Task] | Task") -> _TaskFieldsList:
349
349
)
350
350
351
351
352
- def fields_values (obj , ** kwargs ) -> dict [str , ty .Any ]:
352
+ def task_dict (obj , ** kwargs ) -> dict [str , ty .Any ]:
353
353
"""Get the values of an attrs object."""
354
354
return {f .name : getattr (obj , f .name ) for f in task_fields (obj )}
355
355
356
356
357
- def fields_dict (task : "type[Task] | Task" ) -> dict [str , "Field" ]:
358
- """Returns the fields of a task in a dictionary"""
359
- return {f .name : f for f in task_fields (task )}
360
-
361
-
362
357
def from_list_if_single (obj : ty .Any ) -> ty .Any :
363
358
"""Converts a list to a single item if it is of length == 1"""
364
359
from pydra .utils .typing import is_lazy
You can’t perform that action at this time.
0 commit comments