-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* If a user's configuration file is missing a parameter, the default parameter is used. * Updated CHANGELOG and VERSION. * Instead of setting configuration data to _DEFAULT_CONFIG, it is set to a copy so that further modification doesn't modify _DEFAULT_CONFIG. * Added tests for 2 configuration file operations. * Updated date in CHANGELOG. * Added a sample covalent.conf file for configuration tests. * Mocked the config file location for configuration unit tests. * Attempting again to mock configuration file location in config tests. * Attempting again to mock configuration file location in config tests. * Attempting again to mock configuration file location in config tests in pipeline. * Fixed a path error in config_test.py. * Updated VERSION * Change global varialbe to all-caps in config_test.py. * Moved config_test.py (and its test files) to covalent_tests/shared_files/.
- Loading branch information
Showing
7 changed files
with
208 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.24.7 | ||
0.24.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
# 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 os | ||
from unittest.mock import patch | ||
|
||
from covalent._shared_files.config import _ConfigManager | ||
|
||
CONFIG_DIR = os.path.join(os.path.dirname(__file__), "test_files") | ||
|
||
|
||
@patch.dict(os.environ, {"COVALENT_CONFIG_DIR": CONFIG_DIR}, clear=True) | ||
def test_read_config(): | ||
"""Test that configuration file is properly read""" | ||
|
||
config_manager = _ConfigManager() | ||
config_manager.read_config() | ||
|
||
expected_dict = { | ||
"sdk": {"log_dir": "./", "log_level": "warning", "enable_logging": "false"}, | ||
"executors": { | ||
"local": { | ||
"log_stdout": "stdout.log", | ||
"log_stderr": "stderr.log", | ||
"cache_dir": "/tmp/covalent", | ||
"other_params": {"name": "Local Executor", "proprietary": "False"}, | ||
}, | ||
"local_executor": "local.py", | ||
"slurm_executor": "slurmp.py", | ||
"ssh_executor": "ssh_executor.py", | ||
}, | ||
"test_dict": { | ||
"1": 2, | ||
"3": 4, | ||
}, | ||
} | ||
|
||
assert config_manager.config_data == expected_dict | ||
|
||
|
||
@patch.dict(os.environ, {"COVALENT_CONFIG_DIR": CONFIG_DIR}, clear=True) | ||
def test_update_config(): | ||
"""Test that updating the existing config data with the config file works""" | ||
|
||
config_manager = _ConfigManager() | ||
config_manager.config_data = { | ||
"sdk": { | ||
"test_dir": "/tmp", | ||
"log_dir": { | ||
"dir_one": "/var", | ||
"dir_two": "~/.log_dir", | ||
}, | ||
"log_level": "debug", | ||
"enable_logging": "true", | ||
}, | ||
"executors": { | ||
"local": { | ||
"other_params": { | ||
"proprietary": "true", | ||
"params_test_dict": { | ||
"a": "b", | ||
"c": "d", | ||
}, | ||
} | ||
}, | ||
"executor_test_dict": { | ||
"alpha": "beta", | ||
"gamma": "delta", | ||
}, | ||
}, | ||
"test_dict": None, | ||
} | ||
config_manager.update_config() | ||
|
||
expected_dict = { | ||
"sdk": { | ||
"test_dir": "/tmp", | ||
"log_dir": "./", | ||
"log_level": "warning", | ||
"enable_logging": "false", | ||
}, | ||
"executors": { | ||
"local": { | ||
"log_stdout": "stdout.log", | ||
"log_stderr": "stderr.log", | ||
"cache_dir": "/tmp/covalent", | ||
"other_params": { | ||
"name": "Local Executor", | ||
"proprietary": "False", | ||
"params_test_dict": { | ||
"a": "b", | ||
"c": "d", | ||
}, | ||
}, | ||
}, | ||
"local_executor": "local.py", | ||
"slurm_executor": "slurmp.py", | ||
"ssh_executor": "ssh_executor.py", | ||
"executor_test_dict": { | ||
"alpha": "beta", | ||
"gamma": "delta", | ||
}, | ||
}, | ||
"test_dict": { | ||
"1": 2, | ||
"3": 4, | ||
}, | ||
} | ||
|
||
assert config_manager.config_data == expected_dict |
22 changes: 22 additions & 0 deletions
22
tests/covalent_tests/shared_files/test_files/covalent/covalent.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[sdk] | ||
log_dir = "./" | ||
log_level = "warning" | ||
enable_logging = "false" | ||
|
||
[executors.local] | ||
log_stdout = "stdout.log" | ||
log_stderr = "stderr.log" | ||
cache_dir = "/tmp/covalent" | ||
|
||
[executors] | ||
local_executor = "local.py" | ||
slurm_executor = "slurmp.py" | ||
ssh_executor = "ssh_executor.py" | ||
|
||
[executors.local.other_params] | ||
name = "Local Executor" | ||
proprietary = "False" | ||
|
||
[test_dict] | ||
1 = 2 | ||
3 = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[sdk] | ||
log_dir = "./" | ||
log_level = "warning" | ||
enable_logging = "false" | ||
|
||
[executors.local] | ||
log_stdout = "stdout.log" | ||
log_stderr = "stderr.log" | ||
cache_dir = "/tmp/covalent" | ||
|
||
[executors] | ||
local_executor = "local.py" | ||
slurm_executor = "slurmp.py" | ||
ssh_executor = "ssh_executor.py" | ||
|
||
[executors.local.other_params] | ||
name = "Local Executor" | ||
proprietary = "False" | ||
|
||
[test_dict] | ||
1 = 2 | ||
3 = 4 |