-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure proper conversion of 'cache_docker_images_locally' to boolean
- Loading branch information
1 parent
c97c6c6
commit 96ae3f8
Showing
2 changed files
with
88 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
from typing import Any, Dict | ||
|
||
import pytest | ||
from cloudai.parser.system_parser.slurm_system_parser import SlurmSystemParser | ||
from cloudai.systems.slurm import SlurmSystem | ||
|
||
|
||
@pytest.fixture | ||
def example_data() -> Dict[str, Any]: | ||
return { | ||
"name": "test_system", | ||
"install_path": "/fake/path", | ||
"output_path": "/fake/output", | ||
"default_partition": "main", | ||
"partitions": { | ||
"main": { | ||
"name": "main", | ||
"nodes": ["node-[033-034]"], | ||
"groups": {"group1": {"name": "group1", "nodes": ["node-033"]}}, | ||
}, | ||
"backup": { | ||
"name": "backup", | ||
"nodes": ["node-[01-02]"], | ||
"groups": {"group2": {"name": "group2", "nodes": ["node-01"]}}, | ||
}, | ||
}, | ||
"cache_docker_images_locally": "True", | ||
} | ||
|
||
|
||
def test_parse_slurm_system_parser(example_data): | ||
parser = SlurmSystemParser() | ||
slurm_system = parser.parse(example_data) | ||
|
||
assert isinstance(slurm_system, SlurmSystem) | ||
assert slurm_system.name == "test_system" | ||
assert slurm_system.install_path == "/fake/path" | ||
assert slurm_system.output_path == "/fake/output" | ||
assert slurm_system.default_partition == "main" | ||
assert slurm_system.cache_docker_images_locally is True | ||
assert "main" in slurm_system.partitions | ||
assert "backup" in slurm_system.partitions | ||
assert "group1" in slurm_system.groups["main"] | ||
assert "group2" in slurm_system.groups["backup"] | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"input_value, expected_result", | ||
[ | ||
("True", True), | ||
("False", False), | ||
("true", True), | ||
("false", False), | ||
("1", True), | ||
("0", False), | ||
("yes", True), | ||
("no", False), | ||
], | ||
) | ||
def test_str_to_bool_conversion(input_value, expected_result): | ||
parser = SlurmSystemParser() | ||
result = parser.parse( | ||
{ | ||
"name": "test_system", | ||
"install_path": "/fake/path", | ||
"output_path": "/fake/output", | ||
"default_partition": "main", | ||
"partitions": { | ||
"main": { | ||
"name": "main", | ||
"nodes": ["node-[033-034]"], | ||
"groups": {"group1": {"name": "group1", "nodes": ["node-033"]}}, | ||
}, | ||
"backup": { | ||
"name": "backup", | ||
"nodes": ["node-[01-02]"], | ||
"groups": {"group2": {"name": "group2", "nodes": ["node-01"]}}, | ||
}, | ||
}, | ||
"cache_docker_images_locally": input_value, | ||
} | ||
) | ||
|
||
assert result.cache_docker_images_locally == expected_result |