Repository: AgnostiqHQ/covalent (language: python)

Issue:
Functional tests for Dask executor



Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d93e387d3..2f1a4ff37 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
+## [0.32.7] - 2022-05-11
+
+### Added
+
+- Functional test added for dask executor with the cluster running locally.
+
+### Removed
+
+- Dask from `requirements.txt`.
+
 ## [0.32.6] -- 2022-05-06
 
 ### Added
diff --git a/VERSION b/VERSION
index eb7713622..0037a8bf8 100644
--- a/VERSION
+++ b/VERSION
@@ -1,1 +1,1 @@
-0.32.4
+0.32.7
diff --git a/requirements.txt b/requirements.txt
index 67dadf7a9..a751b5bca 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,5 +1,4 @@
 cloudpickle==2.0.0
-dask[distributed]==2022.1.0
 eventlet==0.31.0
 flask==2.0.1
 flask-cors==3.0.10


Test patch:
diff --git a/tests/functional_tests/dask_executor_test.py b/tests/functional_tests/dask_executor_test.py
new file mode 100644
index 000000000..fcd14d82d
--- /dev/null
+++ b/tests/functional_tests/dask_executor_test.py
@@ -0,0 +1,87 @@
+# Copyright 2021 Agnostiq Inc.
+#
+# This file is part of Covalent.
+#
+# Licensed under the GNU Affero General Public License 3.0 (the "License").
+# A copy of the License may be obtained with this software package or at
+#
+#      https://www.gnu.org/licenses/agpl-3.0.en.html
+#
+# Use of this file is prohibited except in compliance with the License. Any
+# modifications or derivative works of this file must retain this copyright
+# notice, and modified files must contain a notice indicating that they have
+# been altered from the originals.
+#
+# Covalent is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.
+#
+# Relief from the License may be granted by purchasing a commercial license.
+
+import time
+
+import covalent as ct
+from covalent._results_manager import Result
+from covalent.executor import DaskExecutor
+
+
+def test_dask_executor(scheduler_address):
+
+    dask_executor = DaskExecutor(scheduler_address=scheduler_address)
+
+    @ct.electron(executor=dask_executor)
+    def identity(x):
+        return x
+
+    @ct.electron(executor=dask_executor)
+    def combine(x):
+        return sum(x)
+
+    @ct.lattice
+    def workflow(n):
+        vals = []
+        result = 1
+        nodes = range(n)
+
+        for i in nodes:
+            for _ in nodes:
+                if i == 0:
+                    vals.append(identity(1))
+                else:
+                    vals.append(identity(result))
+            result = combine(vals)
+
+        return result, vals
+
+    dispatcher = ct.dispatch(workflow)
+
+    n = 10
+    dispatch_id = dispatcher(n=n)
+    print(f"Dispatching with dispatch_id: {dispatch_id}")
+
+    time.sleep(10)
+
+    result = ct.get_result(dispatch_id=dispatch_id)
+
+    time_taken = (result.end_time - result.start_time).total_seconds()
+    print(f"Time taken: {time_taken}")
+
+    assert result.status == Result.COMPLETED
+
+
+def start_dask_cluster():
+
+    from dask.distributed import LocalCluster
+
+    cluster = LocalCluster()
+
+    return cluster.scheduler_address
+
+
+if __name__ == "__main__":
+
+    scheduler_address = start_dask_cluster()
+
+    print(f"LocalCluster started at scheduler address: {scheduler_address}")
+
+    test_dask_executor(scheduler_address)
diff --git a/tests/requirements.txt b/tests/requirements.txt
index 533566c5b..7be83ee71 100644
--- a/tests/requirements.txt
+++ b/tests/requirements.txt
@@ -1,3 +1,4 @@
+dask[distributed]==2022.1.0
 flake8==3.9.2
 isort==5.7.0
 mock==4.0.3