From d6abcfa92d42049ee11a6b9a12763caa2aef0d7d Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Thu, 12 Oct 2023 09:57:24 -0500 Subject: [PATCH 1/2] Enabled amd-smi auto completion using argcomplete Signed-off-by: Maisam Arif Change-Id: I0ea48b1b3a10e738d1fe91db85bc61ad51b85de2 --- amdsmi_cli/amdsmi_cli.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/amdsmi_cli/amdsmi_cli.py b/amdsmi_cli/amdsmi_cli.py index 3a88ae5acc..3bafe179ca 100755 --- a/amdsmi_cli/amdsmi_cli.py +++ b/amdsmi_cli/amdsmi_cli.py @@ -1,4 +1,6 @@ #!/usr/bin/env python3 +# PYTHON_ARGCOMPLETE_OK + # # Copyright (C) 2023 Advanced Micro Devices. All rights reserved. # @@ -23,6 +25,11 @@ import logging import sys +try: + import argcomplete +except ImportError: + logging.debug("argcomplete module not found. Autocomplete will not work.") + from amdsmi_commands import AMDSMICommands from amdsmi_parser import AMDSMIParser from amdsmi_logger import AMDSMILogger @@ -63,6 +70,11 @@ if __name__ == "__main__": amd_smi_commands.reset, amd_smi_commands.rocm_smi) try: + try: + argcomplete.autocomplete(amd_smi_parser) + except NameError: + logging.debug("argcomplete module not found. Autocomplete will not work.") + args = amd_smi_parser.parse_args(args=None if sys.argv[1:] else ['--help']) # Handle command modifiers before subcommand execution From 2b603be71b726d80c4f7d54d27914cb4bb0ec348 Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Tue, 24 Oct 2023 11:46:47 -0500 Subject: [PATCH 2/2] README - Add argcomplete instructions Change-Id: I76a35e38735e71cd30ba62a177bed53300b63515 Signed-off-by: Galantsev, Dmitrii --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 4fa348f431..61d36acdd0 100755 --- a/README.md +++ b/README.md @@ -134,6 +134,17 @@ For additional details, see the [ROCm Contributing Guide](https://rocm.docs.amd. * python 3.7+ 64-bit * amdgpu driver must be loaded for amdsmi_init() to pass +### Optional autocompletion + +`amd-smi` cli application supports autocompletion. It is enabled by using the +following commands: + +```bash +python3 -m pip install argcomplete +activate-global-python-argcomplete +# restart shell to enable +``` + ### CLI Installation Before amd-smi install, ensure previous versions of amdsmi library are uninstalled using pip: