Skip to content

Commit

Permalink
Use shlex.split() for bm_runner commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
trexfeathers committed Aug 18, 2023
1 parent e5a45c2 commit 4d5b3c8
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions benchmarks/bm_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,14 @@ def _asv_compare(*commits: str, overnight_mode: bool = False) -> None:
for i in range(len(commits) - 1):
before = commits[i]
after = commits[i + 1]
asv_command = (
asv_command = shlex.split(
f"compare {before} {after} --factor={COMPARE_FACTOR} --split"
)

comparison = _subprocess_runner_capture(
asv_command.split(" "), asv=True
)
comparison = _subprocess_runner_capture(asv_command, asv=True)
echo(comparison)
shifts = _subprocess_runner_capture(
[*asv_command.split(" "), "--only-changed"], asv=True
[*asv_command, "--only-changed"], asv=True
)

if shifts or (not overnight_mode):
Expand Down Expand Up @@ -247,12 +245,12 @@ def _gh_create_reports(

for login_type in ("author", "mergedBy"):
gh_query = f'.["{login_type}"]["login"]'
command = (
command = shlex.split(
f"gh pr view {pr_tag[1:]} "
f"--json {login_type} -q '{gh_query}' "
f"--repo {repo}"
)
login = _subprocess_runner_capture(command.split(" "))
login = _subprocess_runner_capture(command)

command = [
"curl",
Expand Down Expand Up @@ -388,12 +386,14 @@ def func(args: argparse.Namespace) -> None:
_setup_common()

commit_range = f"{args.first_commit}^^.."
asv_command = ASV_HARNESS.format(posargs=commit_range)
_subprocess_runner([*asv_command.split(" "), *args.asv_args], asv=True)
asv_command = shlex.split(ASV_HARNESS.format(posargs=commit_range))
_subprocess_runner([*asv_command, *args.asv_args], asv=True)

# git rev-list --first-parent is the command ASV uses.
git_command = f"git rev-list --first-parent {commit_range}"
commit_string = _subprocess_runner_capture(git_command.split(" "))
git_command = shlex.split(
f"git rev-list --first-parent {commit_range}"
)
commit_string = _subprocess_runner_capture(git_command)
commit_list = commit_string.split("\n")
_asv_compare(*reversed(commit_list), overnight_mode=True)

Expand Down Expand Up @@ -428,20 +428,20 @@ def add_arguments(self) -> None:
def func(args: argparse.Namespace) -> None:
_setup_common()

git_command = "git rev-parse HEAD"
head_sha = _subprocess_runner_capture(git_command.split(" "))[:8]
git_command = shlex.split("git rev-parse HEAD")
head_sha = _subprocess_runner_capture(git_command)[:8]

git_command = f"git merge-base {head_sha} {args.base_branch}"
merge_base = _subprocess_runner_capture(git_command.split(" "))[:8]
git_command = shlex.split(
f"git merge-base {head_sha} {args.base_branch}"
)
merge_base = _subprocess_runner_capture(git_command)[:8]

with NamedTemporaryFile("w") as hashfile:
hashfile.writelines([merge_base, "\n", head_sha])
hashfile.flush()
commit_range = f"HASHFILE:{hashfile.name}"
asv_command = ASV_HARNESS.format(posargs=commit_range)
_subprocess_runner(
[*asv_command.split(" "), *args.asv_args], asv=True
)
asv_command = shlex.split(ASV_HARNESS.format(posargs=commit_range))
_subprocess_runner([*asv_command, *args.asv_args], asv=True)

_asv_compare(merge_base, head_sha)

Expand Down Expand Up @@ -497,11 +497,15 @@ def csperf(
# Don't fail the whole run if memory blows on 1 benchmark.
asv_command = asv_command.replace(" --strict", "")
# Only do a single round.
asv_command = re.sub(r"rounds=\d", "rounds=1", asv_command)
_subprocess_runner([*asv_command.split(" "), *args.asv_args], asv=True)
asv_command = shlex.split(
re.sub(r"rounds=\d", "rounds=1", asv_command)
)
_subprocess_runner([*asv_command, *args.asv_args], asv=True)

asv_command = f"publish {commit_range} --html-dir={publish_subdir}"
_subprocess_runner(asv_command.split(" "), asv=True)
asv_command = shlex.split(
f"publish {commit_range} --html-dir={publish_subdir}"
)
_subprocess_runner(asv_command, asv=True)

# Print completion message.
location = BENCHMARKS_DIR / ".asv"
Expand Down

0 comments on commit 4d5b3c8

Please sign in to comment.