Repository: AgnostiqHQ/covalent
Pull request #1351 (2022-10-14 19:38:13)

Re-applying default executor fix post config file reunification
- [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.


codecov[bot]: # [Codecov](https://codecov.io/gh/AgnostiqHQ/covalent/pull/1351?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AgnostiqHQ) Report
> Merging [#1351](https://codecov.io/gh/AgnostiqHQ/covalent/pull/1351?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AgnostiqHQ) (aab84c3) into [develop](https://codecov.io/gh/AgnostiqHQ/covalent/commit/bfca772502c34d33ff9c5417e4e3bfb700136806?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AgnostiqHQ) (bfca772) will **increase** coverage by `5.68%`.
> The diff coverage is `100.00%`.

<details><summary>Additional details and impacted files</summary>


[![Impacted file tree graph](https://codecov.io/gh/AgnostiqHQ/covalent/pull/1351/graphs/tree.svg?width=650&height=150&src=pr&token=YGHCB3DE4P&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AgnostiqHQ)](https://codecov.io/gh/AgnostiqHQ/covalent/pull/1351?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AgnostiqHQ)

```diff
@@             Coverage Diff             @@
##           develop    #1351      +/-   ##
===========================================
+ Coverage    75.63%   81.32%   +5.68%     
===========================================
  Files          140       64      -76     
  Lines         5459     3780    -1679     
  Branches       141        0     -141     
===========================================
- Hits          4129     3074    -1055     
+ Misses        1211      706     -505     
+ Partials       119        0     -119     
```

| Flag | Coverage Δ | | *Carryforward flag |
|---|---|---|---|
| Dispatcher | `85.09% <ø> (ø)` | | Carriedforward from [bfca772](https://codecov.io/gh/AgnostiqHQ/covalent/commit/bfca772502c34d33ff9c5417e4e3bfb700136806?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AgnostiqHQ) |
| Functional_Tests | `?` | | |
| SDK | `78.85% <100.00%> (ø)` | | |
| UI_Frontend | `?` | | |

*This pull request uses carry forward flags. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AgnostiqHQ) to find out more.

</details>

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 19ec5474..0ad4ecf2 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
+
+- Re-applying default executor fix post config file reunification
+
 ## [0.203.0-rc.0] - 2022-10-14
 
 ### Authors
diff --git a/covalent/_shared_files/defaults.py b/covalent/_shared_files/defaults.py
index ba81a6f7..b459689c 100644
--- a/covalent/_shared_files/defaults.py
+++ b/covalent/_shared_files/defaults.py
@@ -126,7 +126,7 @@ def get_default_executor() -> dict:
     """
     from .config import get_config
 
-    return "local" if get_config("sdk.no_cluster") else "dask"
+    return "local" if get_config("sdk.no_cluster") == "true" else "dask"
 
 
 # Default configuration settings


Test patch:
diff --git a/tests/covalent_tests/shared_files/defaults_test.py b/tests/covalent_tests/shared_files/defaults_test.py
new file mode 100644
index 00000000..be26fbfb
--- /dev/null
+++ b/tests/covalent_tests/shared_files/defaults_test.py
@@ -0,0 +1,96 @@
+# 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.
+
+"""Unit tests for the defaults module"""
+
+import os
+from unittest import mock
+
+import pytest
+
+
+@pytest.fixture
+def env_vars(mocker):
+    mocker.patch("logging.getLogger")
+    mocker.patch("logging.StreamHandler")
+    return {
+        "HOME": "test_home",
+        "LOGLEVEL": "TEST_LOG_LEVEL",
+        "COVALENT_LOG_TO_FILE": "test_log",
+        "COVALENT_EXECUTOR_DIR": "test_exec_dir",
+        "COVALENT_DISPATCHER_ADDR": "test_dispatcher_addr",
+        "COVALENT_SVC_PORT": "0000",
+        "COVALENT_SERVER_IFACE_ANY": "test_server_iface",
+        "COVALENT_DEV_PORT": "1111",
+        "COVALENT_RESULTS_DIR": "test_results_dir",
+    }
+
+
+def test_get_default_sdk_config(env_vars, mocker):
+    """Tests that the default SDK configuration is as expected"""
+
+    with mock.patch.dict(os.environ, env_vars, clear=True):
+        from covalent._shared_files.defaults import get_default_sdk_config
+
+        received_config = get_default_sdk_config()
+
+        assert received_config["config_file"] == "test_home/.config/covalent/covalent.conf"
+        assert received_config["log_dir"] == "test_home/.cache/covalent"
+        assert received_config["log_level"] == "test_log_level"
+        assert received_config["enable_logging"] == "test_log"
+        assert received_config["executor_dir"] == "test_exec_dir"
+        assert received_config["no_cluster"] == "false"
+
+
+def test_get_default_dask_config(env_vars):
+    """Tests that the default dask configuration is as expected"""
+
+    with mock.patch.dict(os.environ, env_vars, clear=True):
+        from covalent._shared_files.defaults import get_default_dask_config
+
+        received_config = get_default_dask_config()
+
+        assert received_config["cache_dir"] == "test_home/.cache/covalent"
+        assert received_config["log_dir"] == "test_home/.cache/covalent"
+
+
+def test_get_default_workflow_data_config(env_vars):
+    """Tests that the default workflow data configuration is as expected"""
+
+    with mock.patch.dict(os.environ, env_vars, clear=True):
+        from covalent._shared_files.defaults import get_default_workflow_data_config
+
+        received_config = get_default_workflow_data_config()
+
+        assert received_config["base_dir"] == "test_home/.local/share/covalent/workflow_data"
+
+
+def test_get_default_executor():
+    """Tests whether the default executor is set as expected"""
+
+    with mock.patch("covalent._shared_files.config.get_config", return_value="true"):
+        from covalent._shared_files.defaults import get_default_executor
+
+        assert get_default_executor() == "local"
+
+    with mock.patch("covalent._shared_files.config.get_config", return_value="false"):
+        from covalent._shared_files.defaults import get_default_executor
+
+        assert get_default_executor() == "dask"