diff --git a/projects/amdsmi/CHANGELOG.md b/projects/amdsmi/CHANGELOG.md index 1135bd1838..18c9e0abf3 100644 --- a/projects/amdsmi/CHANGELOG.md +++ b/projects/amdsmi/CHANGELOG.md @@ -287,8 +287,6 @@ GPU: 1 ### Resolved issues -- **Improved Offline install process & lowered dependency for PyYAML**. - - **Fixed CPX not showing total number of logical GPUs**. - Updates were made to `amdsmi_init()` and `amdsmi_get_gpu_bdf_id(..)`. In order to display all logical devices, we needed a way to provide order to GPU's enumerated. This was done by adding a partition_id within the BDF optional pci_id bits. diff --git a/projects/amdsmi/DEBIAN/postinst.in b/projects/amdsmi/DEBIAN/postinst.in index 8ecd91db0c..97ea7a7518 100755 --- a/projects/amdsmi/DEBIAN/postinst.in +++ b/projects/amdsmi/DEBIAN/postinst.in @@ -159,24 +159,6 @@ do_install_amdsmi_python_lib() { fi unset pip_version - # Install setuptools wheel (offline install) - echo "Checking for amdsmi_offline.tar.gz..." - offline_packages_tar_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/amdsmi_offline.tar.gz - - if [ -z "$offline_packages_tar_path" ]; then - echo "Error: amdsmi_offline.tar.gz not found. Not installing amdsmi offline packages..." - else - echo "Extracting amdsmi_offline.tar.gz..." - offline_packages_target_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/ - tar -xzvf $offline_packages_tar_path -C $offline_packages_target_path - offline_packages_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/offline_packages - echo "Installing/Upgrading amdsmi offline packages..." - python3 -m pip install --upgrade --upgrade-strategy only-if-needed --no-index --find-links="$offline_packages_path" setuptools - unset offline_packages_path - unset offline_packages_target_path - fi - unset offline_packages_tar_path - # Check PyYAML dependency, typically should not execute pyyaml_version=$(pip show pyyaml | grep -Po '(?<=Version: )[0-9]') if [[ "$pyyaml_version" -lt 3 ]]; then @@ -185,6 +167,33 @@ do_install_amdsmi_python_lib() { fi unset pyyaml_version +# Install setuptools wheel (offline install) +# Function to find the tarball + find_tarball() { + find / -name "amdsmi_offline.tar.gz" 2>/dev/null | head -n 1 + } + + # Locate the tarball + tarball_path=$(find_tarball) + + if [ -z "$tarball_path" ]; then + echo "Error: amdsmi_offline.tar.gz not found." + exit 1 + fi + + # Extract directory from tarball path + base_dir=$(dirname "$tarball_path") + + # Navigate to the directory containing the tarball + cd "$base_dir" || exit + + # Unpack the tarball + tar -xzvf amdsmi_offline.tar.gz + + # Install setuptools offline (if needed) + cd offline_packages || exit + python3 -m pip install --upgrade --upgrade-strategy only-if-needed --no-index --find-links=. setuptools + # install python library at @CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi local python_lib_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@ python3 -m pip install "$python_lib_path" --quiet --disable-pip-version-check --no-build-isolation diff --git a/projects/amdsmi/DEBIAN/prerm.in b/projects/amdsmi/DEBIAN/prerm.in index 88573f33d3..3decc72093 100755 --- a/projects/amdsmi/DEBIAN/prerm.in +++ b/projects/amdsmi/DEBIAN/prerm.in @@ -13,13 +13,9 @@ rm_ldconfig() { rm_leftovers() { # remove pyc files generated by python + rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/__pycache__" rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi/__pycache__" - # remove CLI folder packages folder - if test -e "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli*"; then - rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli*" - fi - # remove build and egg files rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi.egg-info" rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/build" diff --git a/projects/amdsmi/RPM/post.in b/projects/amdsmi/RPM/post.in index 94d3921481..d98316b4b8 100755 --- a/projects/amdsmi/RPM/post.in +++ b/projects/amdsmi/RPM/post.in @@ -158,25 +158,7 @@ do_install_amdsmi_python_lib() { fi unset pip_version - # Install setuptools wheel (offline install) - echo "Checking for amdsmi_offline.tar.gz..." - offline_packages_tar_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/amdsmi_offline.tar.gz - - if [ -z "$offline_packages_tar_path" ]; then - echo "Error: amdsmi_offline.tar.gz not found. Not installing amdsmi offline packages..." - else - echo "Extracting amdsmi_offline.tar.gz..." - offline_packages_target_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/ - tar -xzvf $offline_packages_tar_path -C $offline_packages_target_path - offline_packages_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/offline_packages - echo "Installing/Upgrading amdsmi offline packages..." - python3 -m pip install --upgrade --upgrade-strategy only-if-needed --no-index --find-links="$offline_packages_path" setuptools - unset offline_packages_path - unset offline_packages_target_path - fi - unset offline_packages_tar_path - - # Check PyYAML dependency, typically should not execute + # Check PyYAML dependency local pyyaml_version pyyaml_version=$(pip show pyyaml | grep -Po '(?<=Version: )[0-9]') if [[ "$pyyaml_version" -lt 3 ]]; then @@ -185,6 +167,33 @@ do_install_amdsmi_python_lib() { fi unset pyyaml_version +# Install setuptools wheel (offline install) +# Function to find the tarball + find_tarball() { + find / -name "amdsmi_offline.tar.gz" 2>/dev/null | head -n 1 + } + + # Locate the tarball + tarball_path=$(find_tarball) + + if [ -z "$tarball_path" ]; then + echo "Error: amdsmi_offline.tar.gz not found." + exit 1 + fi + + # Extract directory from tarball path + base_dir=$(dirname "$tarball_path") + + # Navigate to the directory containing the tarball + cd "$base_dir" || exit + + # Unpack the tarball + tar -xzvf amdsmi_offline.tar.gz + + # Install setuptools offline (if needed) + cd offline_packages || exit + python3 -m pip install --upgrade --upgrade-strategy only-if-needed --no-index --find-links=. setuptools + # install python library at @CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi local python_lib_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@ python3 -m pip install "$python_lib_path" --quiet --disable-pip-version-check --no-build-isolation diff --git a/projects/amdsmi/RPM/preun.in b/projects/amdsmi/RPM/preun.in index fbfde6b5af..43e58c93f3 100755 --- a/projects/amdsmi/RPM/preun.in +++ b/projects/amdsmi/RPM/preun.in @@ -2,13 +2,9 @@ rm_leftovers() { # remove pyc files generated by python + rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/__pycache__" rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi/__pycache__" - # remove CLI folder packages folder - if test -e "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli*"; then - rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli*" - fi - # remove build and egg files rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi.egg-info" rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/build" diff --git a/projects/amdsmi/amdsmi_cli/CMakeLists.txt b/projects/amdsmi/amdsmi_cli/CMakeLists.txt index 6fdd442321..d0cba22c50 100644 --- a/projects/amdsmi/amdsmi_cli/CMakeLists.txt +++ b/projects/amdsmi/amdsmi_cli/CMakeLists.txt @@ -24,7 +24,6 @@ add_custom_command( ${PY_PACKAGE_DIR}/amdsmi_cli_exceptions.py ${PY_PACKAGE_DIR}/rocm_version.py ${PY_PACKAGE_DIR}/BDF.py - ${PY_PACKAGE_DIR}/amdsmi_offline.tar.gz ${PY_PACKAGE_DIR}/README.md ${PY_PACKAGE_DIR}/Release_Notes.md DEPENDS amdsmi_cli @@ -39,7 +38,6 @@ add_custom_command( COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_cli_exceptions.py ${PY_PACKAGE_DIR}/ COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/rocm_version.py ${PY_PACKAGE_DIR}/ COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/BDF.py ${PY_PACKAGE_DIR}/ - COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_offline.tar.gz ${PY_PACKAGE_DIR}/ COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${PY_PACKAGE_DIR}/ COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/Release_Notes.md ${PY_PACKAGE_DIR}/) @@ -58,7 +56,6 @@ add_custom_target( ${PY_PACKAGE_DIR}/amdsmi_cli_exceptions.py ${PY_PACKAGE_DIR}/rocm_version.py ${PY_PACKAGE_DIR}/BDF.py - ${PY_PACKAGE_DIR}/amdsmi_offline.tar.gz ${PY_PACKAGE_DIR}/README.md ${PY_PACKAGE_DIR}/Release_Notes.md) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_logger.py b/projects/amdsmi/amdsmi_cli/amdsmi_logger.py index 8234f99eac..6fb6e5a327 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_logger.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_logger.py @@ -37,7 +37,7 @@ import amdsmi_cli_exceptions 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 +def has_sort_keys_option(): # to check if sort_keys is available return 'sort_keys' in inspect.signature(yaml.dump).parameters class AMDSMILogger(): @@ -212,14 +212,14 @@ class AMDSMILogger(): json_string = json.dumps(capitalized_json, indent=4) - if has_sort_keys_option(): + 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: + 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) - + # Remove a key line if it is a spacer yaml_output = yaml_output.replace("AMDSMI_SPACING_REMOVAL:\n", "") yaml_output = yaml_output.replace("'", "") # Remove '' diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_offline.tar.gz b/projects/amdsmi/amdsmi_cli/amdsmi_offline.tar.gz deleted file mode 100644 index 9484090fd4..0000000000 Binary files a/projects/amdsmi/amdsmi_cli/amdsmi_offline.tar.gz and /dev/null differ