Skip to content

Commit 64eb787

Browse files
committed
Move conda installation to versioned directory
Also simplified the spack environment name given that the spack installation lives within a versioned e3sm-unified direcotry.
1 parent c5deaec commit 64eb787

File tree

3 files changed

+42
-32
lines changed

3 files changed

+42
-32
lines changed

e3sm_supported_machines/bootstrap.py

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def get_env_setup(args, config, machine):
7575

7676
if machine is not None and compiler is not None:
7777
conda_mpi = 'hpc'
78-
env_suffix = f'_{machine}'
78+
env_suffix = '_compute'
7979
else:
8080
conda_mpi = mpi
8181
env_suffix = '_login'
@@ -110,12 +110,6 @@ def build_env(is_test, recreate, compiler, mpi, conda_mpi, version,
110110
os.chdir(build_dir)
111111

112112
env_name = f'e3sm_unified_{version}{env_suffix}'
113-
114-
# add the compiler and MPI library to the spack env name
115-
spack_env = f'{env_name}_{compiler}_{mpi}'
116-
# spack doesn't like dots
117-
spack_env = spack_env.replace('.', '_')
118-
119113
env_path = os.path.join(conda_base, 'envs', env_name)
120114

121115
if conda_mpi in ['nompi', 'hpc']:
@@ -183,7 +177,7 @@ def build_env(is_test, recreate, compiler, mpi, conda_mpi, version,
183177
else:
184178
print(f'{env_name} already exists')
185179

186-
return env_path, env_name, activate_env, channels, spack_env
180+
return env_path, env_name, activate_env, channels
187181

188182

189183
def install_mache_from_branch(activate_env, fork, branch):
@@ -196,7 +190,7 @@ def install_mache_from_branch(activate_env, fork, branch):
196190

197191

198192
def build_sys_ilamb_esmpy(config, machine, compiler, mpi, template_path,
199-
activate_env, channels, spack_base, spack_env):
193+
activate_env, channels, spack_base):
200194

201195
mpi4py_version = config.get('e3sm_unified', 'mpi4py')
202196
ilamb_version = config.get('e3sm_unified', 'ilamb')
@@ -224,7 +218,7 @@ def build_sys_ilamb_esmpy(config, machine, compiler, mpi, template_path,
224218
modules = f'{activate_env_lines}\n{modules}'
225219

226220
spack_view = f'{spack_base}/var/spack/environments/' \
227-
f'{spack_env}/.spack-env/view'
221+
f'e3sm_spack_env/.spack-env/view'
228222
script = template.render(
229223
mpicc=mpicc, modules=modules, template_path=template_path,
230224
mpi4py_version=mpi4py_version, build_mpi4py=str(build_mpi4py),
@@ -248,10 +242,10 @@ def build_sys_ilamb_esmpy(config, machine, compiler, mpi, template_path,
248242
return esmf_mk
249243

250244

251-
def build_spack_env(config, machine, compiler, mpi, spack_env, tmpdir):
245+
def build_spack_env(config, machine, compiler, mpi, env_name, tmpdir):
252246

253247
base_path = config.get('e3sm_unified', 'base_path')
254-
spack_base = f'{base_path}/spack/{spack_env}'
248+
spack_base = f'{base_path}/{env_name}/{machine}/'
255249

256250
if config.has_option('e3sm_unified', 'use_e3sm_hdf5_netcdf'):
257251
use_e3sm_hdf5_netcdf = config.getboolean('e3sm_unified',
@@ -276,7 +270,7 @@ def build_spack_env(config, machine, compiler, mpi, spack_env, tmpdir):
276270
if value != '':
277271
specs.append(f'{value}')
278272

279-
make_spack_env(spack_path=spack_base, env_name=spack_env,
273+
make_spack_env(base_path=spack_base, env_name='e3sm_spack_env',
280274
spack_specs=specs, compiler=compiler, mpi=mpi,
281275
machine=machine, tmpdir=tmpdir, include_e3sm_lapack=True,
282276
include_e3sm_hdf5_netcdf=use_e3sm_hdf5_netcdf,
@@ -398,6 +392,7 @@ def main():
398392
template_path = f'{source_path}/templates'
399393

400394
version = args.version
395+
env_name = f'e3sm_unified_{version}'.replace('.', '_')
401396

402397
machine = args.machine
403398
print(f'arg: {machine}')
@@ -414,7 +409,9 @@ def main():
414409
else:
415410
is_test = not config.getboolean('e3sm_unified', 'release')
416411

417-
conda_base = get_conda_base(args.conda_base, config, shared=True)
412+
conda_base = get_conda_base(
413+
args.conda_base, config, machine, env_name, shared=True
414+
)
418415
conda_base = os.path.abspath(conda_base)
419416

420417
source_activation_scripts = \
@@ -435,7 +432,7 @@ def main():
435432
nompi_suffix = '_login'
436433
# first, make environment for login nodes. We're using no-MPI from
437434
# conda-forge for now
438-
env_path, env_nompi, activate_env, _, _ = build_env(
435+
conda_env_path, env_nompi, activate_env, _ = build_env(
439436
is_test, recreate, nompi_compiler, mpi, 'nompi', version,
440437
python, conda_base, nompi_suffix, nompi_suffix, activate_base,
441438
args.local_conda_build, config)
@@ -448,9 +445,14 @@ def main():
448445
if not is_test:
449446
# make a symlink to the environment
450447
link = os.path.join(conda_base, 'envs', 'e3sm_unified_latest')
451-
check_call(f'ln -sfn {env_path} {link}')
452-
453-
env_path, env_name, activate_env, channels, spack_env = build_env(
448+
check_call(f'ln -sfn {conda_env_path} {link}')
449+
450+
(
451+
conda_env_path,
452+
conda_env_name,
453+
activate_env,
454+
channels
455+
) = build_env(
454456
is_test, recreate, compiler, mpi, conda_mpi, version,
455457
python, conda_base, activ_suffix, env_suffix, activate_base,
456458
args.local_conda_build, config)
@@ -459,11 +461,11 @@ def main():
459461
env_vars=['export HDF5_USE_FILE_LOCKING=FALSE'])
460462

461463
if compiler is not None:
462-
spack_base = build_spack_env(config, machine, compiler, mpi, spack_env,
464+
spack_base = build_spack_env(config, machine, compiler, mpi, env_name,
463465
args.tmpdir)
464466
esmf_mk = build_sys_ilamb_esmpy(config, machine, compiler, mpi,
465467
template_path, activate_env, channels,
466-
spack_base, spack_env)
468+
spack_base)
467469
sys_info['env_vars'].append(esmf_mk)
468470
else:
469471
spack_base = None
@@ -472,14 +474,14 @@ def main():
472474
for ext in ['sh', 'csh']:
473475
if compiler is not None:
474476
spack_script = get_spack_script(
475-
spack_path=spack_base, env_name=spack_env, compiler=compiler,
476-
mpi=mpi, shell=ext, machine=machine)
477+
spack_path=spack_base, env_name="e3sm_spack_env",
478+
compiler=compiler, mpi=mpi, shell=ext, machine=machine)
477479
else:
478480
spack_script = ''
479481

480482
script_filename = write_load_e3sm_unified(
481483
template_path, activ_path, conda_base, is_test, version,
482-
activ_suffix, env_name, env_nompi, sys_info, ext, machine,
484+
activ_suffix, conda_env_name, env_nompi, sys_info, ext, machine,
483485
spack_script)
484486
if ext == 'sh':
485487
test_script_filename = script_filename
@@ -489,7 +491,7 @@ def main():
489491
link = os.path.join(activ_path, link)
490492
check_call(f'ln -sfn {script_filename} {link}')
491493

492-
check_env(test_script_filename, env_name, conda_mpi, machine)
494+
check_env(test_script_filename, conda_env_name, conda_mpi, machine)
493495

494496
commands = f'{activate_base} && conda clean -y -p -t'
495497
check_call(commands)
@@ -498,8 +500,8 @@ def main():
498500
if spack_base is not None:
499501
paths.append(spack_base)
500502
group = config.get('e3sm_unified', 'group')
501-
update_permissions(paths, group, show_progress=True,
502-
group_writable=False, other_readable=True)
503+
#update_permissions(paths, group, show_progress=True,
504+
# group_writable=False, other_readable=True)
503505

504506

505507
if __name__ == '__main__':

e3sm_supported_machines/deploy_e3sm_unified.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,16 @@ def main():
8484
source_path = os.getcwd()
8585

8686
config = get_config(args.config_file)
87+
version = args.version
8788

88-
conda_base = get_conda_base(args.conda_base, config, shared=False)
89+
env_name = f'e3sm_unified_{version}'.replace('.', '_')
90+
91+
if args.machine is None:
92+
raise ValueError("Please specify what machine you are deploying on")
93+
94+
conda_base = get_conda_base(
95+
args.conda_base, config, args.machine, env_name, shared=False
96+
)
8997
conda_base = os.path.abspath(conda_base)
9098

9199
source_activation_scripts = \

e3sm_supported_machines/shared.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,14 @@ def install_miniforge3(conda_base, activate_base):
127127
check_call(commands)
128128

129129

130-
def get_conda_base(conda_base, config, shared):
130+
def get_conda_base(conda_base, config, machine, env_name, shared):
131131
if shared:
132-
conda_base = os.path.join(
133-
config.get('e3sm_unified', 'base_path'), 'base')
132+
base_path = config.get('e3sm_unified', 'base_path')
133+
conda_base = os.path.join(base_path, env_name, machine, 'conda')
134134
elif conda_base is None:
135135
if config.has_option('e3sm_unified', 'base_path'):
136-
conda_base = os.path.abspath(os.path.join(
137-
config.get('e3sm_unified', 'base_path'), 'base'))
136+
base_path = config.get('e3sm_unified', 'base_path')
137+
conda_base = os.path.join(base_path, env_name, machine, 'conda')
138138
elif 'CONDA_EXE' in os.environ:
139139
# if this is a test, assume we're the same base as the
140140
# environment currently active

0 commit comments

Comments
 (0)