Skip to content

improve error reporting when available_software.py script is run in incorrect environment #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading