Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenworsley committed May 17, 2024
1 parent 58e407d commit e7cce70
Showing 1 changed file with 12 additions and 42 deletions.
54 changes: 12 additions & 42 deletions benchmarks/bm_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,6 @@ def _prep_data_gen_env() -> None:
).resolve()
environ[data_gen_var] = str(data_gen_python)

_echo("Installing Mule into data generation environment ...")
mule_dir = data_gen_python.parents[1] / "resources" / "mule"
if not mule_dir.is_dir():
_subprocess_runner(
[
"git",
"clone",
"https://github.com/metomi/mule.git",
str(mule_dir),
]
)
_subprocess_runner(
[
str(data_gen_python),
"-m",
"pip",
"install",
str(mule_dir / "mule"),
]
)

_echo("Data generation environment ready.")


Expand Down Expand Up @@ -224,19 +203,20 @@ def func(args: argparse.Namespace) -> None:
_asv_compare(merge_base, head_sha)


class _CSPerf(_SubParserGenerator, ABC):
"""Common code used by both CPerf and SPerf."""
class SPerf(_SubParserGenerator):
"""Class for parsing and running the 'sperf' argument."""

name = "sperf"
description = (
"Run the on-demand {} suite of benchmarks (part of the UK Met "
"Run the on-demand Sperf suite of benchmarks (part of the UK Met "
"Office NG-VAT project) for the ``HEAD`` of ``upstream/main`` only, "
"and publish the results to the input **publish_dir**, within a "
"unique subdirectory for this run.\n"
"Uses `asv run`."
)
epilog = (
"e.g. python bm_runner.py {0} my_publish_dir\n"
"e.g. python bm_runner.py {0} my_publish_dir --bench=regridding"
"e.g. python bm_runner.py sperf my_publish_dir\n"
"e.g. python bm_runner.py sperf my_publish_dir --bench=regridding"
)

def add_arguments(self) -> None:
Expand All @@ -247,15 +227,15 @@ def add_arguments(self) -> None:
)

@staticmethod
def csperf(args: argparse.Namespace, run_type: str) -> None:
def func(args: argparse.Namespace) -> None:
_setup_common()

publish_dir = Path(args.publish_dir)
if not publish_dir.is_dir():
message = f"Input 'publish directory' is not a directory: {publish_dir}"
raise NotADirectoryError(message)
publish_subdir = (
publish_dir / f"{run_type}_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
publish_dir / f".*Scalability.*_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
)
publish_subdir.mkdir()

Expand All @@ -264,7 +244,9 @@ def csperf(args: argparse.Namespace, run_type: str) -> None:
environ["ON_DEMAND_BENCHMARKS"] = "True"
commit_range = "upstream/main^!"

asv_command = ASV_HARNESS.format(posargs=commit_range) + f" --bench={run_type}"
asv_command = (
ASV_HARNESS.format(posargs=commit_range) + " --bench=.*Scalability.*"
)

# Only do a single round.
asv_command = shlex.split(re.sub(r"rounds=\d", "rounds=1", asv_command))
Expand All @@ -283,24 +265,12 @@ def csperf(args: argparse.Namespace, run_type: str) -> None:
# Print completion message.
location = BENCHMARKS_DIR / ".asv"
_echo(
f'New ASV results for "{run_type}".\n'
f'New ASV results for ".*Scalability.*".\n'
f'See "{publish_subdir}",'
f'\n or JSON files under "{location / "results"}".'
)


class SPerf(_CSPerf):
"""Class for parsing and running the 'sperf' argument."""

name = "sperf"
description = _CSPerf.description.format("SPerf")
epilog = _CSPerf.epilog.format("sperf")

@staticmethod
def func(args: argparse.Namespace) -> None:
_CSPerf.csperf(args, ".*Scalability.*")


class Custom(_SubParserGenerator):
"""Class for parsing and running the 'custom' argument."""

Expand Down

0 comments on commit e7cce70

Please sign in to comment.