Skip to content

enable pickling of cwltool.workflow.Workflow #1878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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