Skip to content

Commit 9aca1c3

Browse files
authored
[CI][Benchmarks] Define abstract classes (#17949)
Define base.Benchmark and base.Suite as abstract classes. They are not meant to be instantiated.
1 parent 3ec130b commit 9aca1c3

File tree

1 file changed

+23
-16
lines changed
  • devops/scripts/benchmarks/benches

1 file changed

+23
-16
lines changed

devops/scripts/benchmarks/benches/base.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from utils.result import BenchmarkMetadata, BenchmarkTag, Result
1111
from options import options
1212
from utils.utils import download, run
13+
from abc import ABC, abstractmethod
1314

1415
benchmark_tags = [
1516
BenchmarkTag("SYCL", "Benchmark uses SYCL runtime"),
@@ -34,11 +35,27 @@
3435
benchmark_tags_dict = {tag.name: tag for tag in benchmark_tags}
3536

3637

37-
class Benchmark:
38+
class Benchmark(ABC):
3839
def __init__(self, directory, suite):
3940
self.directory = directory
4041
self.suite = suite
4142

43+
@abstractmethod
44+
def name(self) -> str:
45+
pass
46+
47+
@abstractmethod
48+
def setup(self):
49+
pass
50+
51+
@abstractmethod
52+
def teardown(self):
53+
pass
54+
55+
@abstractmethod
56+
def run(self, env_vars) -> list[Result]:
57+
pass
58+
4259
@staticmethod
4360
def get_adapter_full_path():
4461
for libs_dir_name in ["lib", "lib64"]:
@@ -99,24 +116,12 @@ def download(
99116
def lower_is_better(self):
100117
return True
101118

102-
def setup(self):
103-
raise NotImplementedError()
104-
105-
def run(self, env_vars) -> list[Result]:
106-
raise NotImplementedError()
107-
108-
def teardown(self):
109-
raise NotImplementedError()
110-
111119
def stddev_threshold(self):
112120
return None
113121

114122
def get_suite_name(self) -> str:
115123
return self.suite.name()
116124

117-
def name(self):
118-
raise NotImplementedError()
119-
120125
def description(self):
121126
return ""
122127

@@ -146,12 +151,14 @@ def get_metadata(self) -> BenchmarkMetadata:
146151
)
147152

148153

149-
class Suite:
154+
class Suite(ABC):
155+
@abstractmethod
150156
def benchmarks(self) -> list[Benchmark]:
151-
raise NotImplementedError()
157+
pass
152158

159+
@abstractmethod
153160
def name(self) -> str:
154-
raise NotImplementedError()
161+
pass
155162

156163
def setup(self):
157164
return

0 commit comments

Comments
 (0)