-
Notifications
You must be signed in to change notification settings - Fork 217
add support for --preview-pr #2331
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
Conversation
|
Hmm, just gave this a quick try, doesn't seem to work for me, possibly because of the filename I'm using? Also, I think it makes more sense to park this under a dedicated option like |
|
Does this help at all? I also see it or other easyconfigs that are named |
|
it's looking for it under |
|
@migueldiascosta That's not the problem, |
|
Hmm, doesn't seem to be related to filename at all: |
|
ok, I can reproduce if I pass the eb filename without a path, I was always using one. I suppose I need to explicitly copy the file to the tmp folder. Can you just check with an absolute path to make sure that's the problem? |
| else: | ||
| lines.extend(['', "(no related easyconfigs found for %s)\n" % os.path.basename(ec['spec'])]) | ||
|
|
||
| return '\n'.join(lines) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@migueldiascosta This is working as expected now, but there's way too much copy-pasting going on here when comparing preview_pr with review_pr.
The only thing that differs is the list of files (pr_files) and a part of the log message.
Can we create a private method (_pr_diff_common or something like that) which accepts these two as additional arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@boegel definitely, will do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current approach of enhancing the existing review_pr is way better 👍
easybuild/main.py
Outdated
| if options.preview_pr: | ||
| print preview_pr(paths, colored=use_color(options.color)) | ||
| cleanup(logfile, eb_tmpdir, testing, silent=True) | ||
| sys.exit(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, can we avoid doing cleanup/exit here? How is this handled for --new-pr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's because options.new_pr is in no_ec_opts, there's a cleanup later for those, I suppose options.preview_pr can also be added to them (although it's a bit counterintuitive that these don't require any easyconfigs to be specified?)
| elif paths: | ||
| pr_files = [path[0] for path in paths] | ||
| else: | ||
| return "no easyconfigs or pr specified" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would raise an error instead here, one of both mus be provided or something is wrong in the way review_pr is used...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| if pr: | ||
| pr_files = [path for path in fetch_easyconfigs_from_pr(pr) if path.endswith('.eb')] | ||
| elif paths: | ||
| pr_files = [path[0] for path in paths] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, shouldn't we pass the paths without the generated part down to review_pr instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in main the paths from det_easyconfig_paths are transformed to these tuples and I used those, but I suppose I can call det_easyconfig_paths in main again, or store the original paths when it is called the first time
| if pr: | ||
| _log.debug("File in PR#%s %s has these related easyconfigs: %s" % (pr, ec['spec'], files)) | ||
| else: | ||
| _log.debug("File in new PR %s has these related easyconfigs: %s" % (ec['spec'], files)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid repeating the whole thing:
if pr:
pr_msg = "PR#%s" % pr
else:
pr_msg = "new PR"
_log.debug("File in %s %s has these related easyconfigs: %s" % (pr_msg, ec['spec'], files))
easybuild/main.py
Outdated
|
|
||
| # command line options that do not require any easyconfigs to be specified | ||
| no_ec_opts = [options.aggregate_regtest, options.new_pr, options.regtest, options.update_pr, search_query] | ||
| no_ec_opts = [options.aggregate_regtest, options.new_pr, options.preview_pr, options.regtest, options.update_pr, search_query] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long, needs wrapping...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, can't we use no_ec_opts or new_update_pr below, and avoid including options.new_pr, options.update_pr and options.preview_pr in no_ec_opts (since it's wrong, sematically)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, an update_pr could just add or remove a patch, without any easyconfig in the command line...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, sure, but it doesn't make much sense for --new-pr and --preview-pr (although in theory you could also only use a patch file there)
easybuild/main.py
Outdated
| forced = options.force or options.rebuild | ||
| dry_run_mode = options.dry_run or options.dry_run_short | ||
| new_update_pr = options.new_pr or options.update_pr | ||
| new_update_pr = options.new_pr or options.update_pr or options.preview_pr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this should be renamed to new_update_preview_pr?
easybuild/main.py
Outdated
| if options.new_pr: | ||
| if options.preview_pr: | ||
| print review_pr(paths=paths, colored=use_color(options.color)) | ||
| elif options.new_pr: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep these alphabetically sorted, so new_pr before preview_pr
| pr_msg = "PR#%s" % pr | ||
| else: | ||
| pr_msg = "new PR" | ||
| _log.debug("File in %s %s has these related easyconfigs: %s" % (pr_msg, ec['spec'], files)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the _log.debug should not be under the else:, should be intended left one level so a log message is also emitted for --review-pr
boegel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also missing: a dedicated test for the --preview-pr option, let me know if you need help with that
easybuild/main.py
Outdated
|
|
||
| # cleanup and exit after dry run, searching easyconfigs or submitting regression test | ||
| if any(no_ec_opts + [options.check_conflicts, dry_run_mode, options.dump_env_script, options.inject_checksums]): | ||
| if any(no_ec_opts + [new_update_preview_pr, options.check_conflicts, dry_run_mode, options.dump_env_script, options.inject_checksums]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now this line is too long, should be shortened somehow...
maybe like this:
stop_options = [options.check_conflicts, dry_run_mode, options.dump_env_script, options.inject_checksums]
if no_ec_opts or new_update_preview_pr or any(stop_options):
cleanup(logfile, eb_tmpdir, testing)
sys.exit(0)|
lgtm, just missing a dedicated test for |
boegel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
|
@migueldiascosta Good to go, thanks! Can you look into an update for the documentation too? |
fix bug that slipped in with #2331
|
documentation added in easybuilders/easybuild#388, thanks again @migueldiascosta! |
Is something like this useful to anyone else?
(I'm calling it when --new-pr is run with -x, but of course, a new option could be created)