Skip to content

Commit ab1c119

Browse files
author
Michael Richard Mckinsey
committed
Implement appending to PATH without needing changes to ramble, through existing interface
1 parent 0d17e7e commit ab1c119

File tree

2 files changed

+42
-11
lines changed

2 files changed

+42
-11
lines changed

experiments/osu-micro-benchmarks/experiment.py

-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ def compute_applications_section(self):
110110
for pk, pv in num_nodes.items():
111111
self.add_experiment_variable("n_gpus", pv, True)
112112

113-
self.add_experiment_variable("binary_path", [p for p in self.spec.variants["env_modules_path"]], False)
114-
115113
def compute_spack_section(self):
116114
system_specs = {}
117115
if self.spec.satisfies("+cuda"):

lib/benchpark/experiment.py

+42-9
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
class ExperimentHelper:
2626
def __init__(self, exp):
2727
self.spec = exp.spec
28+
self.variables = {}
29+
self.env_vars = {
30+
"set": {},
31+
"append": {},
32+
}
2833

2934
def compute_include_section(self):
3035
return []
@@ -47,6 +52,19 @@ def get_helper_name_prefix(self):
4752
def get_spack_variants(self):
4853
return None
4954

55+
def set_environment_variable(self, name, value):
56+
self.env_vars["set"][name] = value
57+
58+
def append_environment_variable(self, name, value):
59+
self.env_vars["append"][name] = value
60+
61+
def compute_config_variables(self):
62+
pass
63+
64+
def compute_config_variables_wrapper(self):
65+
self.compute_config_variables()
66+
return self.variables, self.env_vars
67+
5068

5169
class SingleNode:
5270
variant(
@@ -102,9 +120,9 @@ class Experiment(ExperimentSystemBase, SingleNode):
102120
)
103121

104122
variant(
105-
"env_modules_path",
123+
"append_path",
106124
default=" ",
107-
description="path to local package to use as environment module",
125+
description="Append to environment PATH during experiment execution",
108126
)
109127

110128
def __init__(self, spec):
@@ -163,7 +181,10 @@ def add_experiment_variable(self, name, values, use_in_expr_name=False):
163181
self.expr_name.append(f"{{{name}}}")
164182

165183
def set_environment_variable(self, name, values):
166-
self.set_env_vars[name] = values
184+
self.env_vars["set"][name] = values
185+
186+
def append_environment_variable(self, name, values):
187+
self.env_vars["append"][0]["paths"][name] = values
167188

168189
def zip_experiment_variables(self, name, variable_names):
169190
self.zips[name] = list(variable_names)
@@ -186,12 +207,25 @@ def compute_applications_section(self):
186207

187208
def compute_applications_section_wrapper(self):
188209
self.expr_name = []
189-
self.set_env_vars = {}
210+
self.env_vars = {
211+
"set": {},
212+
"append": [
213+
{
214+
"paths": {},
215+
}
216+
],
217+
}
190218
self.variables = {}
191219
self.zips = {}
192220
self.matrix = []
193221
self.excludes = []
194222

223+
for cls in self.helpers:
224+
variables, env_vars = cls.compute_config_variables_wrapper()
225+
self.variables |= variables
226+
self.env_vars["set"] |= env_vars["set"]
227+
self.env_vars["append"][0] |= env_vars["append"]
228+
195229
self.compute_applications_section()
196230

197231
expr_helper_list = []
@@ -203,6 +237,7 @@ def compute_applications_section_wrapper(self):
203237

204238
expr_setup = {
205239
"variants": {"package_manager": self.spec.variants["package_manager"][0]},
240+
"env_vars": self.env_vars,
206241
"variables": self.variables,
207242
"zips": self.zips,
208243
"matrix": self.matrix,
@@ -275,11 +310,9 @@ def compute_environment_modules_section(self):
275310

276311
self.compute_spack_section()
277312

278-
if "env_modules_path" in self.spec.variants:
279-
self.add_experiment_variable(
280-
"binary_path",
281-
[p for p in self.spec.variants["env_modules_path"]],
282-
False,
313+
if "append_path" in self.spec.variants:
314+
self.append_environment_variable(
315+
"PATH", self.spec.variants["append_path"][0]
283316
)
284317

285318
return {

0 commit comments

Comments
 (0)