From 1406792f2cae55854453b3db6e4f6c05b4b160a5 Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Wed, 18 Oct 2023 21:31:13 +0000 Subject: [PATCH] naming tweaks --- runners/s3-benchrunner-python/main.py | 20 +++++++++---------- .../s3-benchrunner-python/runner/__init__.py | 2 +- runners/s3-benchrunner-python/runner/boto3.py | 6 +++--- runners/s3-benchrunner-python/runner/cli.py | 6 ++++-- runners/s3-benchrunner-python/runner/crt.py | 11 +++++----- .../s3-benchrunner-python/scripts/build.py | 2 +- 6 files changed, 24 insertions(+), 23 deletions(-) diff --git a/runners/s3-benchrunner-python/main.py b/runners/s3-benchrunner-python/main.py index 79fecf59..fc345358 100755 --- a/runners/s3-benchrunner-python/main.py +++ b/runners/s3-benchrunner-python/main.py @@ -3,17 +3,17 @@ import time from runner import ( - Benchmark, BenchmarkConfig, + BenchmarkRunner, bytes_to_MiB, bytes_to_GiB, bytes_to_megabit, bytes_to_gigabit, ns_to_secs, ) -from runner.boto3 import Boto3Benchmark -from runner.cli import CliBenchmark -from runner.crt import CrtBenchmark +from runner.boto3 import Boto3BenchmarkRunner +from runner.cli import CliBenchmarkRunner +from runner.crt import CrtBenchmarkRunner PARSER = argparse.ArgumentParser( description='Python benchmark runner. Pick which S3 library to use.') @@ -26,14 +26,14 @@ PARSER.add_argument('--verbose', action='store_true') -def create_runner_for_lib(lib: str, config: BenchmarkConfig) -> Benchmark: +def create_runner_for_lib(lib: str, config: BenchmarkConfig) -> BenchmarkRunner: """Factory function. Create appropriate subclass, given the lib.""" if lib == 'crt': - return CrtBenchmark(config) + return CrtBenchmarkRunner(config) if lib == 'boto3-python': - return Boto3Benchmark(config) + return Boto3BenchmarkRunner(config) if lib.startswith('cli-'): - return CliBenchmark(config, use_crt=lib.endswith('crt')) + return CliBenchmarkRunner(config, use_crt=lib.endswith('crt')) else: raise ValueError(f'Unknown lib: {lib}') @@ -44,7 +44,7 @@ def create_runner_for_lib(lib: str, config: BenchmarkConfig) -> Benchmark: args.TARGET_THROUGHPUT, args.verbose) # create appropriate benchmark runner for given library - benchmark = create_runner_for_lib(args.LIB, config) + runner = create_runner_for_lib(args.LIB, config) bytes_per_run = config.bytes_per_run() @@ -53,7 +53,7 @@ def create_runner_for_lib(lib: str, config: BenchmarkConfig) -> Benchmark: for run_i in range(config.max_repeat_count): run_start_ns = time.perf_counter_ns() - benchmark.run() + runner.run() run_secs = ns_to_secs(time.perf_counter_ns() - run_start_ns) print(f'Run:{run_i+1} ' + diff --git a/runners/s3-benchrunner-python/runner/__init__.py b/runners/s3-benchrunner-python/runner/__init__.py index 0838d90a..200e5559 100644 --- a/runners/s3-benchrunner-python/runner/__init__.py +++ b/runners/s3-benchrunner-python/runner/__init__.py @@ -82,7 +82,7 @@ def bytes_per_run(self) -> int: return sum([task.size for task in self.tasks]) -class Benchmark: +class BenchmarkRunner: """Base class for runnable benchmark""" def __init__(self, config: BenchmarkConfig): diff --git a/runners/s3-benchrunner-python/runner/boto3.py b/runners/s3-benchrunner-python/runner/boto3.py index e0ba0edb..33e43787 100644 --- a/runners/s3-benchrunner-python/runner/boto3.py +++ b/runners/s3-benchrunner-python/runner/boto3.py @@ -1,11 +1,11 @@ import boto3 # type: ignore from concurrent.futures import ThreadPoolExecutor -from runner import Benchmark, BenchmarkConfig +from runner import BenchmarkConfig, BenchmarkRunner -class Boto3Benchmark(Benchmark): - """Runnable benchmark using boto3.client('s3')""" +class Boto3BenchmarkRunner(BenchmarkRunner): + """Benchmark runner using boto3.client('s3')""" def __init__(self, config: BenchmarkConfig): super().__init__(config) diff --git a/runners/s3-benchrunner-python/runner/cli.py b/runners/s3-benchrunner-python/runner/cli.py index a752df8c..b6fd19cf 100644 --- a/runners/s3-benchrunner-python/runner/cli.py +++ b/runners/s3-benchrunner-python/runner/cli.py @@ -6,14 +6,16 @@ from typing import Optional, Tuple from runner import ( - Benchmark, + BenchmarkRunner, BenchmarkConfig, exit_with_error, exit_with_skip_code, ) -class CliBenchmark(Benchmark): +class CliBenchmarkRunner(BenchmarkRunner): + """Benchmark runner using AWS CLI""" + def __init__(self, config: BenchmarkConfig, use_crt: bool): super().__init__(config) self.use_crt = use_crt diff --git a/runners/s3-benchrunner-python/runner/crt.py b/runners/s3-benchrunner-python/runner/crt.py index 27f7e25d..50fb3def 100644 --- a/runners/s3-benchrunner-python/runner/crt.py +++ b/runners/s3-benchrunner-python/runner/crt.py @@ -2,14 +2,13 @@ import awscrt.http # type: ignore import awscrt.io # type: ignore import awscrt.s3 # type: ignore -from concurrent.futures import Future from typing import Optional, Tuple -from runner import Benchmark, BenchmarkConfig +from runner import BenchmarkConfig, BenchmarkRunner -class CrtBenchmark(Benchmark): - """Runnable benchmark using aws-crt-python's S3Client""" +class CrtBenchmarkRunner(BenchmarkRunner): + """Benchmark runner using aws-crt-python's S3Client""" def __init__(self, config: BenchmarkConfig): super().__init__(config) @@ -39,7 +38,7 @@ def run(self): for request in requests: request.finished_future.result() - def _make_request(self, task_i) -> Future: + def _make_request(self, task_i) -> awscrt.s3.S3Request: task = self.config.tasks[task_i] headers = awscrt.http.HttpHeaders() @@ -80,7 +79,7 @@ def _make_request(self, task_i) -> Future: # completion callback sets the future as complete, # or exits the program on error - def on_done(error: Optional[Exception], + def on_done(error: Optional[BaseException], error_headers: Optional[list[Tuple[str, str]]], error_body: Optional[bytes], **kwargs): diff --git a/runners/s3-benchrunner-python/scripts/build.py b/runners/s3-benchrunner-python/scripts/build.py index 16df8cfa..adbea4b8 100755 --- a/runners/s3-benchrunner-python/scripts/build.py +++ b/runners/s3-benchrunner-python/scripts/build.py @@ -51,7 +51,7 @@ def fetch_and_install(url: str, # create virtual environment (if necessary) awscli from Github # doesn't interfere with system installation of awscli - venv_dir = work_dir.joinpath('.venv') + venv_dir = work_dir.joinpath('venv') venv_python = str(venv_dir.joinpath('bin/python3')) if not venv_dir.exists(): run([sys.executable, '-m', 'venv', str(venv_dir)])