From 4ae9387e273bb6589780657e4ddabe3023720bfb Mon Sep 17 00:00:00 2001 From: Patryk Kaminski Date: Thu, 10 Apr 2025 09:01:34 +0200 Subject: [PATCH] [CI][Benchmarks] Define abstract classes Define base.Benchmark and base.Suite as abstract classes. They are not meant to be instantiated. --- devops/scripts/benchmarks/benches/base.py | 39 +++++++++++++---------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/devops/scripts/benchmarks/benches/base.py b/devops/scripts/benchmarks/benches/base.py index ab38df2e74711..b34c7ec64d1f8 100644 --- a/devops/scripts/benchmarks/benches/base.py +++ b/devops/scripts/benchmarks/benches/base.py @@ -10,6 +10,7 @@ from utils.result import BenchmarkMetadata, BenchmarkTag, Result from options import options from utils.utils import download, run +from abc import ABC, abstractmethod benchmark_tags = [ BenchmarkTag("SYCL", "Benchmark uses SYCL runtime"), @@ -34,11 +35,27 @@ benchmark_tags_dict = {tag.name: tag for tag in benchmark_tags} -class Benchmark: +class Benchmark(ABC): def __init__(self, directory, suite): self.directory = directory self.suite = suite + @abstractmethod + def name(self) -> str: + pass + + @abstractmethod + def setup(self): + pass + + @abstractmethod + def teardown(self): + pass + + @abstractmethod + def run(self, env_vars) -> list[Result]: + pass + @staticmethod def get_adapter_full_path(): for libs_dir_name in ["lib", "lib64"]: @@ -99,24 +116,12 @@ def download( def lower_is_better(self): return True - def setup(self): - raise NotImplementedError() - - def run(self, env_vars) -> list[Result]: - raise NotImplementedError() - - def teardown(self): - raise NotImplementedError() - def stddev_threshold(self): return None def get_suite_name(self) -> str: return self.suite.name() - def name(self): - raise NotImplementedError() - def description(self): return "" @@ -146,12 +151,14 @@ def get_metadata(self) -> BenchmarkMetadata: ) -class Suite: +class Suite(ABC): + @abstractmethod def benchmarks(self) -> list[Benchmark]: - raise NotImplementedError() + pass + @abstractmethod def name(self) -> str: - raise NotImplementedError() + pass def setup(self): return