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

Allow Ramble to track the origin of a FOM #229

Merged
merged 2 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 14 additions & 4 deletions lib/ramble/ramble/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,9 @@ def format_context(context_match, context_format):
(context, context_name))

active_contexts[context] = context_name
fom_values[context_name] = {}

if context_name not in fom_values:
fom_values[context_name] = {}

for fom in file_conf['foms']:
fom_conf = foms[fom]
Expand Down Expand Up @@ -1119,7 +1121,9 @@ def format_context(context_match, context_format):
fom_val = fom_match.group(fom_conf['group'])
fom_values[context][fom_name] = {
'value': fom_val,
'units': fom_conf['units']
'units': fom_conf['units'],
'origin': fom_conf['origin'],
'origin_type': fom_conf['origin_type']
}

# Test all non-file based success criteria
Expand Down Expand Up @@ -1220,14 +1224,18 @@ def _analysis_dicts(self, criteria_list):
# Remap fom / context / file data
# Could push this into the language features in the future
fom_definitions = self.figures_of_merit.copy()
for fom, fom_def in fom_definitions.items():
fom_def['origin'] = self.name
fom_def['origin_type'] = 'application'

fom_contexts = self.figure_of_merit_contexts.copy()
for mod in self._modifier_instances:
fom_contexts.update(mod.figure_of_merit_contexts)

mod_vars = mod.modded_variables(self)

for fom, fom_def in mod.figures_of_merit.items():
fom_definitions[fom] = {}
fom_definitions[fom] = {'origin': f'{mod}', 'origin_type': 'modifier'}
for attr in fom_def.keys():
if isinstance(fom_def[attr], list):
fom_definitions[fom][attr] = fom_def[attr].copy()
Expand All @@ -1251,7 +1259,9 @@ def _analysis_dicts(self, criteria_list):
'regex': re.compile(r'%s' % conf['regex']),
'contexts': [],
'group': conf['group_name'],
'units': conf['units']
'units': conf['units'],
'origin': conf['origin'],
'origin_type': conf['origin_type']
}
if conf['contexts']:
foms[fom]['contexts'].extend(conf['contexts'])
Expand Down
2 changes: 1 addition & 1 deletion lib/ramble/ramble/language/shared_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def _execute_success_criteria(obj):
'file': file,
'fom_name': fom_name,
'fom_context': fom_context,
'formula': formula,
'formula': formula
douglasjacobsen marked this conversation as resolved.
Show resolved Hide resolved
}

return _execute_success_criteria
Expand Down
8 changes: 7 additions & 1 deletion lib/ramble/ramble/workspace/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,13 @@ def dump_results(self, output_formats=['text']):
f.write(' %s figures of merit:\n' %
context['name'])
for fom in context['foms']:
output = '%s = %s %s' % (fom['name'],
name = fom['name']
if fom['origin_type'] == 'modifier':
delim = '::'
mod = fom['origin']
name = f"{fom['origin_type']}{delim}{mod}{delim}{name}"

output = '%s = %s %s' % (name,
fom['value'],
fom['units'])
f.write(' %s\n' % (output.strip()))
Expand Down