Repository: AgnostiqHQ/covalent (language: python)

Issue:
Add tests to ensure that dispatcher does not unpickle user data.
This is a followup issue to #748. We should add tests to check as long as the "local" executor is not used for either ordinary tasks or `workflow_executor` (postprocessing and dispatching sublattices), the dispatcher process never calls `TransportableObject.get_deserialized()`.


Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 524c18628..622af887d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [UNRELEASED]
 
+### Tests
+
+- Check that user data is not unpickled by the Covalent server process
+
 ## [0.145.0] - 2022-07-20
 
 ### Authors


Test patch:
diff --git a/tests/covalent_dispatcher_tests/_core/execution_test.py b/tests/covalent_dispatcher_tests/_core/execution_test.py
index 7f6e61afc..27c5d4d5a 100644
--- a/tests/covalent_dispatcher_tests/_core/execution_test.py
+++ b/tests/covalent_dispatcher_tests/_core/execution_test.py
@@ -590,3 +590,34 @@ def workflow(x):
     result_object = run_workflow(dispatch_id, json_lattice, tasks_pool)
 
     assert result_object.status == Result.FAILED
+
+
+def test_run_workflow_does_not_deserialize(mocker):
+    """Check that dispatcher does not deserialize user data when using
+    out-of-process `workflow_executor`"""
+
+    @ct.electron(executor="dask")
+    def task(x):
+        return x
+
+    @ct.lattice(executor="dask", workflow_executor="dask")
+    def workflow(x):
+        # Exercise both sublatticing and postprocessing
+        sublattice_task = ct.lattice(task, workflow_executor="dask")
+        res1 = ct.electron(sublattice_task(x), executor="dask")
+        return res1
+
+    from concurrent.futures import ThreadPoolExecutor
+
+    workflow.build_graph(5)
+
+    json_lattice = workflow.serialize_to_json()
+    dispatch_id = "asdf"
+    tasks_pool = ThreadPoolExecutor()
+
+    mock_to_deserialize = mocker.patch("covalent.TransportableObject.get_deserialized")
+
+    result_object = run_workflow(dispatch_id, json_lattice, tasks_pool)
+
+    mock_to_deserialize.assert_not_called()
+    assert result_object.status == Result.COMPLETED