Skip to content

Commit

Permalink
Merge PR #83: Improve user interface and output of ReBench
Browse files Browse the repository at this point in the history
  • Loading branch information
smarr committed Jun 18, 2018
2 parents 710beb7 + 6ebaa05 commit 656019f
Show file tree
Hide file tree
Showing 22 changed files with 510 additions and 332 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ addons:
- time

install:
- pip install coveralls humanfriendly pylint
- pip install .
- pip install coveralls
- pip install pylint

# command to run tests
script:
Expand Down
72 changes: 30 additions & 42 deletions rebench/configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
import sys
import logging
import subprocess
import traceback
from os.path import dirname

from .model.experiment import Experiment
from .model.exp_run_details import ExpRunDetails
from .model.exp_variables import ExpVariables
from .model.reporting import Reporting
from .model.virtual_machine import VirtualMachine
from .ui import UIError, DETAIL_INDENT, error, set_verbose_debug_mode


class _VMFilter(object):
Expand Down Expand Up @@ -116,32 +114,36 @@ def load_config(file_name):
"""
import yaml
from pykwalify.core import Core
from pykwalify.errors import SchemaError

# Disable most logging for pykwalify
logging.getLogger('pykwalify').setLevel(logging.ERROR)
import logging
logging.getLogger('pykwalify').setLevel(logging.CRITICAL)
logging.getLogger('pykwalify').addHandler(logging.NullHandler())

try:
with open(file_name, 'r') as conf_file:
data = yaml.safe_load(conf_file)
validator = Core(
source_data=data,
schema_files=[dirname(__file__) + "/rebench-schema.yml"])
validator.validate(raise_exception=False)
if validator.validation_errors and validator.validation_errors:
logging.error(
"Validation of " + file_name + " failed. " +
(" ".join(validator.validation_errors)))
sys.exit(-1)
try:
validator.validate(raise_exception=True)
except SchemaError as err:
raise UIError(
"Validation of " + file_name + " failed." + DETAIL_INDENT +
(DETAIL_INDENT.join(validator.validation_errors)), err)
return data
except IOError:
logging.error("An error occurred on opening the config file (%s)."
% file_name)
logging.error(traceback.format_exc(0))
sys.exit(-1)
except yaml.YAMLError:
logging.error("Failed parsing the config file (%s)." % file_name)
logging.error(traceback.format_exc(0))
sys.exit(-1)
except IOError as err:
if err.errno == 2:
assert err.strerror == "No such file or directory"
raise UIError("The requested config file (%s) could not be opened. %s."
% (file_name, err.strerror), err)
else:
raise UIError(str(err), err)
except yaml.YAMLError as err:
raise UIError("Parsing of the config file "
+ file_name + " failed.\nError " + str(err), err)


class Configurator(object):
Expand All @@ -157,13 +159,11 @@ def __init__(self, raw_config, data_store, cli_options=None, cli_reporter=None,
self._root_run_details = ExpRunDetails.compile(
raw_config.get('runs', {}), ExpRunDetails.default())
self._root_reporting = Reporting.compile(
raw_config.get('reporting', {}), Reporting.empty(), cli_options)
raw_config.get('reporting', {}), Reporting.empty(cli_reporter), cli_options)

self._options = cli_options
self._process_cli_options()

self._cli_reporter = cli_reporter

self._data_store = data_store
self._build_commands = dict()

Expand All @@ -184,26 +184,14 @@ def _process_cli_options(self):
if self._options is None:
return

if self._options.debug:
if self._options.verbose:
logging.basicConfig(level=logging.NOTSET)
logging.getLogger().setLevel(logging.NOTSET)
logging.debug("Enabled verbose debug output.")
else:
logging.basicConfig(level=logging.DEBUG)
logging.getLogger().setLevel(logging.DEBUG)
logging.debug("Enabled debug output.")
else:
logging.basicConfig(level=logging.ERROR)
logging.getLogger().setLevel(logging.ERROR)

if self._options.use_nice:
if not can_set_niceness():
logging.error("Process niceness cannot be set currently. "
"To execute benchmarks with highest priority, "
"you might need root/admin rights.")
logging.error("Deactivated usage of nice command.")
self._options.use_nice = False
set_verbose_debug_mode(self._options.verbose, self._options.debug)

if self._options.use_nice and not can_set_niceness():
error("Error: Process niceness could not be set. "
"To execute benchmarks with highest priority, "
"you might need root/admin rights.")
error("Deactivated usage of nice command.")
self._options.use_nice = False

@property
def use_nice(self):
Expand Down
Loading

0 comments on commit 656019f

Please sign in to comment.