-
Notifications
You must be signed in to change notification settings - Fork 27
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 #229 from rfbgo/modifier_scope
Allow Ramble to track the origin of a FOM
- Loading branch information
Showing
6 changed files
with
148 additions
and
6 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
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,87 @@ | ||
# Copyright 2022-2023 Google LLC | ||
# | ||
# 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 os | ||
import glob | ||
|
||
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', | ||
'mock_applications', | ||
'mock_modifiers', | ||
) | ||
|
||
workspace = RambleCommand('workspace') | ||
|
||
|
||
def test_shared_contexts( | ||
mutable_config, | ||
mutable_mock_workspace_path, | ||
mock_applications, | ||
mock_modifiers): | ||
test_config = """ | ||
ramble: | ||
variables: | ||
mpi_command: 'mpirun -n {n_ranks} -ppn {processes_per_node}' | ||
batch_submit: 'batch_submit {execute_experiment}' | ||
partition: 'part1' | ||
processes_per_node: '1' | ||
n_threads: '1' | ||
applications: | ||
shared-context: | ||
workloads: | ||
test_wl: | ||
experiments: | ||
simple_test: | ||
modifiers: | ||
- name: test-mod | ||
variables: | ||
n_nodes: 1 | ||
spack: | ||
concretized: true | ||
packages: {} | ||
environments: {} | ||
""" | ||
workspace_name = 'test_shared_context' | ||
with ramble.workspace.create(workspace_name) as ws: | ||
ws.write() | ||
|
||
config_path = os.path.join(ws.config_dir, ramble.workspace.config_file_name) | ||
|
||
with open(config_path, 'w+') as f: | ||
f.write(test_config) | ||
ws._re_read() | ||
|
||
workspace('setup', '--dry-run', global_args=['-w', workspace_name]) | ||
|
||
# Create fake figures of merit. | ||
exp_dir = os.path.join(ws.root, 'experiments', 'shared-context', 'test_wl', 'simple_test') | ||
with open(os.path.join(exp_dir, 'simple_test.out'), 'w+') as f: | ||
f.write('fom_context mod_context\n') | ||
f.write('123.4 seconds app_fom\n') | ||
|
||
with open(os.path.join(exp_dir, 'test_analysis.log'), 'w+') as f: | ||
f.write("fom_contextFOM_GOES_HERE") | ||
|
||
workspace('analyze', '-f', 'text', 'json', global_args=['-w', workspace_name]) | ||
|
||
results_files = glob.glob(os.path.join(ws.root, 'results.latest.txt')) | ||
|
||
with open(results_files[0], 'r') as f: | ||
data = f.read() | ||
assert 'matched_shared_context' in data # find the merged context | ||
assert 'test_fom = 123.4' in data # from the app | ||
assert 'shared_context_fom' in data # from the mod |
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
34 changes: 34 additions & 0 deletions
34
var/ramble/repos/builtin.mock/applications/shared-context/application.py
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,34 @@ | ||
# Copyright 2022-2023 Google LLC | ||
# | ||
# 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. | ||
|
||
from ramble.appkit import * | ||
|
||
|
||
class SharedContext(ExecutableApplication): | ||
name = "shared-context" | ||
|
||
executable('foo', 'bar', use_mpi=False) | ||
executable('bar', 'baz', use_mpi=True) | ||
|
||
input_file('input', url='file:///tmp/test_file.log', | ||
description='Not a file', extension='.log') | ||
|
||
workload('test_wl', executable='foo', input='input') | ||
workload('test_wl2', executable='bar', input='input') | ||
|
||
workload_variable('my_var', default='1.0', | ||
description='Example var', | ||
workload='test_wl') | ||
|
||
archive_pattern('{experiment_run_dir}/archive_test.*') | ||
|
||
figure_of_merit('test_fom', | ||
fom_regex=r'(?P<test>[0-9]+\.[0-9]+).*seconds.*', | ||
group_name='test', units='s', contexts=['test_shared_context']) | ||
|
||
figure_of_merit_context('test_shared_context', regex=r'(?P<test>[0-9]+\.[0-9]+).*seconds.*', output_format='matched_shared_context') |
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