Skip to content

Commit 53cc36c

Browse files
committed
dropped fields_dict in favour of task_fields
1 parent b4687b6 commit 53cc36c

File tree

4 files changed

+6
-13
lines changed

4 files changed

+6
-13
lines changed

docs/source/tutorial/5-shell.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
"metadata": {},
163163
"outputs": [],
164164
"source": [
165-
"from pydra.utils import fields_dict\n",
165+
"from pydra.utils import task_fields\n",
166166
"\n",
167167
"Cp = shell.define(\n",
168168
" \"cp <in_fs_objects:fs-object+> <out|out_dir:directory> \"\n",
@@ -172,7 +172,7 @@
172172
" \"--tuple-arg <tuple_arg:int,str=(1,'bar')> \"\n",
173173
")\n",
174174
"\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}\")"
176176
]
177177
},
178178
{

pydra/engine/workflow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from pydra.engine.submitter import Submitter, NodeExecution
2020
from pydra.utils.general import (
2121
attrs_values,
22-
fields_values,
22+
task_dict,
2323
task_fields,
2424
)
2525
from 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 fields_values(outputs).values()):
150+
if all(v is attrs.NOTHING for v in task_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 fields_values(outputs).items() if v is attrs.NOTHING
163+
n for n, v in task_dict(outputs).items() if v is attrs.NOTHING
164164
]:
165165
raise ValueError(
166166
f"Mandatory outputs {unset_outputs} are not set by the "

pydra/utils/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from .general import (
22
task_fields,
3-
fields_dict,
43
plot_workflow,
54
show_workflow,
65
task_help,
@@ -15,5 +14,4 @@
1514
"show_workflow",
1615
"task_help",
1716
"print_help",
18-
"fields_dict",
1917
]

pydra/utils/general.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,16 +349,11 @@ def task_fields(task: "type[Task] | Task") -> _TaskFieldsList:
349349
)
350350

351351

352-
def fields_values(obj, **kwargs) -> dict[str, ty.Any]:
352+
def task_dict(obj, **kwargs) -> dict[str, ty.Any]:
353353
"""Get the values of an attrs object."""
354354
return {f.name: getattr(obj, f.name) for f in task_fields(obj)}
355355

356356

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-
362357
def from_list_if_single(obj: ty.Any) -> ty.Any:
363358
"""Converts a list to a single item if it is of length == 1"""
364359
from pydra.utils.typing import is_lazy

0 commit comments

Comments
 (0)