Skip to content

Commit

Permalink
Added system-info as a management tool
Browse files Browse the repository at this point in the history
Signed-off-by: amd-pworfolk <patrick.worfolk@amd.com>
  • Loading branch information
amd-pworfolk committed Dec 10, 2024
1 parent 87d29ab commit c7eaa61
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 14 deletions.
13 changes: 0 additions & 13 deletions src/turnkeyml/common/system_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,16 +384,3 @@ def get_system_info_dict() -> dict:
dict: Dictionary containing the system information.
"""
return get_system_info().get_dict()


def main():
"""
Prints the system information dictionary.
"""
info_dict = get_system_info_dict()
for k, v in info_dict.items():
print(f"{k}: {v}")


if __name__ == "__main__":
main()
3 changes: 2 additions & 1 deletion src/turnkeyml/llm/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import turnkeyml.common.filesystem as fs
import turnkeyml.cli.cli as cli
from turnkeyml.sequence import Sequence
from turnkeyml.tools.management_tools import Cache, Version
from turnkeyml.tools.management_tools import Cache, Version, SystemInfo
from turnkeyml.tools.report import Report
from turnkeyml.state import State

Expand Down Expand Up @@ -35,6 +35,7 @@ def main():
Report,
Cache,
Version,
SystemInfo,
]

# Import onnxruntime-genai recipes
Expand Down
1 change: 1 addition & 0 deletions src/turnkeyml/sequence/tool_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def get_supported_tools():
mgmt.Version,
mgmt.Cache,
mgmt.ModelsLocation,
mgmt.SystemInfo,
report.Report,
Discover,
export.ExportPytorchModel,
Expand Down
35 changes: 35 additions & 0 deletions src/turnkeyml/tools/management_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import turnkeyml.common.printing as printing
from turnkeyml.tools.tool import ToolParser
from turnkeyml.version import __version__ as turnkey_version
from turnkeyml.common.system_info import get_system_info_dict


class ManagementTool(abc.ABC):
Expand Down Expand Up @@ -265,3 +266,37 @@ def run(self, _, quiet: bool = False):
print(fs.MODELS_DIR)
else:
printing.log_info(f"The models directory is: {fs.MODELS_DIR}")


class SystemInfo(ManagementTool):
"""
Prints system information for the turnkeyml installation.
"""

unique_name = "system-info"

@staticmethod
def parser(add_help: bool = True) -> argparse.ArgumentParser:
parser = __class__.helpful_parser(
short_description="Print system information",
add_help=add_help,
)

return parser

@staticmethod
def pretty_print(my_dict: dict, level=0):
for k, v in my_dict.items():
if isinstance(v, dict):
print(" " * level + f"{k}:")
SystemInfo.pretty_print(v, level + 1)
elif isinstance(v,list):
print(" " * level + f"{k}:")
for item in v:
print(" " * (level+1) + f"{item}")
else:
print(" " * level + f"{k}: {v}")

def run(self, _):
system_info_dict = get_system_info_dict()
self.pretty_print(system_info_dict)

0 comments on commit c7eaa61

Please sign in to comment.