aboutsummaryrefslogtreecommitdiff
path: root/src/mlia/core
diff options
context:
space:
mode:
authorBenjamin Klimczak <benjamin.klimczak@arm.com>2023-08-24 16:38:47 +0100
committerBenjamin Klimczak <benjamin.klimczak@arm.com>2023-09-05 14:20:08 +0100
commite5a0bc3ecd4d9c46ead3b8217584eaa916a3afa4 (patch)
tree94c348fcef50326a755a049a2a4027f588211f8b /src/mlia/core
parent900c3c52b681e0b8a4454e2e2cf29265d53a2c98 (diff)
downloadmlia-e5a0bc3ecd4d9c46ead3b8217584eaa916a3afa4.tar.gz
MLIA-961 Update tox dependencies
- Update version dependencies in the tox.ini - Fix linter issues Change-Id: I04c3a841ee2646a865dab037701d66c28792f2a4 Signed-off-by: Benjamin Klimczak <benjamin.klimczak@arm.com>
Diffstat (limited to 'src/mlia/core')
-rw-r--r--src/mlia/core/advisor.py4
-rw-r--r--src/mlia/core/common.py2
-rw-r--r--src/mlia/core/events.py6
-rw-r--r--src/mlia/core/mixins.py12
-rw-r--r--src/mlia/core/reporting.py2
5 files changed, 13 insertions, 13 deletions
diff --git a/src/mlia/core/advisor.py b/src/mlia/core/advisor.py
index d684241..7db5cfb 100644
--- a/src/mlia/core/advisor.py
+++ b/src/mlia/core/advisor.py
@@ -1,4 +1,4 @@
-# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
+# SPDX-FileCopyrightText: Copyright 2022-2023, Arm Limited and/or its affiliates.
# SPDX-License-Identifier: Apache-2.0
"""Inference advisor module."""
from __future__ import annotations
@@ -77,7 +77,7 @@ class DefaultInferenceAdvisor(InferenceAdvisor, ParameterResolverMixin):
model = Path(model_param)
if not model.exists():
- raise Exception(f"Path {model} does not exist")
+ raise FileNotFoundError(f"Path {model} does not exist.")
return model
diff --git a/src/mlia/core/common.py b/src/mlia/core/common.py
index baaed50..e437a75 100644
--- a/src/mlia/core/common.py
+++ b/src/mlia/core/common.py
@@ -36,7 +36,7 @@ class AdviceCategory(Flag):
category_names = [item.name for item in AdviceCategory]
for advice_value in values:
if advice_value.upper() not in category_names:
- raise Exception(f"Invalid advice category {advice_value}")
+ raise ValueError(f"Invalid advice category {advice_value}.")
return {AdviceCategory[value.upper()] for value in values}
diff --git a/src/mlia/core/events.py b/src/mlia/core/events.py
index e328cc1..ae22771 100644
--- a/src/mlia/core/events.py
+++ b/src/mlia/core/events.py
@@ -1,4 +1,4 @@
-# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
+# SPDX-FileCopyrightText: Copyright 2022-2023, Arm Limited and/or its affiliates.
# SPDX-License-Identifier: Apache-2.0
"""Module for the events and related functionality.
@@ -267,14 +267,14 @@ class EventDispatcherMetaclass(type):
"""
def __new__(
- cls,
+ mcs,
clsname: str,
bases: tuple[type, ...],
namespace: dict[str, Any],
event_handler_method_prefix: str = "on_",
) -> Any:
"""Create event dispatcher and link event handlers."""
- new_class = super().__new__(cls, clsname, bases, namespace)
+ new_class = super().__new__(mcs, clsname, bases, namespace)
@singledispatchmethod
def dispatcher(_self: Any, _event: Event) -> Any:
diff --git a/src/mlia/core/mixins.py b/src/mlia/core/mixins.py
index 5ef9d66..e50e6f7 100644
--- a/src/mlia/core/mixins.py
+++ b/src/mlia/core/mixins.py
@@ -1,4 +1,4 @@
-# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
+# SPDX-FileCopyrightText: Copyright 2022-2023, Arm Limited and/or its affiliates.
# SPDX-License-Identifier: Apache-2.0
"""Mixins module."""
from __future__ import annotations
@@ -35,21 +35,21 @@ class ParameterResolverMixin:
ctx = context or self.context
if ctx.config_parameters is None:
- raise Exception("Configuration parameters are not set")
+ raise ValueError("Configuration parameters are not set.")
section_params = ctx.config_parameters.get(section)
if section_params is None or not isinstance(section_params, dict):
- raise Exception(
+ raise ValueError(
f"Parameter section {section} has wrong format, "
- "expected to be a dictionary"
+ "expected to be a dictionary."
)
value = section_params.get(name)
if not value and expected:
- raise Exception(f"Parameter {name} is not set")
+ raise ValueError(f"Parameter {name} is not set.")
if value and expected_type is not None and not isinstance(value, expected_type):
- raise Exception(f"Parameter {name} expected to have type {expected_type}")
+ raise TypeError(f"Parameter {name} expected to have type {expected_type}.")
return value
diff --git a/src/mlia/core/reporting.py b/src/mlia/core/reporting.py
index 7b9ce5c..722adfd 100644
--- a/src/mlia/core/reporting.py
+++ b/src/mlia/core/reporting.py
@@ -427,7 +427,7 @@ class SingleRow(Table):
def to_plain_text(self, **kwargs: Any) -> str:
"""Produce report in human readable format."""
if len(self.rows) != 1:
- raise Exception("Table should have only one row")
+ raise RuntimeError(f"Table should have only one row, but has {self.rows}.")
items = "\n".join(
column.header.ljust(35) + str(item).rjust(25)