Skip to content

Commit f7fa73d

Browse files
committed
Added support for specifying EasyConfig specific options, for easystack files based on the 'easyconfig' top level keyword
1 parent 372ef13 commit f7fa73d

File tree

4 files changed

+49
-9
lines changed

4 files changed

+49
-9
lines changed

easybuild/framework/easystack.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ def __init__(self):
6969
self.robot = False
7070
self.software_list = []
7171
self.easyconfigs = [] # A list of easyconfig names. May or may not include .eb extension
72+
# A dict where keys are easyconfig names, values are dictionary of options that should be applied for that easyconfig
73+
self.ec_opts = {}
7274

7375
def compose_ec_filenames(self):
7476
"""Returns a list of all easyconfig names"""
@@ -171,7 +173,11 @@ def parse_by_easyconfigs(filepath, easyconfigs, easybuild_version=None, robot=Fa
171173
if len(easyconfig) == 1:
172174
# Get single key from dictionary 'easyconfig'
173175
easyconf_name = list(easyconfig.keys())[0]
176+
# Add easyconfig name to the list
174177
easystack.easyconfigs.append(easyconf_name)
178+
# Add options to the ec_opts dict
179+
if 'options' in easyconfig[easyconf_name].keys():
180+
easystack.ec_opts[easyconf_name] = easyconfig[easyconf_name]['options']
175181
else:
176182
dict_keys = ', '.join(easyconfig.keys())
177183
msg = "Failed to parse easystack file: expected a dictionary with one key (the EasyConfig name). "
@@ -307,12 +313,16 @@ def parse_easystack(filepath):
307313

308314
easyconfig_names = easystack.compose_ec_filenames()
309315

310-
general_options = easystack.get_general_options()
316+
# Disabled general options for now. We weren't using them, and first want support for EasyConfig-specific options.
317+
# Then, we need a method to resolve conflicts (specific options should win)
318+
# general_options = easystack.get_general_options()
311319

312320
_log.debug("EasyStack parsed. Proceeding to install these Easyconfigs: %s" % ', '.join(sorted(easyconfig_names)))
313-
if len(general_options) != 0:
314-
_log.debug("General options for installation are: \n%s" % str(general_options))
315-
else:
316-
_log.debug("No general options were specified in easystack")
317-
318-
return easyconfig_names, general_options
321+
_log.debug("Using EasyConfig specific options based on the following dict:")
322+
_log.debug(easystack.ec_opts)
323+
# if len(general_options) != 0:
324+
# _log.debug("General options for installation are: \n%s" % str(general_options))
325+
# else:
326+
# _log.debug("No general options were specified in easystack")
327+
328+
return easyconfig_names, easystack.ec_opts

easybuild/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
# IMPORTANT this has to be the first easybuild import as it customises the logging
4545
# expect missing log output when this not the case!
46-
from easybuild.tools.build_log import EasyBuildError, print_error, print_msg, stop_logging
46+
from easybuild.tools.build_log import EasyBuildError, print_error, print_msg, stop_logging, print_warning
4747

4848
from easybuild.framework.easyblock import build_and_install_one, inject_checksums
4949
from easybuild.framework.easyconfig import EASYCONFIGS_PKG_SUBDIR
@@ -261,7 +261,7 @@ def main(args=None, logfile=None, do_build=None, testing=False, modtool=None):
261261
# TODO add general_options (i.e. robot) to build options
262262
orig_paths, general_options = parse_easystack(options.easystack)
263263
if general_options:
264-
raise EasyBuildError("Specifying general configuration options in easystack file is not supported yet.")
264+
print_warning("Specifying options in easystack files is not supported yet. They are parsed, but ignored.")
265265

266266
# check whether packaging is supported when it's being used
267267
if options.package:

test/framework/easystack.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,25 @@ def test_easystack_easyconfigs_with_eb_ext(self):
101101
self.assertEqual(sorted(ec_fns), sorted(expected))
102102
self.assertEqual(opts, {})
103103

104+
def test_easystack_easyconfig_opts(self):
105+
"""Teast an easystack file using the 'easyconfigs' key, where additonal options are defined for some easyconfigs"""
106+
topdir = os.path.dirname(os.path.abspath(__file__))
107+
test_easystack = os.path.join(topdir, 'easystacks', 'test_easystack_easyconfigs_opts.yaml')
108+
109+
ec_fns, opts = parse_easystack(test_easystack)
110+
expected = [
111+
'binutils-2.25-GCCcore-4.9.3.eb',
112+
'binutils-2.26-GCCcore-4.9.3.eb',
113+
'foss-2018a.eb',
114+
'toy-0.0-gompi-2018a-test.eb',
115+
]
116+
expected_opts = {
117+
'binutils-2.25-GCCcore-4.9.3.eb': {'debug': True},
118+
'foss-2018a.eb': {'robot': True},
119+
}
120+
self.assertEqual(sorted(ec_fns), sorted(expected))
121+
self.assertEqual(opts, expected_opts)
122+
104123
def test_parse_fail(self):
105124
"""Test for clean error when easystack file fails to parse."""
106125
test_yml = os.path.join(self.test_prefix, 'test.yml')
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
easyconfigs:
2+
- binutils-2.25-GCCcore-4.9.3:
3+
options: {
4+
'debug': True,
5+
}
6+
- binutils-2.26-GCCcore-4.9.3
7+
- foss-2018a:
8+
options: {
9+
'robot': True,
10+
}
11+
- toy-0.0-gompi-2018a-test

0 commit comments

Comments
 (0)