Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion easybuild/framework/easyconfig/easyconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -1968,17 +1968,22 @@ def asdict(self):
res[key] = value
return res

def get_cuda_cc_template_value(self, key):
def get_cuda_cc_template_value(self, key, required=True):
"""
Get template value based on --cuda-compute-capabilities EasyBuild configuration option
and cuda_compute_capabilities easyconfig parameter.
Returns user-friendly error message in case neither are defined,
or if an unknown key is used.

:param required: If False and the key is not found, return an empty string instead of raising an error.
"""
if key.startswith('cuda_') and any(x == key for x in TEMPLATE_NAMES_DYNAMIC):
try:
return self.template_values[key]
except KeyError:
if not required:
self.log.debug(f'Key {key} not found in template values, returning empty value')
return ''
error_msg = "Template value '%s' is not defined!\n"
error_msg += "Make sure that either the --cuda-compute-capabilities EasyBuild configuration "
error_msg += "option is set, or that the cuda_compute_capabilities easyconfig parameter is defined."
Expand Down
1 change: 1 addition & 0 deletions test/framework/easyconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -5090,6 +5090,7 @@ def test_get_cuda_cc_template_value(self):
}
for key in cuda_template_values:
self.assertErrorRegex(EasyBuildError, error_pattern % key, ec.get_cuda_cc_template_value, key)
self.assertEqual(ec.get_cuda_cc_template_value(key, required=False), '')

update_build_option('cuda_compute_capabilities', ['6.5', '7.0'])
ec = EasyConfig(self.eb_file)
Expand Down