aboutsummaryrefslogtreecommitdiff
path: root/src/mlia/target/config.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mlia/target/config.py')
-rw-r--r--src/mlia/target/config.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/mlia/target/config.py b/src/mlia/target/config.py
index 7ab6b43..f257784 100644
--- a/src/mlia/target/config.py
+++ b/src/mlia/target/config.py
@@ -1,6 +1,12 @@
# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
# SPDX-License-Identifier: Apache-2.0
"""IP configuration module."""
+from __future__ import annotations
+
+from dataclasses import dataclass
+
+from mlia.backend.registry import registry as backend_registry
+from mlia.core.common import AdviceCategory
class IPConfiguration: # pylint: disable=too-few-public-methods
@@ -9,3 +15,33 @@ class IPConfiguration: # pylint: disable=too-few-public-methods
def __init__(self, target: str) -> None:
"""Init IP configuration instance."""
self.target = target
+
+
+@dataclass
+class TargetInfo:
+ """Collect information about supported targets."""
+
+ supported_backends: list[str]
+
+ def __str__(self) -> str:
+ """List supported backends."""
+ return ", ".join(sorted(self.supported_backends))
+
+ def is_supported(
+ self, advice: AdviceCategory | None = None, check_system: bool = False
+ ) -> bool:
+ """Check if any of the supported backends support this kind of advice."""
+ return any(
+ backend_registry.items[name].is_supported(advice, check_system)
+ for name in self.supported_backends
+ )
+
+ def filter_supported_backends(
+ self, advice: AdviceCategory | None = None, check_system: bool = False
+ ) -> list[str]:
+ """Get the list of supported backends filtered by the given arguments."""
+ return [
+ name
+ for name in self.supported_backends
+ if backend_registry.items[name].is_supported(advice, check_system)
+ ]