diff --git a/cwltool/workflow.py b/cwltool/workflow.py index 3f61cd521..8546ca72e 100644 --- a/cwltool/workflow.py +++ b/cwltool/workflow.py @@ -17,6 +17,7 @@ ) from uuid import UUID +from mypy_extensions import mypyc_attr from ruamel.yaml.comments import CommentedMap from schema_salad.exceptions import ValidationException from schema_salad.sourceline import SourceLine, indent @@ -66,6 +67,7 @@ def default_make_tool(toolpath_object: CommentedMap, loadingContext: LoadingCont context.default_make_tool = default_make_tool +@mypyc_attr(serializable=True) class Workflow(Process): def __init__( self, diff --git a/tests/test_subclass_mypyc.py b/tests/test_subclass_mypyc.py index 9f302fead..bb138cdc5 100644 --- a/tests/test_subclass_mypyc.py +++ b/tests/test_subclass_mypyc.py @@ -15,6 +15,7 @@ from cwltool.context import LoadingContext, RuntimeContext from cwltool.stdfsaccess import StdFsAccess from cwltool.update import INTERNAL_VERSION +from cwltool.workflow import Workflow from .test_anon_types import snippet @@ -41,6 +42,16 @@ class TestExprTool(ExpressionTool): assert a.test is False +@pytest.mark.parametrize("snippet", snippet) +def test_pickle_unpickle_workflow(snippet: CommentedMap) -> None: + """We can pickle & unpickle a Workflow.""" + + a = Workflow(snippet, LoadingContext()) + stream = pickle.dumps(a) + assert stream + assert pickle.loads(stream) + + def test_serialize_builder() -> None: """We can pickle Builder.""" runtime_context = RuntimeContext()