Skip to content

Commit

Permalink
Move UIError to output to avoid indirect dependency on UI in denoise
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Marr <[email protected]>
  • Loading branch information
smarr committed Sep 3, 2024
1 parent b0f3dc8 commit f99c019
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 30 deletions.
3 changes: 2 additions & 1 deletion rebench/configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions rebench/denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion rebench/model/data_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion rebench/model/run_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
19 changes: 19 additions & 0 deletions rebench/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion rebench/persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: "

Expand Down
3 changes: 2 additions & 1 deletion rebench/rebench.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion rebench/rebenchdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion rebench/tests/configurator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion rebench/tests/executor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
3 changes: 2 additions & 1 deletion rebench/tests/ui_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 0 additions & 19 deletions rebench/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit f99c019

Please sign in to comment.