-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version command #242
base: master
Are you sure you want to change the base?
Version command #242
Changes from 3 commits
3df69dc
1da5d22
d3edf1a
6dbd5fc
670bc6a
8f923ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This also looks like it should be handled in |
||
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) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -26,59 +27,70 @@ | |
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') | ||
if path and not path.startswith('~'): | ||
path = os.path.abspath(path) | ||
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, 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, 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 | ||
""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason for removing this docstring? |
||
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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we use |
||
|
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need three new config files for this? Could this perhaps be solved with having 3 different executors in the same config file and testing directly for those? |
||
experiments: | ||
Test: | ||
suites: | ||
- Suite | ||
executions: | ||
- TestRunner1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate a bit what this code is doing?
Isn't this what
model.executor.Executor.compile()
is doing?