Skip to content

Commit

Permalink
enable pickling of cwltool.workflow.Workflow (#1878)
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c authored Jul 19, 2023
1 parent f23d3e0 commit 1573509
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cwltool/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions tests/test_subclass_mypyc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand Down

0 comments on commit 1573509

Please sign in to comment.