diff --git a/pydra/design/base.py b/pydra/design/base.py index f859e7f3fa..f81dd6602a 100644 --- a/pydra/design/base.py +++ b/pydra/design/base.py @@ -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__ = [ @@ -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], @@ -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. @@ -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" ) diff --git a/pydra/design/python.py b/pydra/design/python.py index cde35e94a8..5f050ac11b 100644 --- a/pydra/design/python.py +++ b/pydra/design/python.py @@ -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): @@ -142,7 +142,7 @@ def make(wrapped: ty.Callable | type) -> PythonSpec: interface = make_task_spec( PythonSpec, - PythonOutSpec, + PythonOutputs, FunctionTask, parsed_inputs, parsed_outputs, diff --git a/pydra/design/shell.py b/pydra/design/shell.py index a8c8d46b33..4c08612fcd 100644 --- a/pydra/design/shell.py +++ b/pydra/design/shell.py @@ -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, @@ -338,7 +338,7 @@ def make( interface = make_task_spec( ShellSpec, - ShellOutSpec, + ShellOutputs, ShellCommandTask, parsed_inputs, parsed_outputs, diff --git a/pydra/design/workflow.py b/pydra/design/workflow.py index 7c967910fa..abe1320221 100644 --- a/pydra/design/workflow.py +++ b/pydra/design/workflow.py @@ -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"] @@ -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 = [] @@ -159,7 +159,7 @@ def make(wrapped: ty.Callable | type) -> TaskSpec: interface = make_task_spec( WorkflowSpec, - WorkflowOutSpec, + WorkflowOutputs, WorkflowTask, parsed_inputs, parsed_outputs, @@ -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: @@ -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) diff --git a/pydra/engine/boutiques.py b/pydra/engine/boutiques.py index 8202da6b99..3f1b7bb4b2 100644 --- a/pydra/engine/boutiques.py +++ b/pydra/engine/boutiques.py @@ -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 @@ -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): diff --git a/pydra/engine/specs.py b/pydra/engine/specs.py index be1891d811..fb74e2b5d0 100644 --- a/pydra/engine/specs.py +++ b/pydra/engine/specs.py @@ -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") @@ -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]): @@ -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() @@ -373,7 +373,7 @@ def collect_outputs( Returns ------- - outputs : ShellOutSpec + outputs : ShellOutputs The outputs of the shell process """ diff --git a/pydra/engine/workflow/base.py b/pydra/engine/workflow/base.py index 1f6fd7f680..e14f581ec9 100644 --- a/pydra/engine/workflow/base.py +++ b/pydra/engine/workflow/base.py @@ -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) diff --git a/pydra/engine/workflow/node.py b/pydra/engine/workflow/node.py index f2fa14adba..307610d7c5 100644 --- a/pydra/engine/workflow/node.py +++ b/pydra/engine/workflow/node.py @@ -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 @@ -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") diff --git a/pydra/mark/shell.py b/pydra/mark/shell.py index d0cde91337..0f700d6970 100644 --- a/pydra/mark/shell.py +++ b/pydra/mark/shell.py @@ -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 = {} @@ -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) @@ -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,) diff --git a/pydra/utils/tests/utils.py b/pydra/utils/tests/utils.py index 3582fa9eda..0a65c780d7 100644 --- a/pydra/utils/tests/utils.py +++ b/pydra/utils/tests/utils.py @@ -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,) ) @@ -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,) ) @@ -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,), )