Skip to content

Commit 379f126

Browse files
committed
fixed up all import errors
1 parent 9c9410e commit 379f126

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+746
-793
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,4 @@ cov.xml
2222
.ipynb_checkpoints
2323

2424
# This can be generated in-tree. We never want to commit it.
25-
pydra/_version.py
26-
pydra/engine/_version.py
25+
pydra/utils/_version.py

docs/source/tutorial/2-advanced-execution.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,9 @@
371371
"metadata": {},
372372
"outputs": [],
373373
"source": [
374-
"from pydra.engine.core import Job\n",
375-
"from pydra.engine.specs import TaskHooks, Result\n",
374+
"from pydra.engine.job import Job\n",
375+
"from pydra.engine.hooks import TaskHooks\n",
376+
"from pydra.engine.result import Result\n",
376377
"import os\n",
377378
"import platform\n",
378379
"\n",

docs/source/tutorial/5-shell.ipynb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,12 @@
355355
"metadata": {},
356356
"outputs": [],
357357
"source": [
358-
"from pydra.engine.specs import ShellTask, ShellOutputs\n",
359358
"from pydra.utils.typing import MultiInputObj\n",
360359
"from fileformats.generic import FsObject, Directory\n",
361360
"\n",
362361
"\n",
363362
"@shell.define\n",
364-
"class Cp(ShellTask[\"Cp.Outputs\"]):\n",
363+
"class Cp(shell.Task[\"Cp.Outputs\"]):\n",
365364
"\n",
366365
" executable = \"cp\"\n",
367366
"\n",
@@ -371,8 +370,7 @@
371370
" int_arg: int | None = shell.arg(argstr=\"--int-arg\", default=None)\n",
372371
" tuple_arg: tuple[int, str] | None = shell.arg(argstr=\"--tuple-arg\", default=None)\n",
373372
"\n",
374-
" @shell.outputs\n",
375-
" class Outputs(ShellOutputs):\n",
373+
" class Outputs(shell.Outputs):\n",
376374
" out_dir: Directory = shell.outarg(path_template=\"{out_dir}\")"
377375
]
378376
},

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

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
"Default values can also be set directly, as with Attrs classes.\n",
3535
"\n",
3636
"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",
3939
"`define` method implicitly). Thus the \"canonical form\" of Python task is as\n",
4040
"follows"
4141
]
@@ -47,13 +47,12 @@
4747
"outputs": [],
4848
"source": [
4949
"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",
5251
"from pydra.compose import python\n",
5352
"\n",
5453
"\n",
5554
"@python.define\n",
56-
"class CanonicalPythonTask(PythonTask[\"CanonicalPythonTask.Outputs\"]):\n",
55+
"class CanonicalPythonTask(python.Task[\"CanonicalPythonTask.Outputs\"]):\n",
5756
" \"\"\"Canonical Python task class for testing\n",
5857
"\n",
5958
" Args:\n",
@@ -65,7 +64,7 @@
6564
" a: int\n",
6665
" b: float = 2.0 # set default value\n",
6766
"\n",
68-
" class Outputs(PythonOutputs):\n",
67+
" class Outputs(python.Outputs):\n",
6968
" \"\"\"\n",
7069
" Args:\n",
7170
" c: Sum of a and b\n",
@@ -102,7 +101,7 @@
102101
"\n",
103102
"\n",
104103
"@python.define\n",
105-
"class CanonicalPythonTask(PythonTask[\"CanonicalPythonTask.Outputs\"]):\n",
104+
"class CanonicalPythonTask(python.Task[\"CanonicalPythonTask.Outputs\"]):\n",
106105
" \"\"\"Canonical Python task class for testing\n",
107106
"\n",
108107
" Args:\n",
@@ -114,7 +113,7 @@
114113
" a: int = python.arg(allowed_values=[1, 2, 3, 4, 5])\n",
115114
" b: float = python.arg(default=2.0, validator=attrs.validators.not_(0))\n",
116115
"\n",
117-
" class Outputs(PythonOutputs):\n",
116+
" class Outputs(python.Outputs):\n",
118117
" \"\"\"\n",
119118
" Args:\n",
120119
" c: Sum of a and b\n",
@@ -153,12 +152,11 @@
153152
"from pathlib import Path\n",
154153
"from fileformats import generic\n",
155154
"from pydra.compose import shell\n",
156-
"from pydra.engine.specs import ShellTask, ShellOutputs\n",
157155
"from pydra.utils.typing import MultiInputObj\n",
158156
"\n",
159157
"\n",
160158
"@shell.define\n",
161-
"class CpWithSize(ShellTask[\"CpWithSize.Outputs\"]):\n",
159+
"class CpWithSize(shell.Task[\"CpWithSize.Outputs\"]):\n",
162160
"\n",
163161
" executable = \"cp\"\n",
164162
"\n",
@@ -168,7 +166,7 @@
168166
" int_arg: int | None = shell.arg(argstr=\"--int-arg\")\n",
169167
" tuple_arg: tuple[int, str] | None = shell.arg(argstr=\"--tuple-arg\")\n",
170168
"\n",
171-
" class Outputs(ShellOutputs):\n",
169+
" class Outputs(shell.Outputs):\n",
172170
"\n",
173171
" @staticmethod\n",
174172
" def get_file_size(out_file: Path) -> int:\n",
@@ -201,7 +199,6 @@
201199
"outputs": [],
202200
"source": [
203201
"from pydra.compose import python, workflow\n",
204-
"from pydra.engine.specs import WorkflowTask, WorkflowOutputs\n",
205202
"\n",
206203
"\n",
207204
"# Example python tasks\n",
@@ -216,7 +213,7 @@
216213
"\n",
217214
"\n",
218215
"@workflow.define\n",
219-
"class CanonicalWorkflowTask(WorkflowTask[\"CanonicalWorkflowTask.Outputs\"]):\n",
216+
"class CanonicalWorkflowTask(workflow.Task[\"CanonicalWorkflowTask.Outputs\"]):\n",
220217
"\n",
221218
" @staticmethod\n",
222219
" def a_converter(value):\n",
@@ -236,7 +233,7 @@
236233
" mul = workflow.add(Mul(a=add.out, b=b))\n",
237234
" return mul.out\n",
238235
"\n",
239-
" class Outputs(WorkflowOutputs):\n",
236+
" class Outputs(workflow.Outputs):\n",
240237
" out: float"
241238
]
242239
}

pydra/_version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "1.0.0"

pydra/compose/base/builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
from_list_if_single,
1313
ensure_list,
1414
PYDRA_ATTR_METADATA,
15-
is_lazy,
1615
)
1716
from pydra.utils.typing import (
1817
MultiInputObj,
1918
MultiInputFile,
2019
MultiOutputObj,
2120
MultiOutputFile,
21+
is_lazy,
2222
)
2323
from .field import Field, Arg, Out
2424

pydra/compose/base/task.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,8 @@
55
from typing import Self
66
import attrs.validators
77
from pydra.utils.typing import is_optional, is_fileset_or_union
8-
from pydra.utils.general import (
9-
list_fields,
10-
is_lazy,
11-
)
12-
from pydra.utils.typing import (
13-
StateArray,
14-
)
8+
from pydra.utils.general import list_fields
9+
from pydra.utils.typing import StateArray, is_lazy
1510
from pydra.utils.hash import hash_function
1611
import os
1712
import itertools
@@ -183,7 +178,7 @@ def __call__(
183178
audit_flags: AuditFlag = AuditFlag.NONE,
184179
messengers: ty.Iterable[Messenger] | None = None,
185180
messenger_args: dict[str, ty.Any] | None = None,
186-
hooks: TaskHooks | None = None,
181+
hooks: "TaskHooks | None" = None,
187182
**kwargs: ty.Any,
188183
) -> OutputsType:
189184
"""Create a job from this task and execute it to produce a result.

pydra/compose/python.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
if ty.TYPE_CHECKING:
1717
from pydra.engine.job import Job
1818

19-
__all__ = ["arg", "out", "define", "PythonTask", "PythonOutputs"]
19+
__all__ = ["arg", "out", "define", "Task", "Outputs"]
2020

2121

2222
@attrs.define
@@ -103,7 +103,7 @@ def define(
103103
outputs_bases: ty.Sequence[type] = (),
104104
auto_attribs: bool = True,
105105
xor: ty.Sequence[str | None] | ty.Sequence[ty.Sequence[str | None]] = (),
106-
) -> "PythonTask":
106+
) -> "Task":
107107
"""
108108
Create an interface for a function or a class.
109109
@@ -124,20 +124,19 @@ def define(
124124
125125
Returns
126126
-------
127-
PythonTask
127+
Task
128128
The task class for the Python function
129129
"""
130-
from pydra.engine.specs import PythonTask, PythonOutputs
131130

132-
def make(wrapped: ty.Callable | type) -> PythonTask:
131+
def make(wrapped: ty.Callable | type) -> Task:
133132
if inspect.isclass(wrapped):
134133
klass = wrapped
135134
function = klass.function
136135
name = klass.__name__
137136
check_explicit_fields_are_none(klass, inputs, outputs)
138137
parsed_inputs, parsed_outputs = extract_fields_from_class(
139-
PythonTask,
140-
PythonOutputs,
138+
Task,
139+
Outputs,
141140
klass,
142141
arg,
143142
out,
@@ -176,8 +175,8 @@ def make(wrapped: ty.Callable | type) -> PythonTask:
176175
)
177176

178177
defn = build_task_class(
179-
PythonTask,
180-
PythonOutputs,
178+
Task,
179+
Outputs,
181180
parsed_inputs,
182181
parsed_outputs,
183182
name=name,
@@ -197,16 +196,16 @@ def make(wrapped: ty.Callable | type) -> PythonTask:
197196

198197

199198
@attrs.define(kw_only=True, auto_attribs=False, eq=False, repr=False)
200-
class PythonOutputs(base.Outputs):
199+
class Outputs(base.Outputs):
201200

202201
@classmethod
203-
def _from_task(cls, job: "Job[PythonTask]") -> ty.Self:
202+
def _from_task(cls, job: "Job[Task]") -> ty.Self:
204203
"""Collect the outputs of a job from a combination of the provided inputs,
205204
the objects in the output directory, and the stdout and stderr of the process.
206205
207206
Parameters
208207
----------
209-
job : Job[PythonTask]
208+
job : Job[Task]
210209
The job whose outputs are being collected.
211210
outputs_dict : dict[str, ty.Any]
212211
The outputs of the job, as a dictionary
@@ -222,15 +221,15 @@ def _from_task(cls, job: "Job[PythonTask]") -> ty.Self:
222221
return outputs
223222

224223

225-
PythonOutputsType = ty.TypeVar("OutputType", bound=PythonOutputs)
224+
PythonOutputsType = ty.TypeVar("OutputType", bound=Outputs)
226225

227226

228227
@attrs.define(kw_only=True, auto_attribs=False, eq=False, repr=False)
229-
class PythonTask(base.Task[PythonOutputsType]):
228+
class Task(base.Task[PythonOutputsType]):
230229

231230
_task_type = "python"
232231

233-
def _run(self, job: "Job[PythonTask]", rerun: bool = True) -> None:
232+
def _run(self, job: "Job[Task]", rerun: bool = True) -> None:
234233
# Prepare the inputs to the function
235234
inputs = attrs_values(self)
236235
del inputs["function"]

pydra/compose/shell/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .field import arg, out, outarg
22
from .builder import define
3-
from .task import ShellTask, ShellOutputs
3+
from .task import Task, Outputs
44

5-
__all__ = ["arg", "out", "outarg", "define", "ShellTask", "ShellOutputs"]
5+
__all__ = ["arg", "out", "outarg", "define", "Task", "Outputs"]

pydra/compose/shell/builder.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
is_optional,
3131
)
3232
from . import field
33-
from .task import ShellTask, ShellOutputs
33+
from .task import Task, Outputs
3434

3535

3636
EXECUTABLE_HELP_STRING = (
@@ -62,7 +62,7 @@ def define(
6262
auto_attribs: bool = True,
6363
name: str | None = None,
6464
xor: ty.Sequence[str | None] | ty.Sequence[ty.Sequence[str | None]] = (),
65-
) -> "ShellTask":
65+
) -> "Task":
6666
"""Create a task for a shell command. Can be used either as a decorator on
6767
the "canonical" dataclass-form of a task or as a function that takes a
6868
"shell-command template string" of the form
@@ -115,13 +115,13 @@ def define(
115115
116116
Returns
117117
-------
118-
ShellTask
118+
Task
119119
The interface for the shell command
120120
"""
121121

122122
def make(
123123
wrapped: ty.Callable | type | None = None,
124-
) -> ShellTask:
124+
) -> Task:
125125

126126
if inspect.isclass(wrapped):
127127
klass = wrapped
@@ -147,8 +147,8 @@ def make(
147147
class_name = klass.__name__
148148
check_explicit_fields_are_none(klass, inputs, outputs)
149149
parsed_inputs, parsed_outputs = extract_fields_from_class(
150-
ShellTask,
151-
ShellOutputs,
150+
Task,
151+
Outputs,
152152
klass,
153153
field.arg,
154154
field.out,
@@ -189,12 +189,8 @@ def make(
189189
class_name = f"_{class_name}"
190190

191191
# Add in fields from base classes
192-
parsed_inputs.update(
193-
{n: getattr(ShellTask, n) for n in ShellTask.BASE_NAMES}
194-
)
195-
parsed_outputs.update(
196-
{n: getattr(ShellOutputs, n) for n in ShellOutputs.BASE_NAMES}
197-
)
192+
parsed_inputs.update({n: getattr(Task, n) for n in Task.BASE_NAMES})
193+
parsed_outputs.update({n: getattr(Outputs, n) for n in Outputs.BASE_NAMES})
198194

199195
if "executable" in parsed_inputs:
200196
raise ValueError(
@@ -236,8 +232,8 @@ def make(
236232
outpt.default = NO_DEFAULT
237233

238234
defn = build_task_class(
239-
ShellTask,
240-
ShellOutputs,
235+
Task,
236+
Outputs,
241237
parsed_inputs,
242238
parsed_outputs,
243239
name=class_name,
@@ -582,7 +578,7 @@ class _InputPassThrough:
582578

583579
name: str
584580

585-
def __call__(self, inputs: ShellTask) -> ty.Any:
581+
def __call__(self, inputs: Task) -> ty.Any:
586582
return getattr(inputs, self.name)
587583

588584

0 commit comments

Comments
 (0)