|
9 | 9 | }, |
10 | 10 | { |
11 | 11 | "cell_type": "code", |
12 | | - "execution_count": 5, |
| 12 | + "execution_count": 8, |
13 | 13 | "metadata": {}, |
14 | 14 | "outputs": [ |
15 | 15 | { |
|
44 | 44 | }, |
45 | 45 | { |
46 | 46 | "cell_type": "code", |
47 | | - "execution_count": 6, |
| 47 | + "execution_count": 9, |
48 | 48 | "metadata": {}, |
49 | 49 | "outputs": [], |
50 | 50 | "source": [ |
|
65 | 65 | }, |
66 | 66 | { |
67 | 67 | "cell_type": "code", |
68 | | - "execution_count": 8, |
| 68 | + "execution_count": 10, |
69 | 69 | "metadata": {}, |
70 | 70 | "outputs": [], |
71 | 71 | "source": [ |
|
113 | 113 | }, |
114 | 114 | { |
115 | 115 | "cell_type": "code", |
116 | | - "execution_count": 18, |
| 116 | + "execution_count": 12, |
117 | 117 | "metadata": {}, |
118 | 118 | "outputs": [ |
119 | 119 | { |
120 | 120 | "name": "stdout", |
121 | 121 | "output_type": "stream", |
122 | 122 | "text": [ |
123 | | - "[arg(name='a', type=<class 'int'>, default=EMPTY, help_string='First input to be inputted', requires=[], converter=None, validator=None, allowed_values=(), xor=(), copy_mode=<CopyMode.any: 15>, copy_collation=<CopyCollation.any: 0>, copy_ext_decomp=<ExtensionDecomposition.single: 1>, readonly=False),\n", |
124 | | - " arg(name='b', type=<class 'float'>, default=EMPTY, help_string='Second input', requires=[], converter=None, validator=None, allowed_values=(), xor=(), copy_mode=<CopyMode.any: 15>, copy_collation=<CopyCollation.any: 0>, copy_ext_decomp=<ExtensionDecomposition.single: 1>, readonly=False),\n", |
125 | | - " arg(name='function', type=typing.Callable, default=<function SampleSpec at 0x11ad1c900>, help_string='', requires=[], converter=None, validator=None, allowed_values=(), xor=(), copy_mode=<CopyMode.any: 15>, copy_collation=<CopyCollation.any: 0>, copy_ext_decomp=<ExtensionDecomposition.single: 1>, readonly=False)]\n", |
126 | | - "[out(name='c', type=<class 'float'>, default=EMPTY, help_string='Sum of a and b', requires=[], converter=None, validator=None),\n", |
127 | | - " out(name='d', type=<class 'float'>, default=EMPTY, help_string='Product of a and b', requires=[], converter=None, validator=None)]\n" |
| 123 | + "{'a': arg(name='a', type=<class 'int'>, default=EMPTY, help_string='First input to be inputted', requires=[], converter=None, validator=None, allowed_values=(), xor=(), copy_mode=<CopyMode.any: 15>, copy_collation=<CopyCollation.any: 0>, copy_ext_decomp=<ExtensionDecomposition.single: 1>, readonly=False),\n", |
| 124 | + " 'b': arg(name='b', type=<class 'float'>, default=EMPTY, help_string='Second input', requires=[], converter=None, validator=None, allowed_values=(), xor=(), copy_mode=<CopyMode.any: 15>, copy_collation=<CopyCollation.any: 0>, copy_ext_decomp=<ExtensionDecomposition.single: 1>, readonly=False),\n", |
| 125 | + " 'function': arg(name='function', type=typing.Callable, default=<function SampleSpec at 0x10d0253a0>, help_string='', requires=[], converter=None, validator=None, allowed_values=(), xor=(), copy_mode=<CopyMode.any: 15>, copy_collation=<CopyCollation.any: 0>, copy_ext_decomp=<ExtensionDecomposition.single: 1>, readonly=False)}\n", |
| 126 | + "{'c': out(name='c', type=<class 'float'>, default=EMPTY, help_string='Sum of a and b', requires=[], converter=None, validator=None),\n", |
| 127 | + " 'd': out(name='d', type=<class 'float'>, default=EMPTY, help_string='Product of a and b', requires=[], converter=None, validator=None)}\n" |
128 | 128 | ] |
129 | 129 | } |
130 | 130 | ], |
131 | 131 | "source": [ |
132 | 132 | "from pprint import pprint\n", |
133 | | - "from pydra.engine.helpers import list_fields\n", |
| 133 | + "from pydra.engine.helpers import fields_dict\n", |
134 | 134 | "\n", |
135 | 135 | "@python.define(outputs=[\"c\", \"d\"])\n", |
136 | 136 | "def SampleSpec(a: int, b: float) -> tuple[float, float]:\n", |
|
147 | 147 | " \"\"\"\n", |
148 | 148 | " return a + b, a * b\n", |
149 | 149 | "\n", |
150 | | - "pprint(list_fields(SampleSpec))\n", |
151 | | - "pprint(list_fields(SampleSpec.Outputs))" |
| 150 | + "pprint(fields_dict(SampleSpec))\n", |
| 151 | + "pprint(fields_dict(SampleSpec.Outputs))" |
152 | 152 | ] |
153 | 153 | }, |
154 | 154 | { |
|
160 | 160 | }, |
161 | 161 | { |
162 | 162 | "cell_type": "code", |
163 | | - "execution_count": 19, |
| 163 | + "execution_count": 13, |
164 | 164 | "metadata": {}, |
165 | 165 | "outputs": [ |
166 | 166 | { |
167 | 167 | "name": "stdout", |
168 | 168 | "output_type": "stream", |
169 | 169 | "text": [ |
170 | | - "[arg(name='b', type=<class 'float'>, default=2.0, help_string='Second input', requires=[], converter=None, validator=None, allowed_values=(), xor=(), copy_mode=<CopyMode.any: 15>, copy_collation=<CopyCollation.any: 0>, copy_ext_decomp=<ExtensionDecomposition.single: 1>, readonly=False),\n", |
171 | | - " arg(name='a', type=<class 'int'>, default=EMPTY, help_string='First input to be inputted', requires=[], converter=None, validator=None, allowed_values=(), xor=(), copy_mode=<CopyMode.any: 15>, copy_collation=<CopyCollation.any: 0>, copy_ext_decomp=<ExtensionDecomposition.single: 1>, readonly=False),\n", |
172 | | - " arg(name='function', type=typing.Callable, default=<function SampleSpec.function at 0x11ad0b600>, help_string='', requires=[], converter=None, validator=None, allowed_values=(), xor=(), copy_mode=<CopyMode.any: 15>, copy_collation=<CopyCollation.any: 0>, copy_ext_decomp=<ExtensionDecomposition.single: 1>, readonly=False)]\n", |
173 | | - "[out(name='c', type=<class 'float'>, default=EMPTY, help_string='Sum of a and b', requires=[], converter=None, validator=None),\n", |
174 | | - " out(name='d', type=<class 'float'>, default=EMPTY, help_string='Product of a and b', requires=[], converter=None, validator=None)]\n" |
| 170 | + "{'a': arg(name='a', type=<class 'int'>, default=EMPTY, help_string='First input to be inputted', requires=[], converter=None, validator=None, allowed_values=(), xor=(), copy_mode=<CopyMode.any: 15>, copy_collation=<CopyCollation.any: 0>, copy_ext_decomp=<ExtensionDecomposition.single: 1>, readonly=False),\n", |
| 171 | + " 'b': arg(name='b', type=<class 'float'>, default=2.0, help_string='Second input', requires=[], converter=None, validator=None, allowed_values=(), xor=(), copy_mode=<CopyMode.any: 15>, copy_collation=<CopyCollation.any: 0>, copy_ext_decomp=<ExtensionDecomposition.single: 1>, readonly=False),\n", |
| 172 | + " 'function': arg(name='function', type=typing.Callable, default=<function SampleSpec.function at 0x10d024040>, help_string='', requires=[], converter=None, validator=None, allowed_values=(), xor=(), copy_mode=<CopyMode.any: 15>, copy_collation=<CopyCollation.any: 0>, copy_ext_decomp=<ExtensionDecomposition.single: 1>, readonly=False)}\n", |
| 173 | + "{'c': out(name='c', type=<class 'float'>, default=EMPTY, help_string='Sum of a and b', requires=[], converter=None, validator=None),\n", |
| 174 | + " 'd': out(name='d', type=<class 'float'>, default=EMPTY, help_string='Product of a and b', requires=[], converter=None, validator=None)}\n" |
175 | 175 | ] |
176 | 176 | } |
177 | 177 | ], |
|
204 | 204 | " def function(a, b):\n", |
205 | 205 | " return a + b, a * b\n", |
206 | 206 | "\n", |
207 | | - "pprint(list_fields(SampleSpec))\n", |
208 | | - "pprint(list_fields(SampleSpec.Outputs))" |
| 207 | + "pprint(fields_dict(SampleSpec))\n", |
| 208 | + "pprint(fields_dict(SampleSpec.Outputs))" |
209 | 209 | ] |
210 | 210 | }, |
211 | 211 | { |
|
217 | 217 | }, |
218 | 218 | { |
219 | 219 | "cell_type": "code", |
220 | | - "execution_count": 20, |
| 220 | + "execution_count": 14, |
221 | 221 | "metadata": {}, |
222 | 222 | "outputs": [ |
223 | 223 | { |
224 | 224 | "name": "stdout", |
225 | 225 | "output_type": "stream", |
226 | 226 | "text": [ |
227 | | - "[arg(name='a', type=<class 'int'>, default=EMPTY, help_string='First input to be inputted', requires=[], converter=None, validator=None, allowed_values=(), xor=(), copy_mode=<CopyMode.any: 15>, copy_collation=<CopyCollation.any: 0>, copy_ext_decomp=<ExtensionDecomposition.single: 1>, readonly=False),\n", |
228 | | - " arg(name='b', type=<class 'float'>, default=EMPTY, help_string='Second input', requires=[], converter=None, validator=None, allowed_values=(), xor=(), copy_mode=<CopyMode.any: 15>, copy_collation=<CopyCollation.any: 0>, copy_ext_decomp=<ExtensionDecomposition.single: 1>, readonly=False),\n", |
229 | | - " arg(name='function', type=typing.Callable, default=<function SampleSpec.function at 0x11ad1d300>, help_string='', requires=[], converter=None, validator=None, allowed_values=(), xor=(), copy_mode=<CopyMode.any: 15>, copy_collation=<CopyCollation.any: 0>, copy_ext_decomp=<ExtensionDecomposition.single: 1>, readonly=False)]\n", |
230 | | - "[out(name='c', type=<class 'float'>, default=EMPTY, help_string='Sum of a and b', requires=[], converter=None, validator=None),\n", |
231 | | - " out(name='d', type=<class 'float'>, default=EMPTY, help_string='Product of a and b', requires=[], converter=None, validator=None)]\n" |
| 227 | + "{'a': arg(name='a', type=<class 'int'>, default=EMPTY, help_string='First input to be inputted', requires=[], converter=None, validator=None, allowed_values=(), xor=(), copy_mode=<CopyMode.any: 15>, copy_collation=<CopyCollation.any: 0>, copy_ext_decomp=<ExtensionDecomposition.single: 1>, readonly=False),\n", |
| 228 | + " 'b': arg(name='b', type=<class 'float'>, default=EMPTY, help_string='Second input', requires=[], converter=None, validator=None, allowed_values=(), xor=(), copy_mode=<CopyMode.any: 15>, copy_collation=<CopyCollation.any: 0>, copy_ext_decomp=<ExtensionDecomposition.single: 1>, readonly=False),\n", |
| 229 | + " 'function': arg(name='function', type=typing.Callable, default=<function SampleSpec.function at 0x10d024180>, help_string='', requires=[], converter=None, validator=None, allowed_values=(), xor=(), copy_mode=<CopyMode.any: 15>, copy_collation=<CopyCollation.any: 0>, copy_ext_decomp=<ExtensionDecomposition.single: 1>, readonly=False)}\n", |
| 230 | + "{'c': out(name='c', type=<class 'float'>, default=EMPTY, help_string='Sum of a and b', requires=[], converter=None, validator=None),\n", |
| 231 | + " 'd': out(name='d', type=<class 'float'>, default=EMPTY, help_string='Product of a and b', requires=[], converter=None, validator=None)}\n" |
232 | 232 | ] |
233 | 233 | } |
234 | 234 | ], |
235 | 235 | "source": [ |
236 | | - "from pydra.engine.specs import PythonSpec\n", |
| 236 | + "from pydra.engine.specs import PythonSpec, PythonOutputs\n", |
237 | 237 | "\n", |
238 | 238 | "@python.define\n", |
239 | 239 | "class SampleSpec(PythonSpec[\"SampleSpec.Outputs\"]):\n", |
|
248 | 248 | " a: int\n", |
249 | 249 | " b: float\n", |
250 | 250 | "\n", |
251 | | - " class Outputs:\n", |
| 251 | + " @python.outputs\n", |
| 252 | + " class Outputs(PythonOutputs):\n", |
252 | 253 | " \"\"\"\n", |
253 | 254 | " Args:\n", |
254 | 255 | " c: Sum of a and b\n", |
|
262 | 263 | " def function(a, b):\n", |
263 | 264 | " return a + b, a * b\n", |
264 | 265 | "\n", |
265 | | - "pprint(list_fields(SampleSpec))\n", |
266 | | - "pprint(list_fields(SampleSpec.Outputs))" |
| 266 | + "pprint(fields_dict(SampleSpec))\n", |
| 267 | + "pprint(fields_dict(SampleSpec.Outputs))" |
267 | 268 | ] |
268 | 269 | }, |
269 | 270 | { |
|
0 commit comments