Skip to content

Commit a28e15a

Browse files
committed
Added support for specifying EasyConfigs in EasyStack files with and without explicit '.eb' extension
1 parent db4310e commit a28e15a

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

easybuild/framework/easystack.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,20 @@ def parse(filepath):
131131

132132
easystack_data = None
133133
top_keys = ('easyconfigs', 'software')
134+
keys_found = []
134135
for key in top_keys:
135136
if key in easystack_raw:
136-
easystack_data = easystack_raw[key]
137-
break
137+
keys_found.append(key)
138+
# For now, we don't support mixing multiple top_keys, so check that only one was defined
139+
if len(keys_found) > 1:
140+
keys_string = ', '.join(keys_found)
141+
msg = "Specifying multiple top level keys (%s) in one EasyStack file is not supported." % keys_string
142+
raise EasyBuildError(msg)
143+
elif len(keys_found) == 0:
144+
raise EasyBuildError("An EasyStack file needs to contain at least one of the keys: %s" % (top_keys,))
145+
else:
146+
key = keys_found[0]
147+
easystack_data = easystack_raw[key]
138148

139149
if easystack_data is None:
140150
msg = "Not a valid EasyStack YAML file: no 'easyconfigs' or 'software' top-level key found"

test/framework/easystack.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,21 @@ def test_easystack_easyconfigs(self):
8686
self.assertEqual(sorted(ec_fns), sorted(expected))
8787
self.assertEqual(opts, {})
8888

89+
def test_easystack_easyconfigs_with_eb_ext(self):
90+
"""Test for easystack file using 'easyconfigs' key, where eb extension is included in the easystack file"""
91+
topdir = os.path.dirname(os.path.abspath(__file__))
92+
test_easystack = os.path.join(topdir, 'easystacks', 'test_easystack_easyconfigs_with_eb_ext.yaml')
93+
94+
ec_fns, opts = parse_easystack(test_easystack)
95+
expected = [
96+
'binutils-2.25-GCCcore-4.9.3.eb',
97+
'binutils-2.26-GCCcore-4.9.3.eb',
98+
'foss-2018a.eb',
99+
'toy-0.0-gompi-2018a-test.eb',
100+
]
101+
self.assertEqual(sorted(ec_fns), sorted(expected))
102+
self.assertEqual(opts, {})
103+
89104
def test_parse_fail(self):
90105
"""Test for clean error when easystack file fails to parse."""
91106
test_yml = os.path.join(self.test_prefix, 'test.yml')
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
easyconfigs:
2+
- binutils-2.25-GCCcore-4.9.3.eb
3+
- binutils-2.26-GCCcore-4.9.3.eb
4+
- foss-2018a.eb
5+
- toy-0.0-gompi-2018a-test.eb

0 commit comments

Comments
 (0)