Skip to content

Commit cd1f14f

Browse files
committed
Catch errors in 'spack stack setup-meta-modules' when no stack-* modules are generated
1 parent 0fcc58a commit cd1f14f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

spack-ext/lib/jcsda-emc/spack-stack/stack/meta_modules.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,12 @@ def custom_sort_key(entry):
373373
raise Exception(f"Expected no or one MPI provider, but got {mpi_providers}")
374374
logging.info(f" ... mpi_providers: {mpi_providers}")
375375

376+
# To catch errors (invalid compilers, etc) we check that the number of written
377+
# stack-* meta modules matches what we expect: One module for the preferred
378+
# compiler, and (if applicable) one for each (currently one) MPI provider.
379+
number_of_meta_modules_expected = 1 + len(mpi_providers)
380+
number_of_meta_modules_written = 0
381+
376382
# Prepare meta module directory
377383
logging.info("Preparing meta module directory ...")
378384
meta_module_dir = os.path.join(module_dir, "Core")
@@ -508,6 +514,7 @@ def custom_sort_key(entry):
508514
with open(compiler_module_file, "w") as f:
509515
f.write(module_content)
510516
logging.info(" ... writing {}".format(compiler_module_file))
517+
number_of_meta_modules_written += 1
511518

512519
# If this is the last compiler in the list (i.e. the preferred compiler),
513520
# then save the substitutes for later when building the MPI meta module
@@ -691,5 +698,10 @@ def custom_sort_key(entry):
691698
with open(mpi_module_file, "w") as f:
692699
f.write(module_content)
693700
logging.info(" ... writing {}".format(mpi_module_file))
701+
number_of_meta_modules_written += 1
702+
694703

695-
logging.info("Metamodule generation completed successfully in {}".format(meta_module_dir))
704+
if number_of_meta_modules_written == number_of_meta_modules_expected:
705+
logging.info("Metamodule generation completed successfully in {}".format(meta_module_dir))
706+
else:
707+
raise Exception("Metamodule generation NOT successful, check output (invalid compiler?)")

0 commit comments

Comments
 (0)