Skip to content

Commit 7602066

Browse files
committed
Revert "renamed task_as_dict to get_fields"
This reverts commit 74a1976.
1 parent 3de7a22 commit 7602066

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

docs/source/tutorial/7-canonical-form.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@
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",
@@ -350,7 +350,7 @@
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
],

pydra/compose/python.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import inspect
33
from typing import dataclass_transform
44
import attrs
5-
from pydra.utils.general import task_fields, get_fields
5+
from pydra.utils.general import task_fields, task_as_dict
66
from pydra.compose import base
77
from 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)

pydra/engine/node.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from enum import Enum
44
import attrs
55
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
77
from pydra.utils.typing import is_lazy
88
from 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:

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-
get_fields,
22+
task_as_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 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 "

pydra/utils/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from .general import (
22
task_fields,
3-
get_fields,
3+
task_as_dict,
44
plot_workflow,
55
show_workflow,
66
task_help,
@@ -13,7 +13,7 @@
1313
__all__ = [
1414
"__version__",
1515
"task_fields",
16-
"get_fields",
16+
"task_as_dict",
1717
"plot_workflow",
1818
"show_workflow",
1919
"task_help",

pydra/utils/general.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)