From f99c01967f026d4658a7c2c914ee1e74271b0870 Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Tue, 3 Sep 2024 22:18:46 +0100 Subject: [PATCH] Move UIError to output to avoid indirect dependency on UI in denoise Signed-off-by: Stefan Marr --- rebench/configurator.py | 3 ++- rebench/denoise.py | 3 +-- rebench/model/data_point.py | 2 +- rebench/model/run_id.py | 2 +- rebench/output.py | 19 +++++++++++++++++++ rebench/persistence.py | 2 +- rebench/rebench.py | 3 ++- rebench/rebenchdb.py | 2 +- rebench/tests/configurator_test.py | 2 +- rebench/tests/executor_test.py | 2 +- rebench/tests/ui_test.py | 3 ++- rebench/ui.py | 19 ------------------- 12 files changed, 32 insertions(+), 30 deletions(-) diff --git a/rebench/configurator.py b/rebench/configurator.py index 839f6374..96c1caae 100644 --- a/rebench/configurator.py +++ b/rebench/configurator.py @@ -28,8 +28,9 @@ from .model.exp_run_details import ExpRunDetails from .model.reporting import Reporting from .model.executor import Executor +from .output import UIError from .rebenchdb import ReBenchDB -from .ui import UIError, escape_braces +from .ui import escape_braces # Disable most logging for pykwalify logging.getLogger('pykwalify').setLevel(logging.CRITICAL) diff --git a/rebench/denoise.py b/rebench/denoise.py index 00b31f87..cef7b6d1 100644 --- a/rebench/denoise.py +++ b/rebench/denoise.py @@ -7,8 +7,7 @@ from math import log, floor from multiprocessing import Pool -from .ui import UIError -from .output import output_as_str +from .output import output_as_str, UIError from .subprocess_kill import kill_process try: diff --git a/rebench/model/data_point.py b/rebench/model/data_point.py index eb50acba..0a341ce4 100644 --- a/rebench/model/data_point.py +++ b/rebench/model/data_point.py @@ -17,7 +17,7 @@ # 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. -from ..ui import UIError +from ..output import UIError class DataPoint(object): diff --git a/rebench/model/run_id.py b/rebench/model/run_id.py index 5015aaa7..79de6580 100644 --- a/rebench/model/run_id.py +++ b/rebench/model/run_id.py @@ -23,8 +23,8 @@ from .benchmark import Benchmark from .termination_check import TerminationCheck +from ..output import UIError from ..statistics import StatisticProperties, SampleCounter -from ..ui import UIError class RunId(object): diff --git a/rebench/output.py b/rebench/output.py index cca28fb9..55659118 100644 --- a/rebench/output.py +++ b/rebench/output.py @@ -3,3 +3,22 @@ def output_as_str(string_like): return string_like.decode('utf-8') else: return string_like + + +class UIError(Exception): + + def __init__(self, message, exception): + super(UIError, self).__init__() + self._message = message + self._exception = exception + + @property + def message(self): + return self._message + + @property + def source_exception(self): + return self._exception + + def __str__(self): + return self._message diff --git a/rebench/persistence.py b/rebench/persistence.py index e66d1b8c..0a1c8eb9 100644 --- a/rebench/persistence.py +++ b/rebench/persistence.py @@ -31,8 +31,8 @@ from .model.measurement import Measurement from .model.profile_data import ProfileData from .model.run_id import RunId +from .output import UIError from .rebenchdb import get_current_time -from .ui import UIError _START_TIME_LINE = "# Execution Start: " diff --git a/rebench/rebench.py b/rebench/rebench.py index a7096c2a..3573ea1a 100755 --- a/rebench/rebench.py +++ b/rebench/rebench.py @@ -41,7 +41,8 @@ from .reporter import CliReporter from .configurator import Configurator, load_config from .configuration_error import ConfigurationError -from .ui import UIError, UI +from .output import UIError +from .ui import UI class ReBench(object): diff --git a/rebench/rebenchdb.py b/rebench/rebenchdb.py index eb3e57f2..373b68ec 100644 --- a/rebench/rebenchdb.py +++ b/rebench/rebenchdb.py @@ -5,7 +5,7 @@ from http.client import HTTPException from urllib.request import urlopen, Request as HttpRequest -from .ui import UIError +from .output import UIError def get_current_time(): diff --git a/rebench/tests/configurator_test.py b/rebench/tests/configurator_test.py index d4b7415d..9004e8bc 100644 --- a/rebench/tests/configurator_test.py +++ b/rebench/tests/configurator_test.py @@ -21,7 +21,7 @@ from ..configurator import Configurator, load_config, validate_gauge_adapters from ..persistence import DataStore -from ..ui import UIError +from ..output import UIError from .rebench_test_case import ReBenchTestCase diff --git a/rebench/tests/executor_test.py b/rebench/tests/executor_test.py index a7e62583..ebeb2e24 100644 --- a/rebench/tests/executor_test.py +++ b/rebench/tests/executor_test.py @@ -26,8 +26,8 @@ from ..executor import Executor, BatchScheduler, RandomScheduler, RoundRobinScheduler from ..configurator import Configurator, load_config from ..model.measurement import Measurement +from ..output import UIError from ..persistence import DataStore -from ..ui import UIError from ..reporter import Reporter diff --git a/rebench/tests/ui_test.py b/rebench/tests/ui_test.py index 6fd6a7d8..581eba24 100644 --- a/rebench/tests/ui_test.py +++ b/rebench/tests/ui_test.py @@ -2,7 +2,8 @@ from yaml import YAMLError from ..configurator import load_config -from ..ui import UI, UIError, escape_braces +from ..output import UIError +from ..ui import UI, escape_braces from .rebench_test_case import ReBenchTestCase diff --git a/rebench/ui.py b/rebench/ui.py index b0bd0973..f7d2334c 100644 --- a/rebench/ui.py +++ b/rebench/ui.py @@ -169,25 +169,6 @@ def debug_error_info(self, text, run_id=None, cmd=None, cwd=None, **kw): self._output(text, 'red', faint=True, **kw) -class UIError(Exception): - - def __init__(self, message, exception): - super(UIError, self).__init__() - self._message = message - self._exception = exception - - @property - def message(self): - return self._message - - @property - def source_exception(self): - return self._exception - - def __str__(self): - return self._message - - class TestDummyUI(object): def init(self, _verbose, _debug):