-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #691 from douglasjacobsen/software-generate
Front-end commands for managing software
- Loading branch information
Showing
5 changed files
with
513 additions
and
23 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 |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# Copyright 2022-2024 The Ramble Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
# https://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
# <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your | ||
# option. This file may not be copied, modified, or distributed | ||
# except according to those terms. | ||
|
||
import pytest | ||
|
||
import ramble.workspace | ||
import ramble.config | ||
import ramble.software_environments | ||
from ramble.main import RambleCommand | ||
|
||
|
||
# everything here uses the mock_workspace_path | ||
pytestmark = pytest.mark.usefixtures("mutable_config", "mutable_mock_workspace_path") | ||
|
||
workspace = RambleCommand("workspace") | ||
|
||
|
||
def test_manage_software(mutable_config, mutable_mock_workspace_path): | ||
workspace_name = "test_manage_software" | ||
with ramble.workspace.create(workspace_name) as ws1: | ||
ws1.write() | ||
|
||
config_path = ws1.config_file_path | ||
|
||
workspace( | ||
"manage", | ||
"experiments", | ||
"wrfv4", | ||
"-v", | ||
"n_ranks=1", | ||
"-v", | ||
"n_nodes=1", | ||
"-p", | ||
"spack", | ||
global_args=["-w", workspace_name], | ||
) | ||
workspace("concretize", global_args=["-w", workspace_name]) | ||
|
||
ws1._re_read() | ||
|
||
with open(config_path) as f: | ||
content = f.read() | ||
# Check that wrf has a package, and the package is in an environment | ||
assert "pkg_spec: wrf" in content | ||
assert "- wrfv4" in content | ||
|
||
# Check that intel-mpi was defined | ||
assert "intel-mpi" in content | ||
|
||
# Check that gcc was defined | ||
assert "[email protected]" in content | ||
|
||
# Check that the (soon to be new) definition of gcc is not defined | ||
assert "[email protected]" not in content | ||
|
||
# Change the GCC package definition | ||
workspace( | ||
"manage", | ||
"software", | ||
"--pkg", | ||
"gcc9", | ||
"--overwrite", | ||
"--package-spec", | ||
"[email protected]", | ||
global_args=["-w", workspace_name], | ||
) | ||
|
||
with open(config_path) as f: | ||
content = f.read() | ||
assert "[email protected]" in content | ||
|
||
# Delete configs for wrf | ||
workspace( | ||
"manage", | ||
"software", | ||
"--remove", | ||
"--env", | ||
"wrfv4", | ||
"--pkg", | ||
"wrfv4", | ||
global_args=["-w", workspace_name], | ||
) | ||
workspace( | ||
"manage", | ||
"software", | ||
"--remove", | ||
"--pkg", | ||
"intel-mpi", | ||
global_args=["-w", workspace_name], | ||
) | ||
workspace( | ||
"manage", "software", "--remove", "--pkg", "gcc9", global_args=["-w", workspace_name] | ||
) | ||
workspace( | ||
"manage", | ||
"software", | ||
"--env", | ||
"foo", | ||
"--environment-packages", | ||
"bar,baz", | ||
global_args=["-w", workspace_name], | ||
) | ||
|
||
with open(config_path) as f: | ||
content = f.read() | ||
|
||
# Check that new env definitions are found | ||
assert "foo" in content | ||
assert "bar" in content | ||
assert "baz" in content | ||
|
||
# Check that removed definitions no longer exist | ||
assert "intel-mpi" not in content | ||
assert "gcc" not in content | ||
assert "- wrf" not in content |
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,30 @@ | ||
# Copyright 2022-2024 The Ramble Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
# https://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
# <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your | ||
# option. This file may not be copied, modified, or distributed | ||
# except according to those terms. | ||
|
||
|
||
def list_str_to_list(in_str): | ||
"""Convert a comma delimited list as a string into a python list | ||
Args: | ||
in_str (str): Input string, comma delimited list of values | ||
Returns: | ||
(list) Each value from input string is a separate entry in the list. | ||
""" | ||
if "[" not in in_str and "]" not in in_str: | ||
return in_str | ||
|
||
temp = in_str.replace("[", "").replace("]", "") | ||
out_value = [] | ||
for part in temp.split(","): | ||
if part[0] == " ": | ||
out_value.append(part[1:]) | ||
else: | ||
out_value.append(part) | ||
return out_value |
Oops, something went wrong.