Skip to content

Commit

Permalink
renamed OutSpec to Outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Dec 9, 2024
1 parent 35f489c commit a9071e4
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 37 deletions.
12 changes: 6 additions & 6 deletions pydra/design/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


if ty.TYPE_CHECKING:
from pydra.engine.specs import TaskSpec, OutSpec
from pydra.engine.specs import TaskSpec, Outputs
from pydra.engine.core import Task

__all__ = [
Expand Down Expand Up @@ -354,7 +354,7 @@ def get_fields(klass, field_type, auto_attribs, helps) -> dict[str, Field]:

def make_task_spec(
spec_type: type["TaskSpec"],
out_type: type["OutSpec"],
out_type: type["Outputs"],
task_type: type["Task"],
inputs: dict[str, Arg],
outputs: dict[str, Out],
Expand Down Expand Up @@ -466,11 +466,11 @@ def make_task_spec(


def make_outputs_spec(
spec_type: type["OutSpec"],
spec_type: type["Outputs"],
outputs: dict[str, Out],
bases: ty.Sequence[type],
spec_name: str,
) -> type["OutSpec"]:
) -> type["Outputs"]:
"""Create an outputs specification class and its outputs specification class from the
output fields provided to the decorator/function.
Expand All @@ -491,10 +491,10 @@ def make_outputs_spec(
klass : type
The class created using the attrs package
"""
from pydra.engine.specs import OutSpec
from pydra.engine.specs import Outputs

if not any(issubclass(b, spec_type) for b in bases):
if out_spec_bases := [b for b in bases if issubclass(b, OutSpec)]:
if out_spec_bases := [b for b in bases if issubclass(b, Outputs)]:
raise ValueError(
f"Cannot make {spec_type} output spec from {out_spec_bases} bases"
)
Expand Down
4 changes: 2 additions & 2 deletions pydra/design/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def define(
Whether to use auto_attribs mode when creating the class.
"""
from pydra.engine.task import FunctionTask
from pydra.engine.specs import PythonSpec, PythonOutSpec
from pydra.engine.specs import PythonSpec, PythonOutputs

def make(wrapped: ty.Callable | type) -> PythonSpec:
if inspect.isclass(wrapped):
Expand Down Expand Up @@ -142,7 +142,7 @@ def make(wrapped: ty.Callable | type) -> PythonSpec:

interface = make_task_spec(
PythonSpec,
PythonOutSpec,
PythonOutputs,
FunctionTask,
parsed_inputs,
parsed_outputs,
Expand Down
4 changes: 2 additions & 2 deletions pydra/design/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def define(
The interface for the shell command
"""
from pydra.engine.task import ShellCommandTask
from pydra.engine.specs import ShellSpec, ShellOutSpec
from pydra.engine.specs import ShellSpec, ShellOutputs

def make(
wrapped: ty.Callable | type | None = None,
Expand Down Expand Up @@ -338,7 +338,7 @@ def make(

interface = make_task_spec(
ShellSpec,
ShellOutSpec,
ShellOutputs,
ShellCommandTask,
parsed_inputs,
parsed_outputs,
Expand Down
10 changes: 5 additions & 5 deletions pydra/design/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

if ty.TYPE_CHECKING:
from pydra.engine.workflow.base import Workflow
from pydra.engine.specs import TaskSpec, OutSpec, WorkflowSpec
from pydra.engine.specs import TaskSpec, Outputs, WorkflowSpec


__all__ = ["define", "add", "this", "arg", "out"]
Expand Down Expand Up @@ -115,7 +115,7 @@ def define(
The interface for the function or class.
"""
from pydra.engine.core import WorkflowTask
from pydra.engine.specs import TaskSpec, WorkflowSpec, WorkflowOutSpec
from pydra.engine.specs import TaskSpec, WorkflowSpec, WorkflowOutputs

if lazy is None:
lazy = []
Expand Down Expand Up @@ -159,7 +159,7 @@ def make(wrapped: ty.Callable | type) -> TaskSpec:

interface = make_task_spec(
WorkflowSpec,
WorkflowOutSpec,
WorkflowOutputs,
WorkflowTask,
parsed_inputs,
parsed_outputs,
Expand Down Expand Up @@ -191,7 +191,7 @@ def this() -> "Workflow":
return Workflow.under_construction


OutSpecType = ty.TypeVar("OutSpecType", bound="OutSpec")
OutSpecType = ty.TypeVar("OutSpecType", bound="Outputs")


def add(task_spec: "TaskSpec[OutSpecType]", name: str = None) -> OutSpecType:
Expand All @@ -207,7 +207,7 @@ def add(task_spec: "TaskSpec[OutSpecType]", name: str = None) -> OutSpecType:
Returns
-------
OutSpec
Outputs
The outputs specification of the node
"""
return this().add(task_spec, name=name)
4 changes: 2 additions & 2 deletions pydra/engine/boutiques.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from pydra.utils.messenger import AuditFlag
from pydra.engine.task import ShellCommandTask
from pydra.engine.specs import SpecInfo, ShellSpec, ShellOutSpec, File, attrs_fields
from pydra.engine.specs import SpecInfo, ShellSpec, ShellOutputs, File, attrs_fields
from .helpers_file import is_local_file


Expand Down Expand Up @@ -175,7 +175,7 @@ def _prepare_output_spec(self, names_subset=None):

if names_subset:
raise RuntimeError(f"{names_subset} are not in the zenodo output spec")
spec = SpecInfo(name="Outputs", fields=fields, bases=(ShellOutSpec,))
spec = SpecInfo(name="Outputs", fields=fields, bases=(ShellOutputs,))
return spec

def _command_args_single(self, state_ind=None, index=None):
Expand Down
16 changes: 8 additions & 8 deletions pydra/engine/specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def is_set(value: ty.Any) -> bool:
return value is not attrs.NOTHING


class OutSpec:
class Outputs:
"""Base class for all output specifications"""

RESERVED_FIELD_NAMES = ("split", "combine")
Expand Down Expand Up @@ -93,7 +93,7 @@ def combine(
return self


OutSpecType = ty.TypeVar("OutputType", bound=OutSpec)
OutSpecType = ty.TypeVar("OutputType", bound=Outputs)


class TaskSpec(ty.Generic[OutSpecType]):
Expand Down Expand Up @@ -314,29 +314,29 @@ class RuntimeSpec:
network: bool = False


class PythonOutSpec(OutSpec):
class PythonOutputs(Outputs):
pass


PythonOutSpecType = ty.TypeVar("OutputType", bound=PythonOutSpec)
PythonOutSpecType = ty.TypeVar("OutputType", bound=PythonOutputs)


class PythonSpec(TaskSpec[PythonOutSpecType]):
pass


class WorkflowOutSpec(OutSpec):
class WorkflowOutputs(Outputs):
pass


WorkflowOutSpecType = ty.TypeVar("OutputType", bound=WorkflowOutSpec)
WorkflowOutSpecType = ty.TypeVar("OutputType", bound=WorkflowOutputs)


class WorkflowSpec(TaskSpec[WorkflowOutSpecType]):
pass


class ShellOutSpec(OutSpec):
class ShellOutputs(Outputs):
"""Output specification of a generic shell process."""

return_code: int = shell.out()
Expand Down Expand Up @@ -373,7 +373,7 @@ def collect_outputs(
Returns
-------
outputs : ShellOutSpec
outputs : ShellOutputs
The outputs of the shell process
"""

Expand Down
6 changes: 3 additions & 3 deletions pydra/engine/workflow/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
from typing_extensions import Self
import attrs
from pydra.engine.helpers import list_fields, attrs_values
from pydra.engine.specs import TaskSpec, OutSpec, WorkflowOutSpec
from pydra.engine.specs import TaskSpec, Outputs, WorkflowOutputs
from .lazy import LazyInField
from pydra.utils.hash import hash_function
from pydra.utils.typing import TypeParser, StateArray
from .node import Node


OutSpecType = ty.TypeVar("OutputType", bound=OutSpec)
WorkflowOutSpecType = ty.TypeVar("OutputType", bound=WorkflowOutSpec)
OutSpecType = ty.TypeVar("OutputType", bound=Outputs)
WorkflowOutSpecType = ty.TypeVar("OutputType", bound=WorkflowOutputs)


@attrs.define(auto_attribs=False)
Expand Down
4 changes: 2 additions & 2 deletions pydra/engine/workflow/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import attrs
from pydra.utils.typing import TypeParser, StateArray
from . import lazy
from ..specs import TaskSpec, OutSpec
from ..specs import TaskSpec, Outputs
from ..helpers import ensure_list, attrs_values
from .. import helpers_state as hlpst
from ..state import State
Expand All @@ -13,7 +13,7 @@
from .base import Workflow


OutputType = ty.TypeVar("OutputType", bound=OutSpec)
OutputType = ty.TypeVar("OutputType", bound=Outputs)
Splitter = ty.Union[str, ty.Tuple[str, ...]]

_not_set = Enum("_not_set", "NOT_SET")
Expand Down
8 changes: 4 additions & 4 deletions pydra/mark/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def ensure_base_included(base_class: type, bases_list: list[type]):
# Ensure bases are lists and can be modified
ensure_base_included(pydra.engine.task.ShellCommandTask, bases)
ensure_base_included(pydra.engine.specs.ShellSpec, inputs_bases)
ensure_base_included(pydra.engine.specs.ShellOutSpec, outputs_bases)
ensure_base_included(pydra.engine.specs.ShellOutputs, outputs_bases)

def convert_to_attrs(fields: dict[str, dict[str, ty.Any]], attrs_func):
annotations = {}
Expand Down Expand Up @@ -161,7 +161,7 @@ def convert_to_attrs(fields: dict[str, dict[str, ty.Any]], attrs_func):
try:
Outputs = klass.Outputs
except AttributeError:
Outputs = type("Outputs", (pydra.engine.specs.ShellOutSpec,), {})
Outputs = type("Outputs", (pydra.engine.specs.ShellOutputs,), {})

# Pass Inputs and Outputs in attrs.define if they are present in klass (i.e.
# not in a base class)
Expand All @@ -177,8 +177,8 @@ def convert_to_attrs(fields: dict[str, dict[str, ty.Any]], attrs_func):

template_fields = _gen_output_template_fields(Inputs, Outputs)

if not issubclass(Outputs, pydra.engine.specs.ShellOutSpec):
outputs_bases = (Outputs, pydra.engine.specs.ShellOutSpec)
if not issubclass(Outputs, pydra.engine.specs.ShellOutputs):
outputs_bases = (Outputs, pydra.engine.specs.ShellOutputs)
add_base_class = True
else:
outputs_bases = (Outputs,)
Expand Down
6 changes: 3 additions & 3 deletions pydra/utils/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def generic_func_task(in_file: File) -> File:
),
]
generic_shelloutput_spec = specs.SpecInfo(
name="Output", fields=generic_shell_output_fields, bases=(specs.ShellOutSpec,)
name="Output", fields=generic_shell_output_fields, bases=(specs.ShellOutputs,)
)


Expand Down Expand Up @@ -117,7 +117,7 @@ def specific_func_task(in_file: MyFormatX) -> MyFormatX:
),
]
specific_shelloutput_spec = specs.SpecInfo(
name="Output", fields=specific_shell_output_fields, bases=(specs.ShellOutSpec,)
name="Output", fields=specific_shell_output_fields, bases=(specs.ShellOutputs,)
)


Expand Down Expand Up @@ -171,7 +171,7 @@ def other_specific_func_task(in_file: MyOtherFormatX) -> MyOtherFormatX:
other_specific_shelloutput_spec = specs.SpecInfo(
name="Output",
fields=other_specific_shell_output_fields,
bases=(specs.ShellOutSpec,),
bases=(specs.ShellOutputs,),
)


Expand Down

0 comments on commit a9071e4

Please sign in to comment.