From d3a40c893e0d8e550f793eab08b4e538f77ee5f0 Mon Sep 17 00:00:00 2001 From: NicolasGensollen Date: Thu, 1 Sep 2022 15:19:47 +0200 Subject: [PATCH 1/4] Basic fix --- pydra/engine/core.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pydra/engine/core.py b/pydra/engine/core.py index 42b78054e3..f5a8163dd0 100644 --- a/pydra/engine/core.py +++ b/pydra/engine/core.py @@ -843,6 +843,10 @@ def __init__( if input_spec: if isinstance(input_spec, BaseSpec): self.input_spec = input_spec + elif isinstance(input_spec, SpecInfo): + if not any([x == BaseSpec for x in input_spec.bases]): + raise ValueError("Provided SpecInfo must have BaseSpec as it's base.") + self.input_spec = input_spec else: self.input_spec = SpecInfo( name="Inputs", From 6244fe6f890aff440def69fe06d8b9b2535a9352 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 1 Sep 2022 13:25:55 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pydra/engine/core.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pydra/engine/core.py b/pydra/engine/core.py index f5a8163dd0..b66549e202 100644 --- a/pydra/engine/core.py +++ b/pydra/engine/core.py @@ -845,7 +845,9 @@ def __init__( self.input_spec = input_spec elif isinstance(input_spec, SpecInfo): if not any([x == BaseSpec for x in input_spec.bases]): - raise ValueError("Provided SpecInfo must have BaseSpec as it's base.") + raise ValueError( + "Provided SpecInfo must have BaseSpec as it's base." + ) self.input_spec = input_spec else: self.input_spec = SpecInfo( From af0376522ff955df80e8b503c47dceb146d112d2 Mon Sep 17 00:00:00 2001 From: NicolasGensollen Date: Thu, 1 Sep 2022 15:52:45 +0200 Subject: [PATCH 3/4] Add non regression test --- pydra/engine/tests/test_workflow.py | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/pydra/engine/tests/test_workflow.py b/pydra/engine/tests/test_workflow.py index 17d3d6b3f7..2bcadc6534 100644 --- a/pydra/engine/tests/test_workflow.py +++ b/pydra/engine/tests/test_workflow.py @@ -30,6 +30,7 @@ from ..submitter import Submitter from ..core import Workflow from ... import mark +from ..specs import SpecInfo, BaseSpec, ShellSpec def test_wf_no_input_spec(): @@ -37,6 +38,37 @@ def test_wf_no_input_spec(): Workflow(name="workflow") +def test_wf_specinfo_input_spec(): + input_spec = SpecInfo( + name='Input', + fields=[ + ('a', str, '',{'mandatory': True}), + ('b', dict, {"foo": 1, "bar": False}, {'mandatory': False}), + ], + bases=(BaseSpec,), + ) + wf = Workflow( + name="workflow", + input_spec=input_spec, + ) + for x in ['a', 'b']: + assert hasattr(wf.inputs, x) + assert wf.inputs.a == '' + assert wf.inputs.b == {"foo": 1, "bar": False} + bad_input_spec = SpecInfo( + name='Input', + fields=[ + ('a', str, {'mandatory': True}), + ], + bases=(ShellSpec,) + ) + with pytest.raises( + ValueError, + match="Provided SpecInfo must have BaseSpec as it's base." + ): + Workflow(name="workflow", input_spec=bad_input_spec) + + def test_wf_name_conflict1(): """raise error when workflow name conflicts with a class attribute or method""" with pytest.raises(ValueError) as excinfo1: From 0c77ad5e92cfcc46438ac63cafe9609f072f5003 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 1 Sep 2022 13:53:17 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pydra/engine/tests/test_workflow.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/pydra/engine/tests/test_workflow.py b/pydra/engine/tests/test_workflow.py index 2bcadc6534..4b021d4875 100644 --- a/pydra/engine/tests/test_workflow.py +++ b/pydra/engine/tests/test_workflow.py @@ -40,10 +40,10 @@ def test_wf_no_input_spec(): def test_wf_specinfo_input_spec(): input_spec = SpecInfo( - name='Input', + name="Input", fields=[ - ('a', str, '',{'mandatory': True}), - ('b', dict, {"foo": 1, "bar": False}, {'mandatory': False}), + ("a", str, "", {"mandatory": True}), + ("b", dict, {"foo": 1, "bar": False}, {"mandatory": False}), ], bases=(BaseSpec,), ) @@ -51,20 +51,19 @@ def test_wf_specinfo_input_spec(): name="workflow", input_spec=input_spec, ) - for x in ['a', 'b']: + for x in ["a", "b"]: assert hasattr(wf.inputs, x) - assert wf.inputs.a == '' + assert wf.inputs.a == "" assert wf.inputs.b == {"foo": 1, "bar": False} bad_input_spec = SpecInfo( - name='Input', + name="Input", fields=[ - ('a', str, {'mandatory': True}), + ("a", str, {"mandatory": True}), ], - bases=(ShellSpec,) + bases=(ShellSpec,), ) with pytest.raises( - ValueError, - match="Provided SpecInfo must have BaseSpec as it's base." + ValueError, match="Provided SpecInfo must have BaseSpec as it's base." ): Workflow(name="workflow", input_spec=bad_input_spec)