From 3df69dce190fdb002f713c523bcb631bd466f344 Mon Sep 17 00:00:00 2001 From: antonzhukovin Date: Tue, 23 Jul 2024 11:52:12 +0100 Subject: [PATCH 1/5] Handle version_command. --- rebench/configurator.py | 27 +++++++++-- rebench/model/executor.py | 7 ++- rebench/rebench-schema.yml | 4 ++ rebench/tests/executor_test.py | 48 ++++++++++++++++--- rebench/tests/persistency.conf | 2 +- rebench/tests/small_with_version_command.conf | 33 +++++++++++++ 6 files changed, 108 insertions(+), 13 deletions(-) create mode 100644 rebench/tests/small_with_version_command.conf diff --git a/rebench/configurator.py b/rebench/configurator.py index 6b6392e1..41dde990 100644 --- a/rebench/configurator.py +++ b/rebench/configurator.py @@ -225,6 +225,22 @@ def __init__(self, raw_config, data_store, ui, cli_options=None, cli_reporter=No experiments = raw_config.get('experiments', {}) self._experiments = self._compile_experiments(experiments) + def _parse_executor(self, executor_name, executor_config): + path = executor_config.get('path') + executable = executor_config.get('executable') + cores = executor_config.get('cores') + version_command = executor_config.get('version_command') + + executor = Executor([], False, self.ui, config_dir=self.config_dir) + if version_command: + executor.set_version_command(version_command) + return executor + + def _compile_experiment(self, exp_name, experiment): + experiment['executors'] = {name: self._parse_executor(name, config) for name, config in + experiment.get('executors', {}).items()} + return Experiment.compile(exp_name, experiment, self) + @property def use_rebench_db(self): report_results = self.options is None or self.options.use_data_reporting @@ -291,9 +307,15 @@ def get_executor(self, executor_name, run_details, variables, action): raise ConfigurationError( "An experiment tries to use an undefined executor: %s" % executor_name) + executor_config = self._executors[executor_name] executor = Executor.compile( - executor_name, self._executors[executor_name], + executor_name, executor_config, run_details, variables, self.build_commands, action) + + version_command = executor_config.get('version_command') + if version_command: + executor.version_command = version_command + return executor def get_suite(self, suite_name): @@ -342,6 +364,3 @@ def _compile_experiments(self, experiments): self._exp_name, experiments[self._exp_name]) return results - - def _compile_experiment(self, exp_name, experiment): - return Experiment.compile(exp_name, experiment, self) diff --git a/rebench/model/executor.py b/rebench/model/executor.py index f03794e3..6002cb10 100644 --- a/rebench/model/executor.py +++ b/rebench/model/executor.py @@ -18,6 +18,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. import os +import subprocess from .build_cmd import BuildCommand from .exp_run_details import ExpRunDetails @@ -35,6 +36,7 @@ def compile(cls, executor_name, executor, run_details, variables, build_commands path = os.path.abspath(path) executable = executor.get('executable') args = executor.get('args') + version_command = executor.get('version_command') build = BuildCommand.create_commands(executor.get('build'), build_commands, path) @@ -51,10 +53,10 @@ def compile(cls, executor_name, executor, run_details, variables, build_commands raise ConfigurationError("Executor " + executor_name + " is configured for profiling, " + "but no profiler details are given.") - return Executor(executor_name, path, executable, args, build, description or desc, + return Executor(executor_name, path, executable, args, version_command, build, description or desc, profiler, run_details, variables, action, env) - def __init__(self, name, path, executable, args, build, description, + def __init__(self, name, path, executable, args, version_command, build, description, profiler, run_details, variables, action, env): """Specializing the executor details in the run definitions with the settings from the executor definitions @@ -63,6 +65,7 @@ def __init__(self, name, path, executable, args, build, description, self.path = path self.executable = executable self.args = args + self.version_command = version_command self.build = build self.description = description diff --git a/rebench/rebench-schema.yml b/rebench/rebench-schema.yml index 7c6669ed..0817b667 100644 --- a/rebench/rebench-schema.yml +++ b/rebench/rebench-schema.yml @@ -277,6 +277,10 @@ schema;executor_type: type: str desc: Argument given to `perf` when processing the recording default: report -g graph --no-children --stdio + version_command: + type: str + required: false + schema;exp_suite_type: desc: A list of suites diff --git a/rebench/tests/executor_test.py b/rebench/tests/executor_test.py index a7e62583..cf279dc3 100644 --- a/rebench/tests/executor_test.py +++ b/rebench/tests/executor_test.py @@ -19,17 +19,18 @@ # IN THE SOFTWARE. import unittest import os +import subprocess +from ..model.executor import Executor as RebenchExecutor from .persistence import TestPersistence from .rebench_test_case import ReBenchTestCase -from ..rebench import ReBench -from ..executor import Executor, BatchScheduler, RandomScheduler, RoundRobinScheduler -from ..configurator import Configurator, load_config +from ..rebench import ReBench +from ..executor import Executor, BatchScheduler, RandomScheduler, RoundRobinScheduler +from ..configurator import Configurator, load_config from ..model.measurement import Measurement -from ..persistence import DataStore +from ..persistence import DataStore from ..ui import UIError -from ..reporter import Reporter - +from ..reporter import Reporter class ExecutorTest(ReBenchTestCase): @@ -219,6 +220,41 @@ def test_determine_exp_name_and_filters_only_others(self): self.assertEqual(exp_name, None) self.assertEqual(exp_filter, ['e:bar', 's:b']) + def test_version_command(self): + executor = RebenchExecutor( + "TestExecutor", None, None, None, "python --version", + None, None, None, None, None, None, None + ) + + try: + result = subprocess.run( + executor.version_command, shell=True, check=True, + stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True + ) + version_output = result.stdout.strip() + except subprocess.CalledProcessError as e: + version_output = e.stderr.strip() + self.assertTrue("Python" in version_output) + + def test_version_command_in_config(self): + self._cnf = Configurator(load_config(self._path + '/small_with_version_command.conf'), DataStore(self.ui), + self.ui, None, data_file=self._tmp_file) + runs = self._cnf.get_runs() + executor = list(runs)[0].benchmark.suite.executor + + self.assertEqual(executor.version_command, "python --version") + + try: + result = subprocess.run( + executor.version_command, shell=True, check=True, + stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True + ) + version_output = result.stdout.strip() + except subprocess.CalledProcessError as e: + version_output = e.stderr.strip() + + self.assertTrue("Python" in version_output) + class _TestReporter(Reporter): __test__ = False # This is not a test class diff --git a/rebench/tests/persistency.conf b/rebench/tests/persistency.conf index 99dbaec5..a082e5d5 100644 --- a/rebench/tests/persistency.conf +++ b/rebench/tests/persistency.conf @@ -3,7 +3,7 @@ # this run definition will be chosen if no parameters are given to rebench.py default_experiment: Test -default_data_file: 'persistency.data' +default_data_file: 'persistency.data' reporting: codespeed: diff --git a/rebench/tests/small_with_version_command.conf b/rebench/tests/small_with_version_command.conf new file mode 100644 index 00000000..e961991e --- /dev/null +++ b/rebench/tests/small_with_version_command.conf @@ -0,0 +1,33 @@ +# Config file for ReBench +# Config format is YAML (see http://yaml.org/ for detailed spec) + +# this run definition will be chosen if no parameters are given to rebench.py +default_experiment: Test +default_data_file: 'small.data' + +# general configuration for runs +runs: + invocations: 10 + retries_after_failure: 3 + +benchmark_suites: + Suite: + gauge_adapter: TestExecutor + command: TestBenchMarks ~/suiteFolder/%(benchmark)s + benchmarks: + - Bench1 + - Bench2 + +executors: + TestRunner1: + path: ~/PycharmProjects/ReBench/rebench/tests + executable: test-vm1.py %(cores)s + cores: [1] + version_command: "python --version" + +experiments: + Test: + suites: + - Suite + executions: + - TestRunner1 From 1da5d22e0d38d413edc751398e4ce07cfca4f973 Mon Sep 17 00:00:00 2001 From: antonzhukovin Date: Tue, 23 Jul 2024 11:59:11 +0100 Subject: [PATCH 2/5] Handle version_command, fixed tests: added missing arguments. --- rebench/tests/bugs/issue_4_run_equality_and_params_test.py | 4 ++-- rebench/tests/persistency_test.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rebench/tests/bugs/issue_4_run_equality_and_params_test.py b/rebench/tests/bugs/issue_4_run_equality_and_params_test.py index 0126c2d0..8e423ac7 100644 --- a/rebench/tests/bugs/issue_4_run_equality_and_params_test.py +++ b/rebench/tests/bugs/issue_4_run_equality_and_params_test.py @@ -36,7 +36,7 @@ def setUp(self): @staticmethod def _create_template_run_id(): executor = Executor('MyVM', 'foo_bar_path', 'foo_bar_bin', - None, None, None, None, None, None, "benchmark", {}) + None, None,None, None, None, None, None, "benchmark", {}) suite = BenchmarkSuite("MySuite", executor, '', '%(benchmark)s %(cores)s %(input)s', None, None, [], None, None, None) benchmark = Benchmark("TestBench", "TestBench", None, suite, None, @@ -46,7 +46,7 @@ def _create_template_run_id(): @staticmethod def _create_hardcoded_run_id(): executor = Executor('MyVM', 'foo_bar_path', 'foo_bar_bin', - None, None, None, None, None, None, "benchmark", {}) + None, None, None, None, None, None, None, "benchmark", {}) suite = BenchmarkSuite('MySuite', executor, '', '%(benchmark)s %(cores)s 2 3', None, None, [], None, None, None) benchmark = Benchmark("TestBench", "TestBench", None, suite, diff --git a/rebench/tests/persistency_test.py b/rebench/tests/persistency_test.py index 6ad6425b..44805c96 100644 --- a/rebench/tests/persistency_test.py +++ b/rebench/tests/persistency_test.py @@ -45,7 +45,7 @@ class PersistencyTest(ReBenchTestCase): def test_de_serialization(self): data_store = DataStore(self.ui) executor = ExecutorConf("MyVM", '', '', - None, None, None, None, None, None, "benchmark", {}) + None, None,None, None, None, None, None, "benchmark", {}) suite = BenchmarkSuite("MySuite", executor, '', '', None, None, None, None, None, None) benchmark = Benchmark("Test Bench [>", "Test Bench [>", None, From d3edf1aec6b88c1a7139e5325a74a8216d66e799 Mon Sep 17 00:00:00 2001 From: antonzhukovin Date: Sat, 27 Jul 2024 02:20:27 +0100 Subject: [PATCH 3/5] Handle version_string, version_git --- rebench/model/executor.py | 51 ++++++++++------- rebench/rebench-schema.yml | 10 +++- .../issue_4_run_equality_and_params_test.py | 4 +- rebench/tests/executor_test.py | 57 ++++++++++++++++++- rebench/tests/persistency_test.py | 2 +- rebench/tests/small_with_version_git.conf | 27 +++++++++ rebench/tests/small_with_version_string.conf | 33 +++++++++++ 7 files changed, 158 insertions(+), 26 deletions(-) create mode 100644 rebench/tests/small_with_version_git.conf create mode 100644 rebench/tests/small_with_version_string.conf diff --git a/rebench/model/executor.py b/rebench/model/executor.py index 6002cb10..0bc9bfb2 100644 --- a/rebench/model/executor.py +++ b/rebench/model/executor.py @@ -27,8 +27,7 @@ from ..configuration_error import ConfigurationError -class Executor(object): - +class Executor: @classmethod def compile(cls, executor_name, executor, run_details, variables, build_commands, action): path = executor.get('path') @@ -37,51 +36,61 @@ def compile(cls, executor_name, executor, run_details, variables, build_commands executable = executor.get('executable') args = executor.get('args') version_command = executor.get('version_command') + version_string = executor.get('version_string') + version_git = executor.get('version_git') build = BuildCommand.create_commands(executor.get('build'), build_commands, path) - description = executor.get('description') desc = executor.get('desc') env = executor.get('env') - profiler = Profiler.compile(executor.get('profiler')) - run_details = ExpRunDetails.compile(executor, run_details) variables = ExpVariables.compile(executor, variables) if action == "profile" and len(profiler) == 0: - raise ConfigurationError("Executor " + executor_name + " is configured for profiling, " - + "but no profiler details are given.") + raise ConfigurationError(f"Executor {executor_name} is configured for profiling, " + "but no profiler details are given.") - return Executor(executor_name, path, executable, args, version_command, build, description or desc, - profiler, run_details, variables, action, env) + return Executor(executor_name, path, executable, args, version_command, version_string, version_git, build, + description or desc, profiler, run_details, variables, action, env) - def __init__(self, name, path, executable, args, version_command, build, description, + def __init__(self, name, path, executable, args, version_command, version_string, version_git, build, description, profiler, run_details, variables, action, env): - """Specializing the executor details in the run definitions with the settings from - the executor definitions - """ self.name = name self.path = path self.executable = executable self.args = args self.version_command = version_command - + self.version_string = version_string + self.version_git = version_git self.build = build self.description = description self.profiler = profiler - self.run_details = run_details self.variables = variables self.env = env - self.action = action + def get_version(self): + if self.version_command: + try: + result = subprocess.run(self.version_command, shell=True, check=True, capture_output=True, text=True) + return result.stdout.strip() + except subprocess.CalledProcessError as e: + return e.stderr.strip() + elif self.version_string: + return self.version_string + elif self.version_git: + try: + result = subprocess.run(self.version_git, shell=True, check=True, capture_output=True, text=True) + return result.stdout.strip() + except subprocess.CalledProcessError as e: + return e.stderr.strip() + else: + return "Unknown version" + def as_dict(self): - result = { - 'name': self.name, - 'desc': self.description - } + result = {'name': self.name, 'desc': self.description} if self.build: result['build'] = [b.as_dict() for b in self.build] - return result + return result \ No newline at end of file diff --git a/rebench/rebench-schema.yml b/rebench/rebench-schema.yml index 0817b667..74a7dcf9 100644 --- a/rebench/rebench-schema.yml +++ b/rebench/rebench-schema.yml @@ -280,7 +280,15 @@ schema;executor_type: version_command: type: str required: false - + desc: Command to retrieve the version of the executable. + version_string: + type: str + required: false + desc: Explicit version string provided by the user. + version_git: + type: str + required: false + desc: Command to retrieve the Git version of the executable. schema;exp_suite_type: desc: A list of suites diff --git a/rebench/tests/bugs/issue_4_run_equality_and_params_test.py b/rebench/tests/bugs/issue_4_run_equality_and_params_test.py index 8e423ac7..e78a102f 100644 --- a/rebench/tests/bugs/issue_4_run_equality_and_params_test.py +++ b/rebench/tests/bugs/issue_4_run_equality_and_params_test.py @@ -36,7 +36,7 @@ def setUp(self): @staticmethod def _create_template_run_id(): executor = Executor('MyVM', 'foo_bar_path', 'foo_bar_bin', - None, None,None, None, None, None, None, "benchmark", {}) + None, None, None, None, None, None, None, None, None, "benchmark", {}) suite = BenchmarkSuite("MySuite", executor, '', '%(benchmark)s %(cores)s %(input)s', None, None, [], None, None, None) benchmark = Benchmark("TestBench", "TestBench", None, suite, None, @@ -46,7 +46,7 @@ def _create_template_run_id(): @staticmethod def _create_hardcoded_run_id(): executor = Executor('MyVM', 'foo_bar_path', 'foo_bar_bin', - None, None, None, None, None, None, None, "benchmark", {}) + None, None, None, None, None, None, None, None, None, "benchmark", {}) suite = BenchmarkSuite('MySuite', executor, '', '%(benchmark)s %(cores)s 2 3', None, None, [], None, None, None) benchmark = Benchmark("TestBench", "TestBench", None, suite, diff --git a/rebench/tests/executor_test.py b/rebench/tests/executor_test.py index cf279dc3..7ce37946 100644 --- a/rebench/tests/executor_test.py +++ b/rebench/tests/executor_test.py @@ -223,7 +223,7 @@ def test_determine_exp_name_and_filters_only_others(self): def test_version_command(self): executor = RebenchExecutor( "TestExecutor", None, None, None, "python --version", - None, None, None, None, None, None, None + None, None, None, None, None, None, None, None, None ) try: @@ -255,6 +255,61 @@ def test_version_command_in_config(self): self.assertTrue("Python" in version_output) + def test_version_string(self): + executor = RebenchExecutor( + "TestExecutor", None, None, None, None, "7.42", + None, None, None, None, None, None, None, None + ) + + version_output = executor.version_string + self.assertTrue("7.42" in version_output) + + def test_version_string_in_config(self): + self._cnf = Configurator(load_config(self._path + '/small_with_version_string.conf'), DataStore(self.ui), + self.ui, None, data_file=self._tmp_file) + runs = self._cnf.get_runs() + executor = list(runs)[0].benchmark.suite.executor + + self.assertEqual(executor.version_string, "7.42") + + version_output = executor.version_string + self.assertTrue("7.42" in version_output) + + def test_version_git(self): + executor = RebenchExecutor( + "TestExecutor", None, None, None, None, None, + "git rev-parse HEAD", None, None, None, None, None, None, None + ) + + try: + result = subprocess.run( + executor.version_git, shell=True, check=True, + stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True + ) + version_output = result.stdout.strip() + except subprocess.CalledProcessError as e: + version_output = e.stderr.strip() + self.assertTrue(len(version_output) > 0) + + def test_version_git_in_config(self): + self._cnf = Configurator(load_config(self._path + '/small_with_version_git.conf'), DataStore(self.ui), + self.ui, None, data_file=self._tmp_file) + runs = self._cnf.get_runs() + executor = list(runs)[0].benchmark.suite.executor + + self.assertEqual(executor.version_git, "git rev-parse HEAD") + + try: + result = subprocess.run( + executor.version_git, shell=True, check=True, + stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True + ) + version_output = result.stdout.strip() + except subprocess.CalledProcessError as e: + version_output = e.stderr.strip() + + self.assertTrue(len(version_output) > 0) + class _TestReporter(Reporter): __test__ = False # This is not a test class diff --git a/rebench/tests/persistency_test.py b/rebench/tests/persistency_test.py index 44805c96..bceba098 100644 --- a/rebench/tests/persistency_test.py +++ b/rebench/tests/persistency_test.py @@ -45,7 +45,7 @@ class PersistencyTest(ReBenchTestCase): def test_de_serialization(self): data_store = DataStore(self.ui) executor = ExecutorConf("MyVM", '', '', - None, None,None, None, None, None, None, "benchmark", {}) + None, None, None, None,None, None, None, None, None, "benchmark", {}) suite = BenchmarkSuite("MySuite", executor, '', '', None, None, None, None, None, None) benchmark = Benchmark("Test Bench [>", "Test Bench [>", None, diff --git a/rebench/tests/small_with_version_git.conf b/rebench/tests/small_with_version_git.conf new file mode 100644 index 00000000..163c82aa --- /dev/null +++ b/rebench/tests/small_with_version_git.conf @@ -0,0 +1,27 @@ +# Config file for ReBench +# Config format is YAML (see http://yaml.org/ for detailed spec) + +# this run definition will be chosen if no parameters are given to rebench.py +default_experiment: Test +default_data_file: 'small.data' + +# general configuration for runs +benchmark_suites: + Suite: + gauge_adapter: TestExecutor + command: TestBenchMarks ~/suiteFolder/%(benchmark)s + benchmarks: + - Bench1 + - Bench2 +executors: + TestRunner1: + path: ~/PycharmProjects/ReBench/rebench/tests + executable: test-vm1.py %(cores)s + cores: [1] + version_git: "git rev-parse HEAD" +experiments: + Test: + suites: + - Suite + executions: + - TestRunner1 diff --git a/rebench/tests/small_with_version_string.conf b/rebench/tests/small_with_version_string.conf new file mode 100644 index 00000000..5370a26a --- /dev/null +++ b/rebench/tests/small_with_version_string.conf @@ -0,0 +1,33 @@ +# Config file for ReBench +# Config format is YAML (see http://yaml.org/ for detailed spec) + +# this run definition will be chosen if no parameters are given to rebench.py +default_experiment: Test +default_data_file: 'small.data' + +# general configuration for runs +runs: + invocations: 10 + retries_after_failure: 3 + +benchmark_suites: + Suite: + gauge_adapter: TestExecutor + command: TestBenchMarks ~/suiteFolder/%(benchmark)s + benchmarks: + - Bench1 + - Bench2 + +executors: + TestRunner1: + path: ~/PycharmProjects/ReBench/rebench/tests + executable: test-vm1.py %(cores)s + cores: [1] + version_string: "7.42" + +experiments: + Test: + suites: + - Suite + executions: + - TestRunner1 From 6dbd5fc26b6fad727c113591ccde639b049b013b Mon Sep 17 00:00:00 2001 From: antonzhukovin Date: Thu, 1 Aug 2024 20:06:19 +0100 Subject: [PATCH 4/5] =?UTF-8?q?Handle=20=E2=80=9Cversion=E2=80=9D=20inform?= =?UTF-8?q?ation=20in=20the=20executor.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Handle version: _command, _string, _git. Removed code from configurator.py, which duplicates executor.py. Joined all separate “version” configuration files into a single one. Also, in the executor.py get_version function returns None instead of string, if version is not found. --- rebench/configurator.py | 26 +++------------ rebench/model/executor.py | 5 ++- rebench/tests/executor_test.py | 6 ++-- ...n_command.conf => small_with_version.conf} | 7 ++-- rebench/tests/small_with_version_git.conf | 27 --------------- rebench/tests/small_with_version_string.conf | 33 ------------------- 6 files changed, 15 insertions(+), 89 deletions(-) rename rebench/tests/{small_with_version_command.conf => small_with_version.conf} (84%) delete mode 100644 rebench/tests/small_with_version_git.conf delete mode 100644 rebench/tests/small_with_version_string.conf diff --git a/rebench/configurator.py b/rebench/configurator.py index 41dde990..d7083d6e 100644 --- a/rebench/configurator.py +++ b/rebench/configurator.py @@ -225,22 +225,6 @@ def __init__(self, raw_config, data_store, ui, cli_options=None, cli_reporter=No experiments = raw_config.get('experiments', {}) self._experiments = self._compile_experiments(experiments) - def _parse_executor(self, executor_name, executor_config): - path = executor_config.get('path') - executable = executor_config.get('executable') - cores = executor_config.get('cores') - version_command = executor_config.get('version_command') - - executor = Executor([], False, self.ui, config_dir=self.config_dir) - if version_command: - executor.set_version_command(version_command) - return executor - - def _compile_experiment(self, exp_name, experiment): - experiment['executors'] = {name: self._parse_executor(name, config) for name, config in - experiment.get('executors', {}).items()} - return Experiment.compile(exp_name, experiment, self) - @property def use_rebench_db(self): report_results = self.options is None or self.options.use_data_reporting @@ -307,15 +291,10 @@ def get_executor(self, executor_name, run_details, variables, action): raise ConfigurationError( "An experiment tries to use an undefined executor: %s" % executor_name) - executor_config = self._executors[executor_name] executor = Executor.compile( - executor_name, executor_config, + executor_name, self._executors[executor_name], run_details, variables, self.build_commands, action) - version_command = executor_config.get('version_command') - if version_command: - executor.version_command = version_command - return executor def get_suite(self, suite_name): @@ -364,3 +343,6 @@ def _compile_experiments(self, experiments): self._exp_name, experiments[self._exp_name]) return results + + def _compile_experiment(self, exp_name, experiment): + return Experiment.compile(exp_name, experiment, self) \ No newline at end of file diff --git a/rebench/model/executor.py b/rebench/model/executor.py index 0bc9bfb2..de1038aa 100644 --- a/rebench/model/executor.py +++ b/rebench/model/executor.py @@ -56,6 +56,9 @@ def compile(cls, executor_name, executor, run_details, variables, build_commands def __init__(self, name, path, executable, args, version_command, version_string, version_git, build, description, profiler, run_details, variables, action, env): + """Specializing the executor details in the run definitions with the settings from + the executor definitions + """ self.name = name self.path = path self.executable = executable @@ -87,7 +90,7 @@ def get_version(self): except subprocess.CalledProcessError as e: return e.stderr.strip() else: - return "Unknown version" + return None def as_dict(self): result = {'name': self.name, 'desc': self.description} diff --git a/rebench/tests/executor_test.py b/rebench/tests/executor_test.py index 7ce37946..5fca26b7 100644 --- a/rebench/tests/executor_test.py +++ b/rebench/tests/executor_test.py @@ -237,7 +237,7 @@ def test_version_command(self): self.assertTrue("Python" in version_output) def test_version_command_in_config(self): - self._cnf = Configurator(load_config(self._path + '/small_with_version_command.conf'), DataStore(self.ui), + self._cnf = Configurator(load_config(self._path + '/small_with_version.conf'), DataStore(self.ui), self.ui, None, data_file=self._tmp_file) runs = self._cnf.get_runs() executor = list(runs)[0].benchmark.suite.executor @@ -265,7 +265,7 @@ def test_version_string(self): self.assertTrue("7.42" in version_output) def test_version_string_in_config(self): - self._cnf = Configurator(load_config(self._path + '/small_with_version_string.conf'), DataStore(self.ui), + self._cnf = Configurator(load_config(self._path + '/small_with_version.conf'), DataStore(self.ui), self.ui, None, data_file=self._tmp_file) runs = self._cnf.get_runs() executor = list(runs)[0].benchmark.suite.executor @@ -292,7 +292,7 @@ def test_version_git(self): self.assertTrue(len(version_output) > 0) def test_version_git_in_config(self): - self._cnf = Configurator(load_config(self._path + '/small_with_version_git.conf'), DataStore(self.ui), + self._cnf = Configurator(load_config(self._path + '/small_with_version.conf'), DataStore(self.ui), self.ui, None, data_file=self._tmp_file) runs = self._cnf.get_runs() executor = list(runs)[0].benchmark.suite.executor diff --git a/rebench/tests/small_with_version_command.conf b/rebench/tests/small_with_version.conf similarity index 84% rename from rebench/tests/small_with_version_command.conf rename to rebench/tests/small_with_version.conf index e961991e..1265f6f1 100644 --- a/rebench/tests/small_with_version_command.conf +++ b/rebench/tests/small_with_version.conf @@ -21,13 +21,14 @@ benchmark_suites: executors: TestRunner1: path: ~/PycharmProjects/ReBench/rebench/tests - executable: test-vm1.py %(cores)s - cores: [1] + executable: test-vm1.py version_command: "python --version" + version_string: "7.42" + version_git: "git rev-parse HEAD" experiments: Test: suites: - Suite executions: - - TestRunner1 + - TestRunner1 \ No newline at end of file diff --git a/rebench/tests/small_with_version_git.conf b/rebench/tests/small_with_version_git.conf deleted file mode 100644 index 163c82aa..00000000 --- a/rebench/tests/small_with_version_git.conf +++ /dev/null @@ -1,27 +0,0 @@ -# Config file for ReBench -# Config format is YAML (see http://yaml.org/ for detailed spec) - -# this run definition will be chosen if no parameters are given to rebench.py -default_experiment: Test -default_data_file: 'small.data' - -# general configuration for runs -benchmark_suites: - Suite: - gauge_adapter: TestExecutor - command: TestBenchMarks ~/suiteFolder/%(benchmark)s - benchmarks: - - Bench1 - - Bench2 -executors: - TestRunner1: - path: ~/PycharmProjects/ReBench/rebench/tests - executable: test-vm1.py %(cores)s - cores: [1] - version_git: "git rev-parse HEAD" -experiments: - Test: - suites: - - Suite - executions: - - TestRunner1 diff --git a/rebench/tests/small_with_version_string.conf b/rebench/tests/small_with_version_string.conf deleted file mode 100644 index 5370a26a..00000000 --- a/rebench/tests/small_with_version_string.conf +++ /dev/null @@ -1,33 +0,0 @@ -# Config file for ReBench -# Config format is YAML (see http://yaml.org/ for detailed spec) - -# this run definition will be chosen if no parameters are given to rebench.py -default_experiment: Test -default_data_file: 'small.data' - -# general configuration for runs -runs: - invocations: 10 - retries_after_failure: 3 - -benchmark_suites: - Suite: - gauge_adapter: TestExecutor - command: TestBenchMarks ~/suiteFolder/%(benchmark)s - benchmarks: - - Bench1 - - Bench2 - -executors: - TestRunner1: - path: ~/PycharmProjects/ReBench/rebench/tests - executable: test-vm1.py %(cores)s - cores: [1] - version_string: "7.42" - -experiments: - Test: - suites: - - Suite - executions: - - TestRunner1 From 8f923eff5c10a6e9ba41f255d14feacd4e7e2dec Mon Sep 17 00:00:00 2001 From: antonzhukovin Date: Thu, 1 Aug 2024 20:26:58 +0100 Subject: [PATCH 5/5] =?UTF-8?q?Handle=20=E2=80=9Cversion=E2=80=9D=20inform?= =?UTF-8?q?ation=20in=20the=20executor.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Handle version: _command, _string, _git. Removed code from configurator.py, which duplicates executor.py. Joined all separate “version” configuration files into a single one. Also, in the executor.py get_version function returns None instead of string, if version is not found. Also fixed the code in order to make it pass the pylit tests (line too long, etc.) --- rebench/configurator.py | 2 +- rebench/model/executor.py | 14 +++++++++----- rebench/tests/executor_test.py | 21 ++++++++++++--------- rebench/tests/persistency_test.py | 4 +++- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/rebench/configurator.py b/rebench/configurator.py index d7083d6e..e389860d 100644 --- a/rebench/configurator.py +++ b/rebench/configurator.py @@ -345,4 +345,4 @@ def _compile_experiments(self, experiments): return results def _compile_experiment(self, exp_name, experiment): - return Experiment.compile(exp_name, experiment, self) \ No newline at end of file + return Experiment.compile(exp_name, experiment, self) diff --git a/rebench/model/executor.py b/rebench/model/executor.py index de1038aa..4b30c86a 100644 --- a/rebench/model/executor.py +++ b/rebench/model/executor.py @@ -51,10 +51,12 @@ def compile(cls, executor_name, executor, run_details, variables, build_commands raise ConfigurationError(f"Executor {executor_name} is configured for profiling, " "but no profiler details are given.") - return Executor(executor_name, path, executable, args, version_command, version_string, version_git, build, + return Executor(executor_name, path, executable, args, + version_command, version_string, version_git, build, description or desc, profiler, run_details, variables, action, env) - def __init__(self, name, path, executable, args, version_command, version_string, version_git, build, description, + def __init__(self, name, path, executable, args, + version_command, version_string, version_git, build, description, profiler, run_details, variables, action, env): """Specializing the executor details in the run definitions with the settings from the executor definitions @@ -77,7 +79,8 @@ def __init__(self, name, path, executable, args, version_command, version_string def get_version(self): if self.version_command: try: - result = subprocess.run(self.version_command, shell=True, check=True, capture_output=True, text=True) + result = subprocess.run(self.version_command, shell=True, + check=True, capture_output=True, text=True) return result.stdout.strip() except subprocess.CalledProcessError as e: return e.stderr.strip() @@ -85,7 +88,8 @@ def get_version(self): return self.version_string elif self.version_git: try: - result = subprocess.run(self.version_git, shell=True, check=True, capture_output=True, text=True) + result = subprocess.run(self.version_git, shell=True, + check=True, capture_output=True, text=True) return result.stdout.strip() except subprocess.CalledProcessError as e: return e.stderr.strip() @@ -96,4 +100,4 @@ def as_dict(self): result = {'name': self.name, 'desc': self.description} if self.build: result['build'] = [b.as_dict() for b in self.build] - return result \ No newline at end of file + return result diff --git a/rebench/tests/executor_test.py b/rebench/tests/executor_test.py index 5fca26b7..c0dc7d6c 100644 --- a/rebench/tests/executor_test.py +++ b/rebench/tests/executor_test.py @@ -237,9 +237,10 @@ def test_version_command(self): self.assertTrue("Python" in version_output) def test_version_command_in_config(self): - self._cnf = Configurator(load_config(self._path + '/small_with_version.conf'), DataStore(self.ui), - self.ui, None, data_file=self._tmp_file) - runs = self._cnf.get_runs() + cnf = Configurator(load_config(self._path + '/small_with_version.conf'), + DataStore(self.ui), + self.ui, None, data_file=self._tmp_file) + runs = cnf.get_runs() executor = list(runs)[0].benchmark.suite.executor self.assertEqual(executor.version_command, "python --version") @@ -265,9 +266,10 @@ def test_version_string(self): self.assertTrue("7.42" in version_output) def test_version_string_in_config(self): - self._cnf = Configurator(load_config(self._path + '/small_with_version.conf'), DataStore(self.ui), - self.ui, None, data_file=self._tmp_file) - runs = self._cnf.get_runs() + cnf = Configurator(load_config(self._path + '/small_with_version.conf'), + DataStore(self.ui), + self.ui, None, data_file=self._tmp_file) + runs = cnf.get_runs() executor = list(runs)[0].benchmark.suite.executor self.assertEqual(executor.version_string, "7.42") @@ -292,9 +294,10 @@ def test_version_git(self): self.assertTrue(len(version_output) > 0) def test_version_git_in_config(self): - self._cnf = Configurator(load_config(self._path + '/small_with_version.conf'), DataStore(self.ui), - self.ui, None, data_file=self._tmp_file) - runs = self._cnf.get_runs() + cnf = Configurator(load_config(self._path + '/small_with_version.conf'), + DataStore(self.ui), + self.ui, None, data_file=self._tmp_file) + runs = cnf.get_runs() executor = list(runs)[0].benchmark.suite.executor self.assertEqual(executor.version_git, "git rev-parse HEAD") diff --git a/rebench/tests/persistency_test.py b/rebench/tests/persistency_test.py index bceba098..9d53f575 100644 --- a/rebench/tests/persistency_test.py +++ b/rebench/tests/persistency_test.py @@ -45,7 +45,9 @@ class PersistencyTest(ReBenchTestCase): def test_de_serialization(self): data_store = DataStore(self.ui) executor = ExecutorConf("MyVM", '', '', - None, None, None, None,None, None, None, None, None, "benchmark", {}) + None, None, None, None, + None, None, None, None, + None, "benchmark", {}) suite = BenchmarkSuite("MySuite", executor, '', '', None, None, None, None, None, None) benchmark = Benchmark("Test Bench [>", "Test Bench [>", None,