Skip to content

Commit 5f2a98d

Browse files
Add compiler usage tracking to concretize
This commit adds usage tracking for compiler packages to the `workspace concretize` action. Warnings are now printed if a compiler is defined in an object, and not used in one of the specs within an experiment. These errors are harder to track, as the defined compiler can come from any of the experiment's objects (modifiers, etc..). But the software-definitions command can help identify the unused compiler when a warning is printed.
1 parent 25af255 commit 5f2a98d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/ramble/ramble/workspace/workspace.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,7 @@ def concretize(self, force=False, quiet=False):
14811481
if app_inst.package_manager is None:
14821482
continue
14831483

1484+
compiler_packages = {}
14841485
compiler_dicts = [app_inst.compilers]
14851486
for mod_inst in app_inst._modifier_instances:
14861487
compiler_dicts.append(mod_inst.compilers)
@@ -1510,6 +1511,7 @@ def concretize(self, force=False, quiet=False):
15101511
newly_created_packages.add(comp)
15111512
packages_dict[comp] = syaml.syaml_dict()
15121513

1514+
compiler_packages[comp] = False
15131515
packages_dict[comp].update(info.to_dict(prefix=spec_prefix))
15141516
for conf in info.config_opts():
15151517
ramble.config.add(conf, scope=self.ws_file_config_scope_name())
@@ -1549,6 +1551,10 @@ def concretize(self, force=False, quiet=False):
15491551
):
15501552
packages_dict[spec_name] = syaml.syaml_dict()
15511553

1554+
# Check for usage of compilers
1555+
if info.compiler in compiler_packages:
1556+
compiler_packages[info.compiler] = True
1557+
15521558
packages_dict[spec_name].update(info.to_dict(prefix=spec_prefix))
15531559

15541560
if spec_name not in app_packages:
@@ -1560,6 +1566,18 @@ def concretize(self, force=False, quiet=False):
15601566

15611567
environments_dict[env_name][namespace.packages] = app_packages.copy()
15621568

1569+
# Ensure all compilers in this experiment are used.
1570+
comp_list = []
1571+
for name, used in compiler_packages.items():
1572+
if not used:
1573+
comp_list.append(name)
1574+
if comp_list:
1575+
logger.warn(
1576+
"Unused compiler(s) found in experiment: "
1577+
+ app_inst.expander.experiment_namespace
1578+
)
1579+
logger.warn(f" {comp_list}")
1580+
15631581
ramble.config.config.update_config(
15641582
namespace.software, full_software_dict, scope=self.ws_file_config_scope_name()
15651583
)

0 commit comments

Comments
 (0)