Skip to content

Commit

Permalink
improve error reporting when available_software.py script is run in i…
Browse files Browse the repository at this point in the history
…ncorrect environment
  • Loading branch information
boegel committed Jun 4, 2024
1 parent 3c4e7ec commit 318caeb
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions scripts/available_software/available_software.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
import os
import re
import subprocess
import sys
import time
from pathlib import Path
from typing import Union, Tuple
import numpy as np
from mdutils.mdutils import MdUtils
from natsort import natsorted

EESSI_TOPDIR = "/cvmfs/software.eessi.io/versions/2023.06"


# --------------------------------------------------------------------------------------------------------
# MAIN
Expand Down Expand Up @@ -85,6 +88,10 @@ def module(*args, filter_fn=lambda x: x) -> np.ndarray:
@return: Array with the output of the module command.
"""
lmod = os.getenv('LMOD_CMD')
if lmod is None:
sys.stderr.write("Lmod not found (via $LMOD_CMD)!\n")
sys.exit(1)

proc = subprocess.run(
[lmod, "python", "--terse"] + list(args),
encoding="utf-8",
Expand Down Expand Up @@ -195,10 +202,14 @@ def targets_eessi() -> np.ndarray:
Returns all the target names of EESSI.
@return: target names
"""
if not os.path.exists(EESSI_TOPDIR):
sys.stderr.write(f"ERROR: {EESSI_TOPDIR} does not exist!\n")
sys.exit(1)

commands = [
"find /cvmfs/software.eessi.io/versions/2023.06/software/linux/*/* -maxdepth 0 \\( ! -name 'intel' -a ! "
f"find {EESSI_TOPDIR}/software/linux/*/* -maxdepth 0 \\( ! -name 'intel' -a ! "
"-name 'amd' \\) -type d",
'find /cvmfs/software.eessi.io/versions/2023.06/software/linux/*/{amd,intel}/* -maxdepth 0 -type d'
f'find {EESSI_TOPDIR}/software/linux/*/{{amd,intel}}/* -maxdepth 0 -type d'
]
targets = np.array([])

Expand All @@ -216,7 +227,11 @@ def modules_eessi() -> dict:
"""
print("Start collecting modules:")
data = {}
module_unuse(os.getenv('MODULEPATH'))

modulepath = os.getenv('MODULEPATH')
if modulepath:
module_unuse(modulepath)

for target in targets_eessi():
print(f"\t Collecting available modules for {target}... ", end="", flush=True)
module_use(target + "/modules/all/")
Expand Down

0 comments on commit 318caeb

Please sign in to comment.