Skip to content

Commit ced1fb5

Browse files
committed
Add pre_conda_script to load scripts
This is needed to unload a problem module on ALCF Polaris and may be useful on other machines in the future. This requires a new capability in mache.
1 parent 14d1df4 commit ced1fb5

File tree

3 files changed

+52
-15
lines changed

3 files changed

+52
-15
lines changed

e3sm_supported_machines/bootstrap.py

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
from configparser import ConfigParser
99

1010
from mache import discover_machine
11-
from mache.spack import make_spack_env, get_spack_script, \
12-
get_modules_env_vars_and_mpi_compilers
11+
from mache.machines.pre_conda import load_pre_conda_script
12+
from mache.spack import (
13+
make_spack_env,
14+
get_spack_script,
15+
get_modules_env_vars_and_mpi_compilers,
16+
)
1317
from mache.permissions import update_permissions
1418
from shared import (
1519
check_call,
@@ -282,9 +286,26 @@ def build_spack_env(config, machine, compiler, mpi, version, tmpdir):
282286
return spack_base_path
283287

284288

285-
def write_load_e3sm_unified(template_path, activ_path, conda_base, is_test,
286-
version, activ_suffix, env_name, env_nompi,
287-
sys_info, ext, machine, spack_script):
289+
def write_load_e3sm_unified(
290+
template_path,
291+
activ_path,
292+
conda_base,
293+
is_test,
294+
version,
295+
activ_suffix,
296+
env_name,
297+
env_nompi,
298+
sys_info,
299+
ext,
300+
machine,
301+
spack_script,
302+
):
303+
304+
pre_conda_script = load_pre_conda_script(machine=machine, ext=ext)
305+
306+
print(f'Pre-conda script for {machine} ({ext}):')
307+
print(pre_conda_script)
308+
print('---')
288309

289310
try:
290311
os.makedirs(activ_path)
@@ -318,14 +339,17 @@ def write_load_e3sm_unified(template_path, activ_path, conda_base, is_test,
318339
else:
319340
env_type = 'SYSTEM'
320341

321-
script = template.render(conda_base=conda_base, env_name=env_name,
322-
env_type=env_type,
323-
script_filename=script_filename,
324-
env_nompi=env_nompi,
325-
spack='\n '.join(spack_script.split('\n')),
326-
modules='\n '.join(sys_info['modules']),
327-
env_vars=env_vars,
328-
machine=machine)
342+
script = template.render(
343+
pre_conda_script=pre_conda_script,
344+
conda_base=conda_base,
345+
env_name=env_name,
346+
env_type=env_type,
347+
script_filename=script_filename,
348+
env_nompi=env_nompi,
349+
spack='\n '.join(spack_script.split('\n')),
350+
modules='\n '.join(sys_info['modules']),
351+
env_vars=env_vars,
352+
machine=machine)
329353

330354
# strip out redundant blank lines
331355
lines = list()
@@ -484,8 +508,17 @@ def main():
484508
spack_script = ''
485509

486510
script_filename = write_load_e3sm_unified(
487-
template_path, activ_path, conda_base, is_test, version,
488-
activ_suffix, conda_env_name, env_nompi, sys_info, ext, machine,
511+
template_path,
512+
activ_path,
513+
conda_base,
514+
is_test,
515+
version,
516+
activ_suffix,
517+
conda_env_name,
518+
env_nompi,
519+
sys_info,
520+
ext,
521+
machine,
489522
spack_script)
490523
if ext == 'sh':
491524
test_script_filename = script_filename

e3sm_supported_machines/templates/load_e3sm_unified.csh.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{{ pre_conda_script }}
2+
13
source {{ conda_base }}/etc/profile.d/conda.csh
24

35
setenv E3SMU_SCRIPT "{{ script_filename }}"

e3sm_supported_machines/templates/load_e3sm_unified.sh.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{{ pre_conda_script }}
2+
13
source {{ conda_base }}/etc/profile.d/conda.sh
24

35
export E3SMU_SCRIPT="{{ script_filename }}"

0 commit comments

Comments
 (0)