Skip to content

Avoid processing the same EasyConfig multiple times #4767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 16, 2025
Merged
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
6 changes: 6 additions & 0 deletions easybuild/framework/easyconfig/tools.py
Original file line number Diff line number Diff line change
@@ -404,9 +404,15 @@ def parse_easyconfigs(paths, validate=True):
"""
easyconfigs = []
generated_ecs = False
parsed_paths = []

for (path, generated) in paths:
# Avoid processing the same file multiple times
path = os.path.abspath(path)
if any(os.path.samefile(path, p) for p in parsed_paths):
continue
parsed_paths.append(path)

# keep track of whether any files were generated
generated_ecs |= generated
if not os.path.exists(path):
26 changes: 26 additions & 0 deletions test/framework/easyconfig.py
Original file line number Diff line number Diff line change
@@ -737,6 +737,32 @@ def test_tweaking(self):
# cleanup
os.remove(tweaked_fn)

def test_parse_easyconfig(self):
"""Test parse_easyconfig function"""
self.contents = textwrap.dedent("""
easyblock = "ConfigureMake"
name = "PI"
version = "3.14"
homepage = "http://example.com"
description = "test easyconfig"
toolchain = SYSTEM
""")
self.prep()
ecs, gen_ecs = parse_easyconfigs([(self.eb_file, False)])
self.assertEqual(len(ecs), 1)
self.assertEqual(ecs[0]['spec'], self.eb_file)
self.assertIsInstance(ecs[0]['ec'], EasyConfig)
self.assertFalse(gen_ecs)
# Passing the same EC multiple times is ignored
ecs, gen_ecs = parse_easyconfigs([(self.eb_file, False), (self.eb_file, False)])
self.assertEqual(len(ecs), 1)
# Similar for symlinks
linked_ec = os.path.join(self.test_prefix, 'linked.eb')
os.symlink(self.eb_file, linked_ec)
ecs, gen_ecs = parse_easyconfigs([(self.eb_file, False), (linked_ec, False)])
self.assertEqual(len(ecs), 1)
self.assertEqual(ecs[0]['spec'], self.eb_file)

def test_alt_easyconfig_paths(self):
"""Test alt_easyconfig_paths function that collects list of additional paths for easyconfig files."""

Loading