Skip to content

Commit 2085766

Browse files
committed
Rename to avoid inmem confusion
1 parent 907c05c commit 2085766

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

lib/ramble/ramble/language/shared_language.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def figure_of_merit(
105105
contexts=None,
106106
fom_type: FomType = FomType.UNDEFINED,
107107
when=None,
108-
inmem_key=None,
108+
fom_map_key=None,
109109
**kwargs,
110110
):
111111
"""Adds a figure of merit to track for this object
@@ -123,12 +123,12 @@ def figure_of_merit(
123123
should exist in.
124124
fom_type (ramble.util.foms.FomType): The type of figure of merit
125125
when (list | None): List of when conditions to apply to directive
126-
inmem_key: If supplied, this is treated as an in-memory (as ooposed to file-based)
127-
figure of merit, and its value is extracted using this key
126+
fom_map_key: If supplied, this is treated as an in-memory (as ooposed to file-based)
127+
figure of merit, and its value is extracted using this key
128128
"""
129129

130130
def _execute_figure_of_merit(obj):
131-
if inmem_key is None:
131+
if fom_map_key is None:
132132
if fom_regex is None or group_name is None:
133133
raise ramble.language.language_base.DirectiveError(
134134
"`fom_regex` and `group_name` are required for defining file-based FOM"
@@ -154,7 +154,7 @@ def _execute_figure_of_merit(obj):
154154
"fom_type": fom_type,
155155
"when": when_list,
156156
"origin_type": obj.origin_type if hasattr(obj, "origin_type") else "",
157-
"inmem_key": inmem_key,
157+
"fom_map_key": fom_map_key,
158158
}
159159

160160
return _execute_figure_of_merit

lib/ramble/ramble/test/application_language.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,11 @@ def test_figure_of_merit_directive_required_args():
293293
app_inst.figure_of_merit(
294294
"test_inmem_fom",
295295
units="s",
296-
inmem_key="test_inmem_key",
296+
fom_map_key="test_fom_map_key",
297297
)
298298
foms = list(list(app_inst.figures_of_merit.values())[0].values())[0]
299299
assert len(foms) == 1
300-
assert foms["test_inmem_fom"]["inmem_key"] == "test_inmem_key"
300+
assert foms["test_inmem_fom"]["fom_map_key"] == "test_fom_map_key"
301301

302302

303303
@pytest.mark.parametrize("app_class", app_types)

var/ramble/repos/builtin.mock/applications/expanded_foms/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ExpandedFoms(ExecutableApplication):
4040
figure_of_merit(
4141
"test_inmem_{my_var}",
4242
units="",
43-
inmem_key="test_inmem",
43+
fom_map_key="test_inmem",
4444
)
4545

4646
success_criteria("Run", mode="string", match=r"Collect", file="{log_file}")

var/ramble/repos/builtin/base_classes/application-base/base_class.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ def __init__(self, file_path):
196196
self._input_lock = None
197197
self._software_lock = None
198198
self._experiment_graph = None
199-
self._inmem_fom_values = {}
199+
# A dict storing fom values, currently it only stores inmem FOMs
200+
self._fom_map = {}
200201

201202
# Ensure we always have the application name, and this is never empty
202203
self.license_names = self.license_names + [self.name]
@@ -2211,8 +2212,8 @@ def _extract_inmem_foms(self, inmem_fom_defs, fom_values):
22112212
fom_name = fom_conf["fom_name_expanded"]
22122213
# TODO: this can be extended to support derived FOMs,
22132214
# since the `fom_values` contains resolved file-based FOMs
2214-
inmem_key = fom_conf["inmem_key"]
2215-
fom_value = self._inmem_fom_values.get(inmem_key)
2215+
fom_map_key = fom_conf["fom_map_key"]
2216+
fom_value = self._fom_map.get(fom_map_key)
22162217
expanded_fom_value = self.expander.expand_var(fom_value)
22172218
fom_values[context][fom_name] = {
22182219
"value": expanded_fom_value,
@@ -2900,7 +2901,7 @@ def _preset_context_dict(dest_def_dict, context):
29002901
}
29012902

29022903
for fom, source_def in source_foms.items():
2903-
is_inmem = source_def["inmem_key"] is not None
2904+
is_inmem = source_def["fom_map_key"] is not None
29042905
dest_def_dict = (
29052906
inmem_fom_defs if is_inmem else file_fom_defs
29062907
)
@@ -2945,7 +2946,7 @@ def _try_expand_var_or_none(var: str, expander):
29452946
)
29462947
),
29472948
"fom_type": source_def["fom_type"].to_dict(),
2948-
"inmem_key": source_def["inmem_key"],
2949+
"fom_map_key": source_def["fom_map_key"],
29492950
# If expansion works (i.e., it doesn't rely on the matched fom
29502951
# groups), then cache it here to avoid repeated expansion later.
29512952
"units_expanded": _try_expand_var_or_none(
@@ -2983,9 +2984,9 @@ def _try_expand_var_or_none(var: str, expander):
29832984

29842985
return files, file_fom_defs, inmem_fom_defs
29852986

2986-
def add_inmem_fom_value(self, inmem_key, value):
2987+
def add_inmem_fom_value(self, fom_map_key, value):
29872988
"""Add value to an in-memory FOM"""
2988-
self._inmem_fom_values[inmem_key] = value
2989+
self._fom_map[fom_map_key] = value
29892990

29902991
def read_status(self):
29912992
"""Read status from an experiment's status file, if possible.

0 commit comments

Comments
 (0)