Skip to content

Commit 44041fe

Browse files
committed
renamed Task to Job and *Def to *Task
1 parent a2cc4d6 commit 44041fe

33 files changed

+682
-684
lines changed

pydra/design/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ def get_fields(klass, field_type, auto_attribs, helps) -> dict[str, Field]:
372372
type_hints = ty.get_type_hints(klass)
373373
for atr_name in dir(klass):
374374
if (
375-
atr_name in ["Task", "Outputs"]
375+
atr_name == "Outputs"
376376
or atr_name in skip_fields
377377
or atr_name.startswith("__")
378378
):
@@ -404,7 +404,7 @@ def get_fields(klass, field_type, auto_attribs, helps) -> dict[str, Field]:
404404
for atr_name, type_ in type_hints.items():
405405
if atr_name.startswith("_") or atr_name in skip_fields:
406406
continue
407-
if atr_name not in list(fields_dict) + ["Task", "Outputs"]:
407+
if atr_name not in list(fields_dict) + ["Outputs"]:
408408
fields_dict[atr_name] = field_type(
409409
name=atr_name, type=type_, help=helps.get(atr_name, "")
410410
)

pydra/design/python.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
)
1515

1616
if ty.TYPE_CHECKING:
17-
from pydra.engine.specs import PythonDef
17+
from pydra.engine.specs import PythonTask
1818

1919
__all__ = ["arg", "out", "define"]
2020

@@ -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-
) -> "PythonDef":
106+
) -> "PythonTask":
107107
"""
108108
Create an interface for a function or a class.
109109
@@ -124,19 +124,19 @@ def define(
124124
125125
Returns
126126
-------
127-
PythonDef
127+
PythonTask
128128
The task definition class for the Python function
129129
"""
130-
from pydra.engine.specs import PythonDef, PythonOutputs
130+
from pydra.engine.specs import PythonTask, PythonOutputs
131131

132-
def make(wrapped: ty.Callable | type) -> PythonDef:
132+
def make(wrapped: ty.Callable | type) -> PythonTask:
133133
if inspect.isclass(wrapped):
134134
klass = wrapped
135135
function = klass.function
136136
name = klass.__name__
137137
check_explicit_fields_are_none(klass, inputs, outputs)
138138
parsed_inputs, parsed_outputs = extract_fields_from_class(
139-
PythonDef,
139+
PythonTask,
140140
PythonOutputs,
141141
klass,
142142
arg,
@@ -176,7 +176,7 @@ def make(wrapped: ty.Callable | type) -> PythonDef:
176176
)
177177

178178
defn = make_task_def(
179-
PythonDef,
179+
PythonTask,
180180
PythonOutputs,
181181
parsed_inputs,
182182
parsed_outputs,

pydra/design/shell.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
)
3232

3333
if ty.TYPE_CHECKING:
34-
from pydra.engine.specs import ShellDef
34+
from pydra.engine.specs import ShellTask
3535

3636
__all__ = ["arg", "out", "outarg", "define"]
3737

@@ -256,7 +256,7 @@ def define(
256256
auto_attribs: bool = True,
257257
name: str | None = None,
258258
xor: ty.Sequence[str | None] | ty.Sequence[ty.Sequence[str | None]] = (),
259-
) -> "ShellDef":
259+
) -> "ShellTask":
260260
"""Create a task definition for a shell command. Can be used either as a decorator on
261261
the "canonical" dataclass-form of a task definition or as a function that takes a
262262
"shell-command template string" of the form
@@ -309,14 +309,14 @@ def define(
309309
310310
Returns
311311
-------
312-
ShellDef
312+
ShellTask
313313
The interface for the shell command
314314
"""
315-
from pydra.engine.specs import ShellDef, ShellOutputs
315+
from pydra.engine.specs import ShellTask, ShellOutputs
316316

317317
def make(
318318
wrapped: ty.Callable | type | None = None,
319-
) -> ShellDef:
319+
) -> ShellTask:
320320

321321
if inspect.isclass(wrapped):
322322
klass = wrapped
@@ -342,7 +342,7 @@ def make(
342342
class_name = klass.__name__
343343
check_explicit_fields_are_none(klass, inputs, outputs)
344344
parsed_inputs, parsed_outputs = extract_fields_from_class(
345-
ShellDef,
345+
ShellTask,
346346
ShellOutputs,
347347
klass,
348348
arg,
@@ -384,7 +384,9 @@ def make(
384384
class_name = f"_{class_name}"
385385

386386
# Add in fields from base classes
387-
parsed_inputs.update({n: getattr(ShellDef, n) for n in ShellDef.BASE_NAMES})
387+
parsed_inputs.update(
388+
{n: getattr(ShellTask, n) for n in ShellTask.BASE_NAMES}
389+
)
388390
parsed_outputs.update(
389391
{n: getattr(ShellOutputs, n) for n in ShellOutputs.BASE_NAMES}
390392
)
@@ -429,7 +431,7 @@ def make(
429431
outpt.default = NO_DEFAULT
430432

431433
defn = make_task_def(
432-
ShellDef,
434+
ShellTask,
433435
ShellOutputs,
434436
parsed_inputs,
435437
parsed_outputs,
@@ -769,7 +771,7 @@ class _InputPassThrough:
769771

770772
name: str
771773

772-
def __call__(self, inputs: ShellDef) -> ty.Any:
774+
def __call__(self, inputs: ShellTask) -> ty.Any:
773775
return getattr(inputs, self.name)
774776

775777

pydra/design/tests/test_python.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import attrs
55
import pytest
66
from pydra.engine.helpers import list_fields
7-
from pydra.engine.specs import PythonDef, PythonOutputs
7+
from pydra.engine.specs import PythonTask, PythonOutputs
88
from pydra.design import python
99

1010

@@ -18,7 +18,7 @@ def func(a: int) -> float:
1818

1919
SampleDef = python.define(func)
2020

21-
assert issubclass(SampleDef, PythonDef)
21+
assert issubclass(SampleDef, PythonTask)
2222
inputs = sorted(list_fields(SampleDef), key=sort_key)
2323
outputs = sorted(list_fields(SampleDef.Outputs), key=sort_key)
2424
assert inputs == [
@@ -49,7 +49,7 @@ def func(a: int, k: float = 2.0) -> float:
4949

5050
SampleDef = python.define(func)
5151

52-
assert issubclass(SampleDef, PythonDef)
52+
assert issubclass(SampleDef, PythonTask)
5353
inputs = sorted(list_fields(SampleDef), key=sort_key)
5454
outputs = sorted(list_fields(SampleDef.Outputs), key=sort_key)
5555
assert inputs == [
@@ -73,7 +73,7 @@ def func(a: int) -> float:
7373
outputs={"b": python.out(help="the doubled output", type=Decimal)},
7474
)
7575

76-
assert issubclass(SampleDef, PythonDef)
76+
assert issubclass(SampleDef, PythonTask)
7777
inputs = sorted(list_fields(SampleDef), key=sort_key)
7878
outputs = sorted(list_fields(SampleDef.Outputs), key=sort_key)
7979
assert inputs == [
@@ -98,7 +98,7 @@ def func(a: int) -> int:
9898
outputs={"b": float},
9999
)
100100

101-
assert issubclass(SampleDef, PythonDef)
101+
assert issubclass(SampleDef, PythonTask)
102102
inputs = sorted(list_fields(SampleDef), key=sort_key)
103103
outputs = sorted(list_fields(SampleDef.Outputs), key=sort_key)
104104
assert inputs == [
@@ -118,7 +118,7 @@ def SampleDef(a: int, b: float) -> tuple[float, float]:
118118
"""Sample function for testing"""
119119
return a + b, a * b
120120

121-
assert issubclass(SampleDef, PythonDef)
121+
assert issubclass(SampleDef, PythonTask)
122122
inputs = sorted(list_fields(SampleDef), key=sort_key)
123123
outputs = sorted(list_fields(SampleDef.Outputs), key=sort_key)
124124
assert inputs == [
@@ -250,7 +250,7 @@ def SampleDef(a: int, b: float) -> tuple[float, float]:
250250

251251
def test_interface_with_class():
252252
@python.define
253-
class SampleDef(PythonDef["SampleDef.Outputs"]):
253+
class SampleDef(PythonTask["SampleDef.Outputs"]):
254254
"""Sample class for testing
255255
256256
Args:
@@ -276,7 +276,7 @@ class Outputs(PythonOutputs):
276276
def function(a, b):
277277
return a + b, a * b
278278

279-
assert issubclass(SampleDef, PythonDef)
279+
assert issubclass(SampleDef, PythonTask)
280280
inputs = sorted(list_fields(SampleDef), key=sort_key)
281281
outputs = sorted(list_fields(SampleDef.Outputs), key=sort_key)
282282
assert inputs == [
@@ -301,7 +301,7 @@ def function(a, b):
301301

302302
def test_interface_with_inheritance():
303303
@python.define
304-
class SampleDef(PythonDef["SampleDef.Outputs"]):
304+
class SampleDef(PythonTask["SampleDef.Outputs"]):
305305
"""Sample class for testing
306306
307307
Args:
@@ -327,12 +327,12 @@ class Outputs(PythonOutputs):
327327
def function(a, b):
328328
return a + b, a * b
329329

330-
assert issubclass(SampleDef, PythonDef)
330+
assert issubclass(SampleDef, PythonTask)
331331

332332

333333
def test_interface_with_class_no_auto_attribs():
334334
@python.define(auto_attribs=False)
335-
class SampleDef(PythonDef["SampleDef.Outputs"]):
335+
class SampleDef(PythonTask["SampleDef.Outputs"]):
336336
a: int = python.arg(help="First input to be inputted")
337337
b: float = python.arg(help="Second input")
338338

@@ -377,7 +377,7 @@ def test_interface_invalid_wrapped1():
377377
with pytest.raises(ValueError):
378378

379379
@python.define(inputs={"a": python.arg()})
380-
class SampleDef(PythonDef["SampleDef.Outputs"]):
380+
class SampleDef(PythonTask["SampleDef.Outputs"]):
381381
a: int
382382

383383
class Outputs:
@@ -392,7 +392,7 @@ def test_interface_invalid_wrapped2():
392392
with pytest.raises(ValueError):
393393

394394
@python.define(outputs={"b": python.out()})
395-
class SampleDef(PythonDef["SampleDef.Outputs"]):
395+
class SampleDef(PythonTask["SampleDef.Outputs"]):
396396
a: int
397397

398398
class Outputs:

0 commit comments

Comments
 (0)