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 removal of scalars, and ignoring modifier variables #452

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
7 changes: 7 additions & 0 deletions lib/ramble/ramble/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,20 @@ def build_used_variables(self, workspace):
Returns:
(set): All variable names used by this experiment.
"""
self.build_modifier_instances()
self.add_expand_vars(workspace)

# Add all known keywords
for key in self.keywords.keys:
self.expander._used_variables.add(key)
self.expander.expand_var_name(key)

# Add modifier mode variables:
for mod_inst in self._modifier_instances:
for var in mod_inst.mode_variables().keys():
self.expander._used_variables.add(var)
self.expander.expand_var_name(var)

if self.chained_experiments:
for chained_exp in self.chained_experiments:
if namespace.inherit_variables in chained_exp:
Expand Down
2 changes: 1 addition & 1 deletion lib/ramble/ramble/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def render_objects(self, render_group, exclude_where=None, remove=True, fatal=Tr
# Remove any variables that are not used by the render group
all_vars = set(object_variables.keys())
for var in all_vars:
if var not in used_variables:
if var not in used_variables and isinstance(object_variables[var], list):
del object_variables[var]

if zips:
Expand Down
22 changes: 11 additions & 11 deletions lib/ramble/ramble/test/experiment_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ def test_chained_invalid_order_errors(mutable_mock_workspace_path, capsys):
assert "Invalid experiment chain defined:" in captured


def test_modifiers_set_correctly(mutable_mock_workspace_path, capsys):
def test_modifiers_set_correctly(mutable_mock_workspace_path, mock_modifiers, capsys):
workspace('create', 'test')

assert 'test' in workspace('list')
Expand All @@ -1287,8 +1287,8 @@ def test_modifiers_set_correctly(mutable_mock_workspace_path, capsys):
}
application_context.modifiers = [
{
'name': 'test_app_mod',
'mode': 'test_app',
'name': 'test-mod',
'mode': 'app-scope',
'on_executable': [
'builtin::env_vars'
]
Expand All @@ -1303,8 +1303,8 @@ def test_modifiers_set_correctly(mutable_mock_workspace_path, capsys):
}
workload_context.modifiers = [
{
'name': 'test_wl_mod',
'mode': 'test_wl',
'name': 'test-mod',
'mode': 'wl-scope',
'on_executable': [
'builtin::env_vars'
]
Expand All @@ -1318,8 +1318,8 @@ def test_modifiers_set_correctly(mutable_mock_workspace_path, capsys):
}
experiment_context.modifiers = [
{
'name': 'test_exp1_mod',
'mode': 'test_exp1',
'name': 'test-mod',
'mode': 'exp-scope',
'on_executable': [
'builtin::env_vars'
]
Expand All @@ -1334,11 +1334,11 @@ def test_modifiers_set_correctly(mutable_mock_workspace_path, capsys):
app_inst = exp_set.experiments['basic.test_wl.test1']
assert app_inst.modifiers is not None

expected_modifiers = set(['test_app_mod', 'test_wl_mod', 'test_exp1_mod'])
expected_modifier_modes = set(['app-scope', 'wl-scope', 'exp-scope'])
for mod_def in app_inst.modifiers:
assert mod_def['name'] in expected_modifiers
expected_modifiers.remove(mod_def['name'])
assert len(expected_modifiers) == 0
assert mod_def['mode'] in expected_modifier_modes
expected_modifier_modes.remove(mod_def['mode'])
assert len(expected_modifier_modes) == 0


def test_explicit_zips_work(mutable_mock_workspace_path):
Expand Down
7 changes: 7 additions & 0 deletions var/ramble/repos/builtin.mock/modifiers/test-mod/modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ class TestMod(BasicModifier):
tags('test')

mode('test', description='This is a test mode')
default_mode('test')

mode('app-scope', description='This is a test mode at the application scope')

mode('wl-scope', description='This is a test mode at the workload scope')

mode('exp-scope', description='This is a test mode at the experiment scope')

variable_modification('mpi_command', 'echo "prefix_mpi_command" >> {log_file}; ', method='prepend', modes=['test'])

Expand Down
Loading