|
34 | 34 | "Default values can also be set directly, as with Attrs classes.\n", |
35 | 35 | "\n", |
36 | 36 | "In order to allow static type-checkers to check the type of outputs of tasks added\n", |
37 | | - "to workflows, it is also necessary to explicitly extend from the `pydra.engine.specs.PythonTask`\n", |
38 | | - "and `pydra.engine.specs.PythonOutputs` classes (they are otherwise set as bases by the\n", |
| 37 | + "to workflows, it is also necessary to explicitly extend from the `pydra.engine.python.Task`\n", |
| 38 | + "and `pydra.engine.python.Outputs` classes (they are otherwise set as bases by the\n", |
39 | 39 | "`define` method implicitly). Thus the \"canonical form\" of Python task is as\n", |
40 | 40 | "follows" |
41 | 41 | ] |
|
47 | 47 | "outputs": [], |
48 | 48 | "source": [ |
49 | 49 | "from pprint import pprint\n", |
50 | | - "from pydra.engine.helpers import fields_dict\n", |
51 | | - "from pydra.engine.specs import PythonTask, PythonOutputs\n", |
| 50 | + "from pydra.utils import fields_dict\n", |
52 | 51 | "from pydra.compose import python\n", |
53 | 52 | "\n", |
54 | 53 | "\n", |
55 | 54 | "@python.define\n", |
56 | | - "class CanonicalPythonTask(PythonTask[\"CanonicalPythonTask.Outputs\"]):\n", |
| 55 | + "class CanonicalPythonTask(python.Task[\"CanonicalPythonTask.Outputs\"]):\n", |
57 | 56 | " \"\"\"Canonical Python task class for testing\n", |
58 | 57 | "\n", |
59 | 58 | " Args:\n", |
|
65 | 64 | " a: int\n", |
66 | 65 | " b: float = 2.0 # set default value\n", |
67 | 66 | "\n", |
68 | | - " class Outputs(PythonOutputs):\n", |
| 67 | + " class Outputs(python.Outputs):\n", |
69 | 68 | " \"\"\"\n", |
70 | 69 | " Args:\n", |
71 | 70 | " c: Sum of a and b\n", |
|
102 | 101 | "\n", |
103 | 102 | "\n", |
104 | 103 | "@python.define\n", |
105 | | - "class CanonicalPythonTask(PythonTask[\"CanonicalPythonTask.Outputs\"]):\n", |
| 104 | + "class CanonicalPythonTask(python.Task[\"CanonicalPythonTask.Outputs\"]):\n", |
106 | 105 | " \"\"\"Canonical Python task class for testing\n", |
107 | 106 | "\n", |
108 | 107 | " Args:\n", |
|
114 | 113 | " a: int = python.arg(allowed_values=[1, 2, 3, 4, 5])\n", |
115 | 114 | " b: float = python.arg(default=2.0, validator=attrs.validators.not_(0))\n", |
116 | 115 | "\n", |
117 | | - " class Outputs(PythonOutputs):\n", |
| 116 | + " class Outputs(python.Outputs):\n", |
118 | 117 | " \"\"\"\n", |
119 | 118 | " Args:\n", |
120 | 119 | " c: Sum of a and b\n", |
|
153 | 152 | "from pathlib import Path\n", |
154 | 153 | "from fileformats import generic\n", |
155 | 154 | "from pydra.compose import shell\n", |
156 | | - "from pydra.engine.specs import ShellTask, ShellOutputs\n", |
157 | 155 | "from pydra.utils.typing import MultiInputObj\n", |
158 | 156 | "\n", |
159 | 157 | "\n", |
160 | 158 | "@shell.define\n", |
161 | | - "class CpWithSize(ShellTask[\"CpWithSize.Outputs\"]):\n", |
| 159 | + "class CpWithSize(shell.Task[\"CpWithSize.Outputs\"]):\n", |
162 | 160 | "\n", |
163 | 161 | " executable = \"cp\"\n", |
164 | 162 | "\n", |
|
168 | 166 | " int_arg: int | None = shell.arg(argstr=\"--int-arg\")\n", |
169 | 167 | " tuple_arg: tuple[int, str] | None = shell.arg(argstr=\"--tuple-arg\")\n", |
170 | 168 | "\n", |
171 | | - " class Outputs(ShellOutputs):\n", |
| 169 | + " class Outputs(shell.Outputs):\n", |
172 | 170 | "\n", |
173 | 171 | " @staticmethod\n", |
174 | 172 | " def get_file_size(out_file: Path) -> int:\n", |
|
201 | 199 | "outputs": [], |
202 | 200 | "source": [ |
203 | 201 | "from pydra.compose import python, workflow\n", |
204 | | - "from pydra.engine.specs import WorkflowTask, WorkflowOutputs\n", |
205 | 202 | "\n", |
206 | 203 | "\n", |
207 | 204 | "# Example python tasks\n", |
|
216 | 213 | "\n", |
217 | 214 | "\n", |
218 | 215 | "@workflow.define\n", |
219 | | - "class CanonicalWorkflowTask(WorkflowTask[\"CanonicalWorkflowTask.Outputs\"]):\n", |
| 216 | + "class CanonicalWorkflowTask(workflow.Task[\"CanonicalWorkflowTask.Outputs\"]):\n", |
220 | 217 | "\n", |
221 | 218 | " @staticmethod\n", |
222 | 219 | " def a_converter(value):\n", |
|
236 | 233 | " mul = workflow.add(Mul(a=add.out, b=b))\n", |
237 | 234 | " return mul.out\n", |
238 | 235 | "\n", |
239 | | - " class Outputs(WorkflowOutputs):\n", |
| 236 | + " class Outputs(workflow.Outputs):\n", |
240 | 237 | " out: float" |
241 | 238 | ] |
242 | 239 | } |
|
0 commit comments