Repository: AgnostiqHQ/covalent (language: python)

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



Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 494554beb..52b206b4e 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 d82ce0b91..fdf3b4c82 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 18ca81414..2ef8461b2 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",
     [