Repository: AgnostiqHQ/covalent
Pull request #1515 (2023-02-14 03:16:12)

Fix redispatch transport graph copying bug
<!--
⚠️ Your pull request title should be short detailed and understandable for all.
⚠️ Increment the version number in the /VERSION file. If this is a bugfix, increment the patch version (the rightmost number), for example 0.18.2 becomes 0.18.3. If it's a new feature, increment the minor version (the middle number), for example 0.18.2 becomes 0.19.0.
⚠️ Add a note to /CHANGELOG.md with your version number and the date, summarizing the changes.
⚠️ If your pull request fixes an open issue, please link to the issue.
⚠️ Rebase the latest changes from the develop branch. Assuming origin points to https://github.com/AgnostiqHQ/covalent, you should run git rebase origin/develop.
-->

- [ ] I have added the tests to cover my changes.
- [ ] I have updated the documentation and CHANGELOG accordingly.
- [ ] I have read the CONTRIBUTING document.



Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3b39425a..5d5372c7 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]
 
+### Fixed
+
+- Redispatch bug involving copying reusable nodes from old transport graph to new transport graph.
+
 ### Docs
 
 - Update `AWS Lambda` executor RTD with steps to extend the base executor image for installing custom packages
diff --git a/covalent_dispatcher/_core/data_manager.py b/covalent_dispatcher/_core/data_manager.py
index 998732bc..d2012945 100644
--- a/covalent_dispatcher/_core/data_manager.py
+++ b/covalent_dispatcher/_core/data_manager.py
@@ -156,7 +156,7 @@ def _get_result_object_from_new_lattice(
         tg = result_object.lattice.transport_graph
         tg_old = old_result_object.lattice.transport_graph
         reusable_nodes = TransportGraphOps(tg_old).get_reusable_nodes(tg)
-        TransportGraphOps(tg_old).copy_nodes_from(tg, reusable_nodes)
+        TransportGraphOps(tg).copy_nodes_from(tg_old, reusable_nodes)
 
     return result_object
 


Test patch:
diff --git a/tests/covalent_dispatcher_tests/_core/data_manager_test.py b/tests/covalent_dispatcher_tests/_core/data_manager_test.py
index 99f0f55c..1499b741 100644
--- a/tests/covalent_dispatcher_tests/_core/data_manager_test.py
+++ b/tests/covalent_dispatcher_tests/_core/data_manager_test.py
@@ -188,7 +188,7 @@ def test_get_result_object_from_new_lattice(mocker, reuse):
             result_object_mock().lattice.transport_graph
         )
         transport_graph_ops_mock().copy_nodes_from.assert_called_once_with(
-            result_object_mock().lattice.transport_graph,
+            old_result_mock.lattice.transport_graph,
             transport_graph_ops_mock().get_reusable_nodes.return_value,
         )
 
diff --git a/tests/functional_tests/workflow_stack_test.py b/tests/functional_tests/workflow_stack_test.py
index 31c55a10..a97eff76 100644
--- a/tests/functional_tests/workflow_stack_test.py
+++ b/tests/functional_tests/workflow_stack_test.py
@@ -957,3 +957,4 @@ def test_redispatch_reusing_previous_results_and_new_args():
     result = ct.get_result(redispatch_id, wait=True)
     assert int(result.result) == 1
     assert str(result.status) == "COMPLETED"
+    assert result.get_node_result(0)["start_time"] == result.get_node_result(0)["end_time"]