[SWDEV-469278] Removed PyYAML Dependency

Signed-off-by: Justin Williams <Justin.Williams@amd.com>
Change-Id: Idec32cfb0de84cc255b506d7f972e2750992745e
This commit is contained in:
Justin Williams
2024-11-18 10:10:13 -06:00
committato da Maisam Arif
parent bc77330a74
commit 2370aa1b40
4 ha cambiato i file con 18 aggiunte e 35 eliminazioni
+3 -10
Vedi File
@@ -28,7 +28,7 @@ find_program(GIT NAMES git)
## Setup the package version based on git tags.
set(PKG_VERSION_GIT_TAG_PREFIX "amdsmi_pkg_ver")
get_package_version_number("24.7.1" ${PKG_VERSION_GIT_TAG_PREFIX} GIT)
get_package_version_number("24.7.0" ${PKG_VERSION_GIT_TAG_PREFIX} GIT)
message("Package version: ${PKG_VERSION_STR}")
set(${AMD_SMI_LIBS_TARGET}_VERSION_MAJOR "${CPACK_PACKAGE_VERSION_MAJOR}")
set(${AMD_SMI_LIBS_TARGET}_VERSION_MINOR "${CPACK_PACKAGE_VERSION_MINOR}")
@@ -107,13 +107,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat=2 -fno-common -Wstrict-overflow
# Intentionally leave out -Wsign-promo. It causes spurious warnings.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual -Wreorder")
# Add CMAKE debug flags
if ("${CMAKE_BUILD_TYPE}" STREQUAL Release)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb -O0 -DDEBUG")
endif ()
set(COMMON_SRC_DIR "${PROJECT_SOURCE_DIR}/src")
set(ROCM_SRC_DIR "${PROJECT_SOURCE_DIR}/rocm_smi/src")
set(AMDSMI_SRC_DIR "${PROJECT_SOURCE_DIR}/src/amd_smi")
@@ -261,7 +254,7 @@ install(
add_subdirectory(goamdsmi_shim)
#Debian package specific variables
set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "python3-argcomplete, libdrm-dev, python3-yaml")
set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "python3-argcomplete, libdrm-dev")
set(CPACK_DEBIAN_ASAN_PACKAGE_RECOMMENDS ${CPACK_DEBIAN_PACKAGE_RECOMMENDS})
set(CPACK_DEBIAN_DEV_PACKAGE_RECOMMENDS ${CPACK_DEBIAN_PACKAGE_RECOMMENDS})
set(CPACK_DEBIAN_PACKAGE_DEPENDS "sudo, python3 (>= 3.6.8), python3-pip")
@@ -285,7 +278,7 @@ set(CPACK_RPM_PACKAGE_SUGGESTS "python3-argcomplete")
set(CPACK_RPM_DEV_PACKAGE_SUGGESTS ${CPACK_RPM_PACKAGE_SUGGESTS})
set(CPACK_RPM_ASAN_PACKAGE_SUGGESTS ${CPACK_RPM_PACKAGE_SUGGESTS})
# python version gated by rhel8 :(
set(CPACK_RPM_PACKAGE_REQUIRES "sudo, python3 >= 3.6.8, python3-pip, python3-PyYAML")
set(CPACK_RPM_PACKAGE_REQUIRES "sudo, python3 >= 3.6.8, python3-pip")
set(CPACK_RPM_DEV_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_REQUIRES})
set(CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_REQUIRES})
+15 -19
Vedi File
@@ -25,20 +25,10 @@ import re
import time
from typing import Dict
from enum import Enum
import yaml
import inspect
from amdsmi_helpers import AMDSMIHelpers
import amdsmi_cli_exceptions
### Custom YAML Functions
# Dumper class to preserve order of yaml.dump
class CustomDumper(yaml.Dumper):
def represent_dict_preserve_order(self, data):
return self.represent_dict(data.items())
def has_sort_keys_option(): # to check if sort_keys is available
return 'sort_keys' in inspect.signature(yaml.dump).parameters
class AMDSMILogger():
def __init__(self, format='human_readable', destination='stdout') -> None:
self.output = {}
@@ -233,15 +223,8 @@ class AMDSMILogger():
capitalized_json["AMDSMI_SPACING_REMOVAL"] = tabbed_dictionary
json_string = json.dumps(capitalized_json, indent=4)
if has_sort_keys_option():
yaml_data = yaml.safe_load(json_string)
yaml_output = yaml.dump(yaml_data, sort_keys=False, allow_unicode=True)
else:
CustomDumper.add_representer(dict, CustomDumper.represent_dict_preserve_order)
yaml_data = yaml.safe_load(json_string)
yaml_output = yaml.dump(yaml_data, Dumper=CustomDumper, allow_unicode=True, default_flow_style=False)
# Convert the capitalized JSON to a YAML-like string
yaml_output = self.custom_dump(capitalized_json)
# Remove a key line if it is a spacer
yaml_output = yaml_output.replace("AMDSMI_SPACING_REMOVAL:\n", "")
@@ -264,6 +247,19 @@ class AMDSMILogger():
return clean_yaml_output
def custom_dump(self, data, indent=0):
"""Converts a Python dictionary to a YAML-like string."""
yaml_string = ""
for key, value in data.items():
if isinstance(value, dict):
yaml_string += " " * indent + f"{key}:\n" + self.custom_dump(value, indent + 1)
elif isinstance(value, list):
yaml_string += " " * indent + f"{key}:\n"
for item in value:
yaml_string += " " * (indent + 1) + f"- {item}\n"
else:
yaml_string += " " * indent + f"{key}: {value}\n"
return yaml_string
def flatten_dict(self, target_dict, topology_override=False):
"""This will flatten a dictionary out to a single level of key value stores
-3
Vedi File
@@ -15,9 +15,6 @@ license = {file = "amdsmi/LICENSE"}
readme = {file = "amdsmi/README.md", content-type = "text/markdown"}
description = "AMDSMI Python LIB - AMD GPU Monitoring Library"
requires-python = ">=3.6"
dependencies = [
"PyYAML >= 3.0",
]
classifiers = [
"Programming Language :: Python :: 3"
]
-3
Vedi File
@@ -9,9 +9,6 @@ setup(
description="AMDSMI Python LIB - AMD GPU Monitoring Library",
url="https://github.com/ROCm/amdsmi",
packages=find_packages(),
install_requires=[
"PyYAML>=3.0",
],
classifiers=[
"Programming Language :: Python :: 3",
],