Skip to content

Commit 919be4e

Browse files
committed
renamed task_dict to task_as_dict and added to pydra.utils.__init__
1 parent 4b755ad commit 919be4e

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

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, task_dict
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,
@@ -236,7 +236,7 @@ class PythonTask(base.Task[PythonOutputsType]):
236236

237237
def _run(self, job: "Job[PythonTask]", rerun: bool = True) -> None:
238238
# Prepare the inputs to the function
239-
inputs = task_dict(self)
239+
inputs = task_as_dict(self)
240240
del inputs["function"]
241241
# Run the actual function
242242
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, task_dict
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 task_dict(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-
task_dict,
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 task_dict(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 task_dict(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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from .general import (
22
task_fields,
3+
task_as_dict,
34
plot_workflow,
45
show_workflow,
56
task_help,
@@ -12,6 +13,7 @@
1213
__all__ = [
1314
"__version__",
1415
"task_fields",
16+
"task_as_dict",
1517
"plot_workflow",
1618
"show_workflow",
1719
"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 task_dict(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)