Repository: AgnostiqHQ/covalent (python)

Issue:
covalebt start + covalent restart starts covalent with no cluster 

Pull request description:
Preserve value of `sdk.no_cluster` when restarting Covalent
<!--
⚠️ 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.
-->

- [x] I have added the tests to cover my changes.
- [x] I have updated the documentation and CHANGELOG accordingly.
- [x] I have read the CONTRIBUTING document.

Closes #1355 

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 494554be..52b206b4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,9 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [UNRELEASED]
 
+### Fixed
+
+- `covalent restart` honors the `sdk.no_cluster` setting
+
 ### Docs
 
 - Updated RTD with details about the new AWS lambda executor interface
+
 ### Operations
 
 - Removed PAUL_BLART check on build sdist step in release.yml
diff --git a/covalent_dispatcher/_cli/service.py b/covalent_dispatcher/_cli/service.py
index d82ce0b9..fdf3b4c8 100644
--- a/covalent_dispatcher/_cli/service.py
+++ b/covalent_dispatcher/_cli/service.py
@@ -304,7 +304,7 @@ def start(
     ctx: click.Context,
     port: int,
     develop: bool,
-    no_cluster: bool,
+    no_cluster: str,
     mem_per_worker: str,
     threads_per_worker: int,
     workers: int,
@@ -365,13 +365,14 @@ def restart(ctx, port: bool, develop: bool) -> None:
     Restart the server.
     """
 
+    no_cluster_map = {"true": True, "false": False}
     configuration = {
         "port": port or get_config("user_interface.port"),
         "develop": develop or (get_config("sdk.log_level") == "debug"),
-        "no_cluster": get_config("user_interface.port"),
+        "no_cluster": no_cluster_map[get_config("sdk.no_cluster")],
         "mem_per_worker": get_config("dask.mem_per_worker"),
         "threads_per_worker": get_config("dask.threads_per_worker"),
-        "workers": set_config("dask.num_workers"),
+        "workers": get_config("dask.num_workers"),
     }
 
     ctx.invoke(stop)


Test patch:
diff --git a/tests/covalent_dispatcher_tests/_cli/service_test.py b/tests/covalent_dispatcher_tests/_cli/service_test.py
index 18ca8141..2ef8461b 100644
--- a/tests/covalent_dispatcher_tests/_cli/service_test.py
+++ b/tests/covalent_dispatcher_tests/_cli/service_test.py
@@ -283,9 +283,21 @@ def test_stop(mocker, monkeypatch):
 def test_restart(mocker, port_tag, port, pid, server, restart_called, start_called, stop_called):
     """Test the restart CLI command."""
 
+    mock_config_map = {
+        "user_interface.port": port,
+        "sdk.log_level": "debug",
+        "sdk.no_cluster": "true",
+        "dask.mem_per_worker": 1024,
+        "dask.threads_per_worker": 2,
+        "dask.num_workers": 4,
+    }
+
+    def mock_config(key):
+        return mock_config_map[key]
+
     start = mocker.patch("covalent_dispatcher._cli.service.start")
     stop = mocker.patch("covalent_dispatcher._cli.service.stop")
-    mocker.patch("covalent_dispatcher._cli.service.get_config", return_value=port)
+    mocker.patch("covalent_dispatcher._cli.service.get_config", mock_config)
 
     obj = mocker.MagicMock()
     mocker.patch("covalent_dispatcher._cli.service._read_pid", return_value=pid)
@@ -296,6 +308,49 @@ def test_restart(mocker, port_tag, port, pid, server, restart_called, start_call
     assert stop.called is stop_called
 
 
+@pytest.mark.parametrize(
+    "port_tag,port,pid,server,no_cluster",
+    [
+        ("port", 42, 100, "ui", "true"),
+        ("port", 42, 100, "ui", "false"),
+    ],
+)
+def test_restart_preserves_nocluster(mocker, port_tag, port, pid, server, no_cluster):
+    """Test the restart CLI command preserves the setting of sdk.no_cluster."""
+
+    mock_config_map = {
+        "user_interface.port": port,
+        "sdk.log_level": "debug",
+        "sdk.no_cluster": no_cluster,
+        "dask.mem_per_worker": 1024,
+        "dask.threads_per_worker": 2,
+        "dask.num_workers": 4,
+    }
+    no_cluster_map = {"true": True, "false": False}
+
+    def mock_config(key):
+        return mock_config_map[key]
+
+    start = mocker.patch("covalent_dispatcher._cli.service.start")
+    stop = mocker.patch("covalent_dispatcher._cli.service.stop")
+    mocker.patch("covalent_dispatcher._cli.service.get_config", mock_config)
+
+    obj = mocker.MagicMock()
+    mocker.patch("covalent_dispatcher._cli.service._read_pid", return_value=pid)
+
+    configuration = {
+        "port": mock_config_map["user_interface.port"],
+        "develop": (mock_config_map["sdk.log_level"] == "debug"),
+        "no_cluster": no_cluster_map[mock_config_map["sdk.no_cluster"]],
+        "mem_per_worker": mock_config_map["dask.mem_per_worker"],
+        "threads_per_worker": mock_config_map["dask.threads_per_worker"],
+        "workers": mock_config_map["dask.num_workers"],
+    }
+    runner = CliRunner()
+    runner.invoke(restart, f"--{port_tag} {port}", obj=obj)
+    start.assert_called_with(**configuration)
+
+
 @pytest.mark.parametrize(
     "port_val,pid,echo_output,file_removed,pid_exists",
     [