aboutsummaryrefslogtreecommitdiff
path: root/src/mlia/backend/common.py
diff options
context:
space:
mode:
authorBenjamin Klimczak <benjamin.klimczak@arm.com>2022-07-11 12:33:42 +0100
committerBenjamin Klimczak <benjamin.klimczak@arm.com>2022-07-26 14:08:21 +0100
commit5d81f37de09efe10f90512e50252be9c36925fcf (patch)
treeb4d7cdfd051da0a6e882bdfcf280fd7ca7b39e57 /src/mlia/backend/common.py
parent7899b908c1fe6d86b92a80f3827ddd0ac05b674b (diff)
downloadmlia-5d81f37de09efe10f90512e50252be9c36925fcf.tar.gz
MLIA-551 Rework remains of AIET architecture
Re-factoring the code base to further merge the old AIET code into MLIA. - Remove last traces of the backend type 'tool' - Controlled systems removed, including SSH protocol, controller, RunningCommand, locks etc. - Build command / build dir and deploy functionality removed from Applications and Systems - Moving working_dir() - Replace module 'output_parser' with new module 'output_consumer' and merge Base64 parsing into it - Change the output consumption to optionally remove (i.e. actually consume) lines - Use Base64 parsing in GenericInferenceOutputParser, replacing the regex-based parsing and remove the now unused regex parsing - Remove AIET reporting - Pre-install applications by moving them to src/mlia/resources/backends - Rename aiet-config.json to backend-config.json - Move tests from tests/mlia/ to tests/ - Adapt unit tests to code changes - Dependencies removed: paramiko, filelock, psutil - Fix bug in corstone.py: The wrong resource directory was used which broke the functionality to download backends. - Use f-string formatting. - Use logging instead of print. Change-Id: I768bc3bb6b2eda57d219ad01be4a8e0a74167d76
Diffstat (limited to 'src/mlia/backend/common.py')
-rw-r--r--src/mlia/backend/common.py35
1 files changed, 13 insertions, 22 deletions
diff --git a/src/mlia/backend/common.py b/src/mlia/backend/common.py
index 2bbb9d3..e61d6b6 100644
--- a/src/mlia/backend/common.py
+++ b/src/mlia/backend/common.py
@@ -33,7 +33,7 @@ from mlia.backend.fs import remove_resource
from mlia.backend.fs import ResourceType
-BACKEND_CONFIG_FILE: Final[str] = "aiet-config.json"
+BACKEND_CONFIG_FILE: Final[str] = "backend-config.json"
class ConfigurationException(Exception):
@@ -126,10 +126,6 @@ class Backend(ABC):
self.description = config.get("description", "")
self.config_location = config.get("config_location")
self.variables = config.get("variables", {})
- self.build_dir = config.get("build_dir")
- self.lock = config.get("lock", False)
- if self.build_dir:
- self.build_dir = self._substitute_variables(self.build_dir)
self.annotations = config.get("annotations", {})
self._parse_commands_and_params(config)
@@ -145,7 +141,7 @@ class Backend(ABC):
command = self.commands.get(command_name)
if not command:
- raise AttributeError("Unknown command: '{}'".format(command_name))
+ raise AttributeError(f"Unknown command: '{command_name}'")
# Iterate over all available parameters until we have a match.
for param in command.params:
@@ -209,7 +205,7 @@ class Backend(ABC):
def var_value(match: Match) -> str:
var_name = match["var_name"]
if var_name not in self.variables:
- raise ConfigurationException("Unknown variable {}".format(var_name))
+ raise ConfigurationException(f"Unknown variable {var_name}")
return self.variables[var_name]
@@ -312,7 +308,7 @@ class Backend(ABC):
command = self.commands.get(command_name)
if not command:
raise ConfigurationException(
- "Command '{}' could not be found.".format(command_name)
+ f"Command '{command_name}' could not be found."
)
commands_to_run = []
@@ -394,7 +390,7 @@ class Command:
if repeated_aliases:
raise ConfigurationException(
- "Non unique aliases {}".format(", ".join(repeated_aliases))
+ f"Non-unique aliases {', '.join(repeated_aliases)}"
)
both_name_and_alias = [
@@ -404,9 +400,8 @@ class Command:
]
if both_name_and_alias:
raise ConfigurationException(
- "Aliases {} could not be used as parameter name".format(
- ", ".join(both_name_and_alias)
- )
+ f"Aliases {', '.join(both_name_and_alias)} could not be used "
+ "as parameter name."
)
def get_details(self) -> Dict:
@@ -449,12 +444,12 @@ def resolve_all_parameters(
return str_val
-def load_application_or_tool_configs(
+def load_application_configs(
config: Any,
config_type: Type[Any],
is_system_required: bool = True,
) -> Any:
- """Get one config for each system supported by the application/tool.
+ """Get one config for each system supported by the application.
The configuration could contain different parameters/commands for different
supported systems. For each supported system this function will return separate
@@ -501,15 +496,13 @@ def load_application_or_tool_configs(
if params_default and params_tool:
if any(not p.get("alias") for p in params_default):
raise ConfigurationException(
- "Default parameters for command {} should have aliases".format(
- command_name
- )
+ f"Default parameters for command {command_name} "
+ "should have aliases"
)
if any(not p.get("alias") for p in params_tool):
raise ConfigurationException(
- "{} parameters for command {} should have aliases".format(
- system_name, command_name
- )
+ f"{system_name} parameters for command {command_name} "
+ "should have aliases."
)
merged_by_alias = {
@@ -519,8 +512,6 @@ def load_application_or_tool_configs(
params[command_name] = list(merged_by_alias.values())
merged_config["user_params"] = params
- merged_config["build_dir"] = system.get("build_dir", config.get("build_dir"))
- merged_config["lock"] = system.get("lock", config.get("lock", False))
merged_config["variables"] = {
**config.get("variables", {}),
**system.get("variables", {}),