Skip to content

Commit db3cd4c

Browse files
committed
removed python output order attribute
1 parent dd606f8 commit db3cd4c

File tree

6 files changed

+27
-39
lines changed

6 files changed

+27
-39
lines changed

pydra/design/base.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,6 @@ class Out(Field):
267267
The converter for the field passed through to the attrs.field, by default it is None
268268
validator: callable | iterable[callable], optional
269269
The validator(s) for the field passed through to the attrs.field, by default it is None
270-
order : int
271-
The order of the output in the output list, allows for tuple unpacking of outputs
272270
"""
273271

274272
pass

pydra/design/python.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class out(Out):
8080
outputs
8181
"""
8282

83-
order: int = attrs.field(default=None)
83+
pass
8484

8585

8686
@dataclass_transform(
@@ -161,11 +161,6 @@ def make(wrapped: ty.Callable | type) -> PythonDef:
161161
name="function", type=ty.Callable, default=function
162162
)
163163

164-
# Set positions for outputs to allow for tuple unpacking
165-
output: out
166-
for i, output in enumerate(parsed_outputs.values()):
167-
output.order = i
168-
169164
defn = make_task_def(
170165
PythonDef,
171166
PythonOutputs,

pydra/design/shell.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ class out(Out):
125125
to the function), output_dir (task output_dir will be used), stdout, stderr
126126
(stdout and stderr of the task will be sent) inputs (entire inputs will be
127127
passed) or any input field name (a specific input field will be sent).
128-
order : int
129-
The order of the output in the output list, allows for tuple unpacking of outputs
130128
"""
131129

132130
callable: ty.Callable | None = None

pydra/design/tests/test_python.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def func(a: int) -> float:
2525
python.arg(name="a", type=int),
2626
python.arg(name="function", type=ty.Callable, default=func),
2727
]
28-
assert outputs == [python.out(name="out", type=float, order=0)]
28+
assert outputs == [python.out(name="out", type=float)]
2929
definition = SampleDef(a=1)
3030
outputs = definition()
3131
assert outputs.out == 2.0
@@ -48,7 +48,7 @@ def func(a: int, k: float = 2.0) -> float:
4848
python.arg(name="function", type=ty.Callable, default=func),
4949
python.arg(name="k", type=float, default=2.0),
5050
]
51-
assert outputs == [python.out(name="out", type=float, order=0)]
51+
assert outputs == [python.out(name="out", type=float)]
5252
assert SampleDef(a=1)().out == 2.0
5353
assert SampleDef(a=10, k=3.0)().out == 30.0
5454

@@ -72,7 +72,7 @@ def func(a: int) -> float:
7272
python.arg(name="function", type=ty.Callable, default=func),
7373
]
7474
assert outputs == [
75-
python.out(name="b", type=Decimal, help="the doubled output", order=0),
75+
python.out(name="b", type=Decimal, help="the doubled output"),
7676
]
7777
outputs = SampleDef.Outputs(b=Decimal(2.0))
7878
assert isinstance(outputs.b, Decimal)
@@ -96,7 +96,7 @@ def func(a: int) -> int:
9696
python.arg(name="a", type=float),
9797
python.arg(name="function", type=ty.Callable, default=func),
9898
]
99-
assert outputs == [python.out(name="b", type=float, order=0)]
99+
assert outputs == [python.out(name="b", type=float)]
100100
intf = SampleDef(a=1)
101101
assert isinstance(intf.a, float)
102102
outputs = SampleDef.Outputs(b=2.0)
@@ -122,8 +122,8 @@ def SampleDef(a: int, b: float) -> tuple[float, float]:
122122
),
123123
]
124124
assert outputs == [
125-
python.out(name="c", type=float, order=0),
126-
python.out(name="d", type=float, order=1),
125+
python.out(name="c", type=float),
126+
python.out(name="d", type=float),
127127
]
128128
assert attrs.fields(SampleDef).function.default.__name__ == "SampleDef"
129129
SampleDef.Outputs(c=1.0, d=2.0)
@@ -153,8 +153,8 @@ def SampleDef(a: int, b: float) -> tuple[float, float]:
153153
),
154154
]
155155
assert outputs == [
156-
python.out(name="c", type=float, help="Sum of a and b", order=0),
157-
python.out(name="d", type=float, help="product of a and b", order=1),
156+
python.out(name="c", type=float, help="Sum of a and b"),
157+
python.out(name="d", type=float, help="product of a and b"),
158158
]
159159
assert attrs.fields(SampleDef).function.default.__name__ == "SampleDef"
160160

@@ -187,8 +187,8 @@ def SampleDef(a: int, b: float) -> tuple[float, float]:
187187
),
188188
]
189189
assert outputs == [
190-
python.out(name="c", type=float, help="Sum of a and b", order=0),
191-
python.out(name="d", type=float, help="Product of a and b", order=1),
190+
python.out(name="c", type=float, help="Sum of a and b"),
191+
python.out(name="d", type=float, help="Product of a and b"),
192192
]
193193
assert attrs.fields(SampleDef).function.default.__name__ == "SampleDef"
194194

@@ -229,8 +229,8 @@ def SampleDef(a: int, b: float) -> tuple[float, float]:
229229
),
230230
]
231231
assert outputs == [
232-
python.out(name="c", type=float, help="Sum of a and b", order=0),
233-
python.out(name="d", type=float, help="Product of a and b", order=1),
232+
python.out(name="c", type=float, help="Sum of a and b"),
233+
python.out(name="d", type=float, help="Product of a and b"),
234234
]
235235
assert attrs.fields(SampleDef).function.default.__name__ == "SampleDef"
236236

@@ -276,8 +276,8 @@ def function(a, b):
276276
),
277277
]
278278
assert outputs == [
279-
python.out(name="c", type=float, help="Sum of a and b", order=0),
280-
python.out(name="d", type=float, help="Product of a and b", order=1),
279+
python.out(name="c", type=float, help="Sum of a and b"),
280+
python.out(name="d", type=float, help="Product of a and b"),
281281
]
282282
assert SampleDef.function.__name__ == "function"
283283
SampleDef(a=1)
@@ -346,8 +346,8 @@ def function(a, b):
346346
),
347347
]
348348
assert outputs == [
349-
python.out(name="c", type=float, help="Sum of a and b", order=0),
350-
python.out(name="d", type=float, help="Product of a and b", order=1),
349+
python.out(name="c", type=float, help="Sum of a and b"),
350+
python.out(name="d", type=float, help="Product of a and b"),
351351
]
352352
assert SampleDef.function.__name__ == "function"
353353
SampleDef(a=1, b=2.0)

pydra/engine/specs.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import re
55
from copy import copy
66
import os
7-
from operator import attrgetter
87
import inspect
98
import itertools
109
import platform
@@ -87,6 +86,10 @@ def _get_node(self):
8786
f"{self} outputs object is not a lazy output of a workflow node"
8887
) from None
8988

89+
def __iter__(self) -> list[str]:
90+
"""The names of the fields in the output object"""
91+
return sorted(f.name for f in attrs_fields(self))
92+
9093
def __getitem__(self, name_or_index: str | int) -> ty.Any:
9194
"""Return the value for the given attribute
9295
@@ -591,12 +594,6 @@ class RuntimeSpec:
591594

592595
class PythonOutputs(TaskOutputs):
593596

594-
def __iter__(self) -> ty.Generator[ty.Any, None, None]:
595-
"""Iterate through all the values in the definition, allows for tuple unpacking"""
596-
fields = sorted(attrs_fields(self), key=attrgetter("order"))
597-
for field in fields:
598-
yield getattr(self, field.name)
599-
600597
@classmethod
601598
def _from_task(cls, task: "Task[PythonDef]") -> Self:
602599
"""Collect the outputs of a task from a combination of the provided inputs,

pydra/engine/tests/test_functions.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def Indirect(a):
8989
assert non_func_values(Direct(a=a)) == non_func_values(Indirect(a=a))
9090

9191
# checking if the annotation is properly converted to output_spec if used in task
92-
assert list_fields(Direct.Outputs)[0] == python.out(name="out", type=int, order=0)
92+
assert list_fields(Direct.Outputs)[0] == python.out(name="out", type=int)
9393

9494

9595
def test_annotation_equivalence_2():
@@ -119,8 +119,8 @@ def Indirect(a) -> tuple[int, float]:
119119

120120
# checking if the annotation is properly converted to output_spec if used in task
121121
assert list_fields(Direct.Outputs) == [
122-
python.out(name="out1", type=int, order=0),
123-
python.out(name="out2", type=float, order=1),
122+
python.out(name="out1", type=int),
123+
python.out(name="out2", type=float),
124124
]
125125

126126

@@ -150,7 +150,7 @@ def Indirect(a):
150150
assert hashes(Direct(a=a)) == hashes(Partial(a=a)) == hashes(Indirect(a=a))
151151

152152
# checking if the annotation is properly converted to output_spec if used in task
153-
assert list_fields(Direct.Outputs)[0] == python.out(name="out1", type=int, order=0)
153+
assert list_fields(Direct.Outputs)[0] == python.out(name="out1", type=int)
154154

155155

156156
def test_annotation_equivalence_4():
@@ -186,8 +186,8 @@ def Indirect(a):
186186

187187
# checking if the annotation is properly converted to output_spec if used in task
188188
assert list_fields(Direct.Outputs) == [
189-
python.out(name="sum", type=int, order=0),
190-
python.out(name="sub", type=int, order=1),
189+
python.out(name="sum", type=int),
190+
python.out(name="sub", type=int),
191191
]
192192

193193

0 commit comments

Comments
 (0)