Skip to content

Commit 816f23c

Browse files
committed
enable pickling of cwltool.workflow.Workflow
1 parent f23d3e0 commit 816f23c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

cwltool/workflow.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
)
1818
from uuid import UUID
1919

20+
from mypy_extensions import mypyc_attr
2021
from ruamel.yaml.comments import CommentedMap
2122
from schema_salad.exceptions import ValidationException
2223
from schema_salad.sourceline import SourceLine, indent
@@ -66,6 +67,7 @@ def default_make_tool(toolpath_object: CommentedMap, loadingContext: LoadingCont
6667
context.default_make_tool = default_make_tool
6768

6869

70+
@mypyc_attr(serializable=True)
6971
class Workflow(Process):
7072
def __init__(
7173
self,

tests/test_subclass_mypyc.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from cwltool.builder import Builder
1414
from cwltool.command_line_tool import CommandLineTool, ExpressionTool
15+
from cwltool.workflow import Workflow
1516
from cwltool.context import LoadingContext, RuntimeContext
1617
from cwltool.stdfsaccess import StdFsAccess
1718
from cwltool.update import INTERNAL_VERSION
@@ -40,6 +41,14 @@ class TestExprTool(ExpressionTool):
4041
a = TestExprTool(snippet, LoadingContext())
4142
assert a.test is False
4243

44+
@pytest.mark.parametrize("snippet", snippet)
45+
def test_pickle_unpickle_workflow(snippet: CommentedMap) -> None:
46+
"""We can pickle & unpickle a Workflow."""
47+
48+
a = Workflow(snippet, LoadingContext())
49+
stream = pickle.dumps(a)
50+
assert stream
51+
assert pickle.loads(stream)
4352

4453
def test_serialize_builder() -> None:
4554
"""We can pickle Builder."""

0 commit comments

Comments
 (0)