Skip to content

Commit 894a56f

Browse files
committed
fix support for specifying multiple PRs to --from-pr
1 parent 61801b4 commit 894a56f

File tree

8 files changed

+44
-72
lines changed

8 files changed

+44
-72
lines changed

easybuild/framework/easyconfig/tools.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def get_paths_for(subdir=EASYCONFIGS_PKG_SUBDIR, robot_path=None):
307307
return paths
308308

309309

310-
def alt_easyconfig_paths(tmpdir, tweaked_ecs=False, from_pr=False):
310+
def alt_easyconfig_paths(tmpdir, tweaked_ecs=False, from_prs=None):
311311
"""Obtain alternative paths for easyconfig files."""
312312

313313
# paths where tweaked easyconfigs will be placed, easyconfigs listed on the command line take priority and will be
@@ -318,12 +318,13 @@ def alt_easyconfig_paths(tmpdir, tweaked_ecs=False, from_pr=False):
318318
tweaked_ecs_paths = (os.path.join(tmpdir, 'tweaked_easyconfigs'),
319319
os.path.join(tmpdir, 'tweaked_dep_easyconfigs'))
320320

321-
# path where files touched in PR will be downloaded to
322-
pr_path = None
323-
if from_pr:
324-
pr_path = os.path.join(tmpdir, "files_pr%s" % '_'.join(str(pr) for pr in from_pr))
321+
# paths where files touched in PRs will be downloaded to,
322+
# which are picked up via 'pr_paths' build option in fetch_files_from_pr
323+
pr_paths = None
324+
if from_prs:
325+
pr_paths = [os.path.join(tmpdir, 'files_pr%s' % pr) for pr in from_prs]
325326

326-
return tweaked_ecs_paths, pr_path
327+
return tweaked_ecs_paths, pr_paths
327328

328329

329330
def det_easyconfig_paths(orig_paths):
@@ -333,7 +334,7 @@ def det_easyconfig_paths(orig_paths):
333334
:return: list of paths to easyconfig files
334335
"""
335336
try:
336-
from_pr_list = [int(pr_nr) for pr_nr in build_option('from_pr')]
337+
from_prs = [int(pr_nr) for pr_nr in build_option('from_pr')]
337338
except ValueError:
338339
raise EasyBuildError("Argument to --from-pr must be a comma separated list of PR #s.")
339340

@@ -342,11 +343,12 @@ def det_easyconfig_paths(orig_paths):
342343
# list of specified easyconfig files
343344
ec_files = orig_paths[:]
344345

345-
if from_pr_list is not None:
346+
if from_prs:
346347
pr_files = []
347-
tmpdir = tempfile.mkdtemp()
348-
for pr in from_pr_list:
349-
pr_files.extend(fetch_easyconfigs_from_pr(pr, path=os.path.join(tmpdir, 'files_pr%s' % pr)))
348+
for pr in from_prs:
349+
# path to where easyconfig files should be downloaded is determined via 'pr_paths' build option,
350+
# which corresponds to the list of PR paths returned by alt_easyconfig_paths
351+
pr_files.extend(fetch_easyconfigs_from_pr(pr))
350352

351353
if ec_files:
352354
# replace paths for specified easyconfigs that are touched in PR

easybuild/tools/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
345345
'build_specs',
346346
'command_line',
347347
'external_modules_metadata',
348-
'pr_path',
348+
'pr_paths',
349349
'robot_path',
350350
'valid_module_classes',
351351
'valid_stops',

easybuild/tools/github.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,15 @@ def fetch_files_from_pr(pr, path=None, github_user=None, github_account=None, gi
447447

448448
if path is None:
449449
if github_repo == GITHUB_EASYCONFIGS_REPO:
450-
path = build_option('pr_path')
450+
pr_paths = build_option('pr_paths')
451+
if pr_paths:
452+
# figure out directory for this specific PR (see also alt_easyconfig_paths)
453+
cands = [p for p in pr_paths if p.endswith('files_pr%s' % pr)]
454+
if len(cands) == 1:
455+
path = cands[0]
456+
else:
457+
raise EasyBuildError("Failed to isolate path for PR #%s from list of PR paths: %s", pr, pr_paths)
458+
451459
elif github_repo == GITHUB_EASYBLOCKS_REPO:
452460
path = os.path.join(tempfile.gettempdir(), 'ebs_pr%s' % pr)
453461
else:

easybuild/tools/options.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,19 +1461,19 @@ def set_up_configuration(args=None, logfile=None, testing=False, silent=False):
14611461
# software name/version, toolchain name/version, extra patches, ...
14621462
(try_to_generate, build_specs) = process_software_build_specs(options)
14631463

1464-
# map --from-pr strlist to list of ints
1464+
# map list of strings --from-pr value to list of integers
14651465
try:
1466-
from_pr_list = [int(pr_nr) for pr_nr in eb_go.options.from_pr]
1466+
from_prs = [int(pr_nr) for pr_nr in eb_go.options.from_pr]
14671467
except ValueError:
14681468
raise EasyBuildError("Argument to --from-pr must be a comma separated list of PR #s.")
14691469

14701470
# determine robot path
14711471
# --try-X, --dep-graph, --search use robot path for searching, so enable it with path of installed easyconfigs
14721472
tweaked_ecs = try_to_generate and build_specs
1473-
tweaked_ecs_paths, pr_path = alt_easyconfig_paths(tmpdir, tweaked_ecs=tweaked_ecs, from_pr=from_pr_list)
1473+
tweaked_ecs_paths, pr_paths = alt_easyconfig_paths(tmpdir, tweaked_ecs=tweaked_ecs, from_prs=from_prs)
14741474
auto_robot = try_to_generate or options.check_conflicts or options.dep_graph or search_query
1475-
robot_path = det_robot_path(options.robot_paths, tweaked_ecs_paths, pr_path, auto_robot=auto_robot)
1476-
log.debug("Full robot path: %s" % robot_path)
1475+
robot_path = det_robot_path(options.robot_paths, tweaked_ecs_paths, pr_paths, auto_robot=auto_robot)
1476+
log.debug("Full robot path: %s", robot_path)
14771477

14781478
if not robot_path:
14791479
print_warning("Robot search path is empty!")
@@ -1486,7 +1486,7 @@ def set_up_configuration(args=None, logfile=None, testing=False, silent=False):
14861486
'build_specs': build_specs,
14871487
'command_line': eb_cmd_line,
14881488
'external_modules_metadata': parse_external_modules_metadata(options.external_modules_metadata),
1489-
'pr_path': pr_path,
1489+
'pr_paths': pr_paths,
14901490
'robot_path': robot_path,
14911491
'silent': testing or new_update_opt,
14921492
'try_to_generate': try_to_generate,
@@ -1543,7 +1543,7 @@ def set_up_configuration(args=None, logfile=None, testing=False, silent=False):
15431543
sys.path.insert(0, new_fake_vsc_path)
15441544

15451545
return eb_go, (build_specs, log, logfile, robot_path, search_query, tmpdir, try_to_generate,
1546-
from_pr_list, tweaked_ecs_paths)
1546+
from_prs, tweaked_ecs_paths)
15471547

15481548

15491549
def process_software_build_specs(options):

easybuild/tools/robot.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@
5252
_log = fancylogger.getLogger('tools.robot', fname=False)
5353

5454

55-
def det_robot_path(robot_paths_option, tweaked_ecs_paths, pr_path, auto_robot=False):
55+
def det_robot_path(robot_paths_option, tweaked_ecs_paths, pr_paths, auto_robot=False):
5656
"""Determine robot path."""
5757
robot_path = robot_paths_option[:]
58-
_log.info("Using robot path(s): %s" % robot_path)
58+
_log.info("Using robot path(s): %s", robot_path)
5959

6060
tweaked_ecs_path, tweaked_ecs_deps_path = None, None
6161
# paths to tweaked easyconfigs or easyconfigs downloaded from a PR have priority
@@ -67,9 +67,10 @@ def det_robot_path(robot_paths_option, tweaked_ecs_paths, pr_path, auto_robot=Fa
6767
robot_path.append(tweaked_ecs_deps_path)
6868
_log.info("Prepended list of robot search paths with %s and appended with %s: %s", tweaked_ecs_path,
6969
tweaked_ecs_deps_path, robot_path)
70-
if pr_path is not None:
71-
robot_path.append(pr_path)
72-
_log.info("Appended list of robot search paths with %s: %s" % (pr_path, robot_path))
70+
71+
if pr_paths is not None:
72+
robot_path.extend(pr_paths)
73+
_log.info("Extended list of robot search paths with %s: %s", pr_paths, robot_path)
7374

7475
return robot_path
7576

test/framework/easyconfigs/test_ecs/o/OpenBLAS/OpenBLAS-0.3.1-GCC-7.3.0-2.30.eb

Lines changed: 0 additions & 41 deletions
This file was deleted.

test/framework/options.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,7 +1728,7 @@ def test_from_pr(self):
17281728
self.assertTrue(sorted(regex.findall(outtxt)), sorted(modules))
17291729

17301730
pr_tmpdir = os.path.join(tmpdir, r'eb-\S{6,8}', 'files_pr6424')
1731-
regex = re.compile("Appended list of robot search paths with %s:" % pr_tmpdir, re.M)
1731+
regex = re.compile(r"Extended list of robot search paths with \['%s'\]:" % pr_tmpdir, re.M)
17321732
self.assertTrue(regex.search(outtxt), "Found pattern %s in %s" % (regex.pattern, outtxt))
17331733
except URLError as err:
17341734
print("Ignoring URLError '%s' in test_from_pr" % err)
@@ -1762,9 +1762,11 @@ def test_from_pr(self):
17621762
regex = re.compile(r"^ \* \[.\] .*/(?P<filepath>.*) \(module: (?P<module>.*)\)$", re.M)
17631763
self.assertTrue(sorted(regex.findall(outtxt)), sorted(modules))
17641764

1765-
pr_tmpdir = os.path.join(tmpdir, r'eb-\S{6,8}', 'files_pr12150_12366')
1766-
regex = re.compile("Appended list of robot search paths with %s:" % pr_tmpdir, re.M)
1767-
self.assertTrue(regex.search(outtxt), "Found pattern %s in %s" % (regex.pattern, outtxt))
1765+
for pr in ('12150', '12366'):
1766+
pr_tmpdir = os.path.join(tmpdir, r'eb-\S{6,8}', 'files_pr%s' % pr)
1767+
regex = re.compile(r"Extended list of robot search paths with .*%s.*:" % pr_tmpdir, re.M)
1768+
self.assertTrue(regex.search(outtxt), "Found pattern %s in %s" % (regex.pattern, outtxt))
1769+
17681770
except URLError as err:
17691771
print("Ignoring URLError '%s' in test_from_pr" % err)
17701772
shutil.rmtree(tmpdir)

test/framework/robot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,8 +1065,8 @@ def test_tweak_robotpath(self):
10651065
test_easyconfigs = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')
10661066

10671067
# Create directories to store the tweaked easyconfigs
1068-
tweaked_ecs_paths, pr_path = alt_easyconfig_paths(self.test_prefix, tweaked_ecs=True)
1069-
robot_path = det_robot_path([test_easyconfigs], tweaked_ecs_paths, pr_path, auto_robot=True)
1068+
tweaked_ecs_paths, pr_paths = alt_easyconfig_paths(self.test_prefix, tweaked_ecs=True)
1069+
robot_path = det_robot_path([test_easyconfigs], tweaked_ecs_paths, pr_paths, auto_robot=True)
10701070

10711071
init_config(build_options={
10721072
'valid_module_classes': module_classes(),

0 commit comments

Comments
 (0)