Skip to content

Commit

Permalink
Satisfy linter
Browse files Browse the repository at this point in the history
  • Loading branch information
altheaden committed Sep 23, 2024
1 parent 3d67afb commit 48062b9
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 59 deletions.
108 changes: 62 additions & 46 deletions conda/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,9 @@ def build_conda_env(env_type, recreate, mpi, conda_mpi, version,
# conda packages don't like dashes
version_conda = version.replace('-', '')
packages = f'{packages} "compass={version_conda}={mpi_prefix}_*"'
commands = f'{activate_base} && ' \
f'conda create -y -n {env_name} {channels} {packages}'
commands = \
f'{activate_base} && ' \
f'conda create -y -n {env_name} {channels} {packages}'
check_call(commands, logger=logger)
else:
if env_type == 'dev':
Expand Down Expand Up @@ -408,7 +409,7 @@ def build_jigsaw(activate_env, source_path, env_path, logger):

t1 = time.time()
total = int(t1 - t0 + 0.5)
message = f'JIGSAW install took {total:.1f} s.'
message = f'JIGSAW install took {total:.1f} s.' # noqa: 231
if logger is None:
print(message)
else:
Expand All @@ -424,11 +425,12 @@ def get_env_vars(machine, compiler, mpilib):
env_vars = 'export MPAS_EXTERNAL_LIBS=""\n'

if 'intel' in compiler and machine == 'anvil':
env_vars = f'{env_vars}' \
f'export I_MPI_CC=icc\n' \
f'export I_MPI_CXX=icpc\n' \
f'export I_MPI_F77=ifort\n' \
f'export I_MPI_F90=ifort\n'
env_vars = \
f'{env_vars}' \
f'export I_MPI_CC=icc\n' \
f'export I_MPI_CXX=icpc\n' \
f'export I_MPI_F77=ifort\n' \
f'export I_MPI_F90=ifort\n'

if machine.startswith('conda'):
# we're using parallelio so we don't have ADIOS support
Expand All @@ -442,9 +444,10 @@ def get_env_vars(machine, compiler, mpilib):
f'export MPAS_EXTERNAL_LIBS="${{MPAS_EXTERNAL_LIBS}} -lgomp"\n'

if mpilib == 'mvapich':
env_vars = f'{env_vars}' \
f'export MV2_ENABLE_AFFINITY=0\n' \
f'export MV2_SHOW_CPU_BINDING=1\n'
env_vars = \
f'{env_vars}' \
f'export MV2_ENABLE_AFFINITY=0\n' \
f'export MV2_SHOW_CPU_BINDING=1\n'

if machine.startswith('chicoma') or machine.startswith('pm'):
env_vars = \
Expand Down Expand Up @@ -525,8 +528,9 @@ def build_spack_env(config, update_spack, machine, compiler, mpi, # noqa: C901
f'"scorpio'
f'@{scorpio}+pnetcdf~timing+internal-timing~tools+malloc"')
# make sure scorpio, not esmf, libraries are linked
lib_path = f'{spack_branch_base}/var/spack/environments/' \
f'{spack_env}/.spack-env/view/lib'
lib_path = \
f'{spack_branch_base}/var/spack/environments/' \
f'{spack_env}/.spack-env/view/lib'
scorpio_lib_path = '$(spack find --format "{prefix}" scorpio)'
custom_spack = \
f'{custom_spack}' \
Expand Down Expand Up @@ -572,8 +576,9 @@ def build_spack_env(config, update_spack, machine, compiler, mpi, # noqa: C901
custom_spack=custom_spack, spack_mirror=spack_mirror)

# remove ESMC/ESMF include files that interfere with MPAS time keeping
include_path = f'{spack_branch_base}/var/spack/environments/' \
f'{spack_env}/.spack-env/view/include'
include_path = \
f'{spack_branch_base}/var/spack/environments/' \
f'{spack_env}/.spack-env/view/include'
for prefix in ['ESMC', 'esmf']:
files = glob.glob(os.path.join(include_path, f'{prefix}*'))
for filename in files:
Expand All @@ -587,10 +592,12 @@ def build_spack_env(config, update_spack, machine, compiler, mpi, # noqa: C901
include_e3sm_hdf5_netcdf=e3sm_hdf5_netcdf,
yaml_template=yaml_template)

spack_view = f'{spack_branch_base}/var/spack/environments/' \
f'{spack_env}/.spack-env/view'
env_vars = f'{env_vars}' \
f'export PIO={spack_view}\n'
spack_view = \
f'{spack_branch_base}/var/spack/environments/' \
f'{spack_env}/.spack-env/view'
env_vars = \
f'{env_vars}' \
f'export PIO={spack_view}\n'
if parallelio != 'None':
env_vars = \
f'{env_vars}' \
Expand Down Expand Up @@ -619,14 +626,16 @@ def build_spack_env(config, update_spack, machine, compiler, mpi, # noqa: C901
f'${{ALBANY_LINK_LIBS}} {stdcxx} {mpicxx}"\n'

if lapack != 'None':
env_vars = f'{env_vars}' \
f'export LAPACK={spack_view}\n' \
f'export USE_LAPACK=true\n'
env_vars = \
f'{env_vars}' \
f'export LAPACK={spack_view}\n' \
f'export USE_LAPACK=true\n'

if petsc != 'None':
env_vars = f'{env_vars}' \
f'export PETSC={spack_view}\n' \
f'export USE_PETSC=true\n'
env_vars = \
f'{env_vars}' \
f'export PETSC={spack_view}\n' \
f'export USE_PETSC=true\n'

return spack_branch_base, spack_script, env_vars

Expand All @@ -636,7 +645,7 @@ def set_ld_library_path(spack_branch_base, spack_env, logger):
f'source {spack_branch_base}/share/spack/setup-env.sh && ' \
f'spack env activate {spack_env} && ' \
f'spack config add modules:prefix_inspections:lib:[LD_LIBRARY_PATH] && ' \
f'spack config add modules:prefix_inspections:lib64:[LD_LIBRARY_PATH]' # noqa: E501
f'spack config add modules:prefix_inspections:lib64:[LD_LIBRARY_PATH]' # noqa: E501,E231
check_call(commands, logger=logger)


Expand All @@ -658,21 +667,26 @@ def write_load_compass(template_path, activ_path, conda_base, env_type,
script_filename = '{}/{}{}.sh'.format(activ_path, prefix, activ_suffix)

if not env_only:
env_vars = f'{env_vars}\n' \
f'export USE_PIO2=true'
env_vars = \
f'{env_vars}\n' \
f'export USE_PIO2=true'
if without_openmp:
env_vars = f'{env_vars}\n' \
f'export OPENMP=false'
env_vars = \
f'{env_vars}\n' \
f'export OPENMP=false'
else:
env_vars = f'{env_vars}\n' \
f'export OPENMP=true'
env_vars = \
f'{env_vars}\n' \
f'export OPENMP=true'

env_vars = f'{env_vars}\n' \
f'export HDF5_USE_FILE_LOCKING=FALSE\n' \
f'export LOAD_COMPASS_ENV={script_filename}'
env_vars = \
f'{env_vars}\n' \
f'export HDF5_USE_FILE_LOCKING=FALSE\n' \
f'export LOAD_COMPASS_ENV={script_filename}'
if machine is not None and not machine.startswith('conda'):
env_vars = f'{env_vars}\n' \
f'export COMPASS_MACHINE={machine}'
env_vars = \
f'{env_vars}\n' \
f'export COMPASS_MACHINE={machine}'

filename = f'{template_path}/load_compass.template'
with open(filename, 'r') as f:
Expand Down Expand Up @@ -1090,11 +1104,12 @@ def main(): # noqa: C901

if local_mache:
print('Install local mache\n')
commands = f'source {conda_base}/etc/profile.d/conda.sh && ' \
f'conda activate {conda_env_name} && ' \
f'cd ../build_mache/mache && ' \
f'conda install -y --file spec-file.txt && ' \
f'python -m pip install --no-deps --no-build-isolation .'
commands = \
f'source {conda_base}/etc/profile.d/conda.sh && ' \
f'conda activate {conda_env_name} && ' \
f'cd ../build_mache/mache && ' \
f'conda install -y --file spec-file.txt && ' \
f'python -m pip install --no-deps --no-build-isolation .'
check_call(commands, logger=logger)

previous_conda_env = conda_env_name
Expand All @@ -1110,10 +1125,11 @@ def main(): # noqa: C901
config, args.update_spack, machine, compiler, mpi,
spack_env, spack_base, spack_template_path, env_vars,
args.tmpdir, logger)
spack_script = f'echo Loading Spack environment...\n' \
f'{spack_script}\n' \
f'echo Done.\n' \
f'echo\n'
spack_script = \
f'echo Loading Spack environment...\n' \
f'{spack_script}\n' \
f'echo Done.\n' \
f'echo\n'
else:
env_vars = \
f'{env_vars}' \
Expand Down
29 changes: 16 additions & 13 deletions conda/configure_compass_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ def bootstrap(activate_install_env, source_path, local_conda_build):

print('Creating the compass conda environment\n')
bootstrap_command = f'{source_path}/conda/bootstrap.py'
command = f'{activate_install_env} && ' \
f'{bootstrap_command} {" ".join(sys.argv[1:])}'
command = \
f'{activate_install_env} && ' \
f'{bootstrap_command} {" ".join(sys.argv[1:])}'
if local_conda_build is not None:
command = f'{command} --local_conda_build {local_conda_build}'
check_call(command)
Expand All @@ -51,8 +52,9 @@ def setup_install_env(env_name, activate_base, use_local, logger, recreate,
f'conda create -y -n {env_name} {channels} {packages}'
else:
print('Updating conda environment for installing compass\n')
commands = f'{activate_base} && ' \
f'conda install -y -n {env_name} {channels} {packages}'
commands = \
f'{activate_base} && ' \
f'conda install -y -n {env_name} {channels} {packages}'

check_call(commands, logger=logger)

Expand Down Expand Up @@ -107,15 +109,16 @@ def main():

if local_mache:
print('Clone and install local mache\n')
commands = f'{activate_install_env} && ' \
f'rm -rf conda/build_mache && ' \
f'mkdir -p conda/build_mache && ' \
f'cd conda/build_mache && ' \
f'git clone -b {args.mache_branch} ' \
f'[email protected]:{args.mache_fork}.git mache && ' \
f'cd mache && ' \
f'conda install -y --file spec-file.txt && ' \
f'python -m pip install --no-deps --no-build-isolation .'
commands = \
f'{activate_install_env} && ' \
f'rm -rf conda/build_mache && ' \
f'mkdir -p conda/build_mache && ' \
f'cd conda/build_mache && ' \
f'git clone -b {args.mache_branch} ' \
f'[email protected]:{args.mache_fork}.git mache && ' \ # noqa: 231
f'cd mache && ' \
f'conda install -y --file spec-file.txt && ' \
f'python -m pip install --no-deps --no-build-isolation .'

check_call(commands, logger=logger)

Expand Down

0 comments on commit 48062b9

Please sign in to comment.