From 47fc50576e7040680c19e152592b2c5e5cc297f5 Mon Sep 17 00:00:00 2001 From: Ruomei Yan Date: Wed, 2 Nov 2022 16:47:56 +0000 Subject: MLIA-649 Strip mlia backend management into a new command * add entry point for mlia-backend in setup.cfg and main.py * add --force option for install from path: uninstall existing backend in ML Inference Advisor and install from given path * add uninstall and list program parameters: uninstall has backend_name as input arg, install has backend_name as a mandatory argument * add unit tests in test_cli_commands.py, test_cli_main.py, test_tools_metadata_common.py, test_tools_metadata_corstone.py * updated README.md * remove --download option for installing backend * add new lines for the display section when we do mlia-backen list * add case insensitive support for backend names in command line argument Change-Id: Icb89d8957fa6be4b767710e24fa074f26472674b --- src/mlia/cli/commands.py | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'src/mlia/cli/commands.py') diff --git a/src/mlia/cli/commands.py b/src/mlia/cli/commands.py index 72ae4bb..4be7f3e 100644 --- a/src/mlia/cli/commands.py +++ b/src/mlia/cli/commands.py @@ -29,7 +29,6 @@ from mlia.api import PathOrFileLike from mlia.cli.config import get_installation_manager from mlia.cli.options import parse_optimization_parameters from mlia.utils.console import create_section_header -from mlia.utils.types import only_one_selected logger = logging.getLogger(__name__) @@ -243,34 +242,36 @@ def optimization( ) -def backend( - backend_action: str, +def backend_install( + name: str, path: Path | None = None, - download: bool = False, - name: str | None = None, i_agree_to_the_contained_eula: bool = False, noninteractive: bool = False, + force: bool = False, ) -> None: - """Backends configuration.""" + """Install configuration.""" logger.info(CONFIG) manager = get_installation_manager(noninteractive) - if backend_action == "status": - manager.show_env_details() + install_from_path = path is not None - if backend_action == "install": - install_from_path = path is not None + if install_from_path: + manager.install_from(cast(Path, path), name, force) + else: + eula_agreement = not i_agree_to_the_contained_eula + manager.download_and_install(name, eula_agreement) - if not only_one_selected(install_from_path, download): - raise Exception( - "Please select only one action: download or " - "provide path to the backend installation" - ) - if install_from_path: - manager.install_from(cast(Path, path), name) +def backend_uninstall( + name: str, +) -> None: + """Uninstall backend(s).""" + manager = get_installation_manager(noninteractive=True) + manager.uninstall(name) + - if download: - eula_agreement = not i_agree_to_the_contained_eula - manager.download_and_install(name, eula_agreement) +def backend_list() -> None: + """List backend status.""" + manager = get_installation_manager(noninteractive=True) + manager.show_env_details() -- cgit v1.2.1