Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix '--where' experiment index filter on info #642

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/ramble/ramble/cmd/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,18 @@ def workspace_info(args):
print_experiment_set.set_experiment_context(experiment_context)
print_experiment_set.build_experiment_chains()

# Reindex the experiments in the print set to match the overall set
for exp_name, _, _ in print_experiment_set.all_experiments():
app_inst = experiment_set.get_experiment(exp_name)
experiment_index = app_inst.expander.expand_var_name(
app_inst.keywords.experiment_index
)

print_app_inst = print_experiment_set.get_experiment(exp_name)
print_app_inst.define_variable(
print_app_inst.keywords.experiment_index, experiment_index
)

print_header = True
# Define variable printing groups.
var_indent = " "
Expand Down
62 changes: 62 additions & 0 deletions lib/ramble/ramble/test/cmd/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,68 @@ def test_workspace_info_with_experiment_chain():
assert "- basic.test_wl2.test_experiment.chain.0.basic.test_wl.test_experiment" in output


def test_workspace_info_with_where_filter():
test_config = """
ramble:
variables:
mpi_command: 'mpirun -n {n_ranks} -ppn {processes_per_node}'
batch_submit: 'batch_submit {execute_experiment}'
processes_per_node: '5'
n_ranks: '{processes_per_node}*{n_nodes}'
applications:
basic:
workloads:
test_wl:
experiments:
test_experiment:
variables:
n_nodes: '2'
test_wl2:
experiments:
test_experiment:
variables:
n_nodes: '2'
zlib:
workloads:
ensure_installed:
experiments:
test_experiment:
variables:
n_nodes: '2'
software:
packages:
zlib:
pkg_spec: 'zlib'
environments:
zlib:
packages:
- zlib
"""

workspace_name = "test_info"
ws1 = ramble.workspace.create(workspace_name)
ws1.write()

config_path = os.path.join(ws1.config_dir, ramble.workspace.config_file_name)

with open(config_path, "w+") as f:
f.write(test_config)

ws1._re_read()

output = workspace(
"info",
"--software",
"--where",
'"{experiment_index}" == "1"',
global_args=["-w", workspace_name],
)

assert "basic.test_wl.test_experiment" in output
assert "basic.test_wl2.test_experiment" not in output
assert "zlib.ensure_installed.test_experiment" not in output


def test_workspace_dir(tmpdir):
with tmpdir.as_cwd():
workspace("create", "-d", ".")
Expand Down