已合并
[msprof_master]msprof编包支持根据tag名刷新run+whl包名 #182
[msprof_master]msprof编包支持根据tag名刷新run+whl包名 #182
已合并
yuliangbin创建于 4月13日
8 个文件变更+68-26
Mbuild/build.sh+6-1
@@ -6,6 +6,7 @@ set -e
6CUR_DIR=$(dirname $(readlink -f $0))6CUR_DIR=$(dirname $(readlink -f $0))
7TOP_DIR=${CUR_DIR}/..7TOP_DIR=${CUR_DIR}/..
8VERSION="none"8VERSION="none"
9+WHL_VERSION="0.0.1"
9BUILD_TYPE="Release"10BUILD_TYPE="Release"
10BUILD_MODE="analysis"11BUILD_MODE="analysis"
11 12 
@@ -33,6 +34,10 @@ while [[ $# -gt 0 ]]; do
33 VERSION="${1#*=}"34 VERSION="${1#*=}"
34 shift35 shift
35 ;;36 ;;
37+ --whl_version=*)
38+ WHL_VERSION="${1#*=}"
39+ shift
40+ ;;
36 *)41 *)
37 echo "[ERROR] Unknown parameter: $1"42 echo "[ERROR] Unknown parameter: $1"
38 exit 143 exit 1
@@ -120,4 +125,4 @@ case "$BUILD_MODE" in
120esac125esac
121 126 
122# 2. package127# 2. package
123-bash ${TOP_DIR}/scripts/create_run_package.sh ${VERSION} ${BUILD_MODE}128+bash ${TOP_DIR}/scripts/create_run_package.sh ${VERSION} ${WHL_VERSION} ${BUILD_MODE}
Mbuild/setup.py+18-2
@@ -19,11 +19,27 @@ import os
19from setuptools import setup19from setuptools import setup
20from setuptools import find_packages20from setuptools import find_packages
21 21 
22-__version__ = '0.0.1'22+try:
23+ from packaging.version import Version, InvalidVersion
24+ __version__ = os.environ.get("WHL_VERSION", "0.0.1")
25+ try:
26+ # Verify whether the version number complies with PEP 440
27+ Version(__version__)
28+ print(f"Using version: {__version__}")
29+ except InvalidVersion as e:
30+ print(f"Warning: Version '{__version__}' is invalid: {e}. Using default '0.0.1'")
31+ __version__ = "0.0.1"
32+except ImportError:
33+ # If there is no packaging library, use the simplified verification method
34+ print("Warning: packaging module not available, using version as-is")
35+ __version__ = os.environ.get("WHL_VERSION", "0.0.1")
36+except Exception as e:
37+ print(f"Error: Failed to process version, using default '0.0.1'. Error: {e}")
38+ __version__ = "0.0.1"
39+ 
23cur_path = os.path.abspath(os.path.dirname(__file__))40cur_path = os.path.abspath(os.path.dirname(__file__))
24root_path = os.path.join(cur_path, "../")41root_path = os.path.join(cur_path, "../")
25 42 
26- 
27setup(43setup(
28 name="msprof",44 name="msprof",
29 version=__version__,45 version=__version__,
Mscripts/create_run_package.sh+35-12
@@ -30,27 +30,39 @@ UTILS_SCRIPT=utils.sh
30 30 
31MSPROF_RUN_NAME="mindstudio-profiler"31MSPROF_RUN_NAME="mindstudio-profiler"
32VERSION="none"32VERSION="none"
33+WHL_VERSION="0.0.1"
33BUILD_MODE="analysis"34BUILD_MODE="analysis"
34 35 
35PKG_LIMIT_SIZE=524288000 # 500M36PKG_LIMIT_SIZE=524288000 # 500M
36 37 
38+arch_name="$(uname -m)-linux"
39+ 
37function parse_script_args() {40function parse_script_args() {
38- if [ $# -gt 2 ]; then41+ if [ $# -gt 3 ]; then
39- echo "[ERROR] Too many arguments. Only one or two arguments are allowed."42+ echo "[ERROR] Too many arguments. Maximum 3 arguments allowed: VERSION, WHL_VERSION, BUILD_MODE"
40 exit 143 exit 1
44+ elif [ $# -eq 3 ]; then
45+ VERSION="$1"
46+ WHL_VERSION="$2"
47+ BUILD_MODE="$3"
41 elif [ $# -eq 2 ]; then48 elif [ $# -eq 2 ]; then
42 VERSION="$1"49 VERSION="$1"
43- BUILD_MODE="$2"50+ WHL_VERSION="$2"
44 elif [ $# -eq 1 ]; then51 elif [ $# -eq 1 ]; then
45 VERSION="$1"52 VERSION="$1"
53+ else
54+ echo "[ERROR] At least one argument (VERSION) is required"
55+ exit 1
46 fi56 fi
47}57}
48 58 
49# build python whl59# build python whl
50function build_python_whl() {60function build_python_whl() {
51 cd ${TOP_DIR}/build/analysis/build61 cd ${TOP_DIR}/build/analysis/build
62+ export WHL_VERSION=${WHL_VERSION}
52 python3 ${TOP_DIR}/build/setup.py bdist_wheel --python-tag=py3 --py-limited-api=cp3763 python3 ${TOP_DIR}/build/setup.py bdist_wheel --python-tag=py3 --py-limited-api=cp37
53 cd - > /dev/null64 cd - > /dev/null
65+ unset WHL_VERSION
54}66}
55 67 
56function create_collector_temp_dir() {68function create_collector_temp_dir() {
@@ -59,11 +71,11 @@ function create_collector_temp_dir() {
59 local oam_tools_dir=${3}71 local oam_tools_dir=${3}
60 72 
61 # 1. runtime73 # 1. runtime
62- cp ${runtime_dir}/runtime/lib/libmsprofiler.so ${temp_dir}74+ cp ${runtime_dir}/${arch_name}/lib64/libmsprofiler.so ${temp_dir}
63- cp ${runtime_dir}/runtime/lib/libprofapi.so ${temp_dir}75+ cp ${runtime_dir}/${arch_name}/lib64/libprofapi.so ${temp_dir}
64- cp ${runtime_dir}/runtime/lib/libprofimpl.so ${temp_dir}76+ cp ${runtime_dir}/${arch_name}/lib64/libprofimpl.so ${temp_dir}
65- cp ${runtime_dir}/runtime/include/external/acl/acl_prof.h ${temp_dir}77+ cp ${runtime_dir}/${arch_name}/include/acl/acl_prof.h ${temp_dir}
66- cp ${runtime_dir}/runtime/include/external/ge/ge_prof.h ${temp_dir}78+ cp ${runtime_dir}/${arch_name}/include/ge/ge_prof.h ${temp_dir}
67 # 2. oam_tools79 # 2. oam_tools
68 cp ${oam_tools_dir}/oam_tools/profiler/bin/msprof ${temp_dir}80 cp ${oam_tools_dir}/oam_tools/profiler/bin/msprof ${temp_dir}
69}81}
@@ -71,7 +83,7 @@ function create_collector_temp_dir() {
71function create_analysis_temp_dir() {83function create_analysis_temp_dir() {
72 local temp_dir=${1}84 local temp_dir=${1}
73 85 
74- cp ${TOP_DIR}/build/analysis/dist/msprof-0.0.1-py3-none-any.whl ${temp_dir}86+ cp ${TOP_DIR}/build/analysis/dist/msprof-*-py3-none-any.whl ${temp_dir}
75 cp -r ${TOP_DIR}/analysis ${temp_dir}87 cp -r ${TOP_DIR}/analysis ${temp_dir}
76 rm -rf ${temp_dir}/analysis/csrc88 rm -rf ${temp_dir}/analysis/csrc
77}89}
@@ -118,12 +130,22 @@ function copy_script() {
118 chmod 500 "${temp_dir}/${script_name}"130 chmod 500 "${temp_dir}/${script_name}"
119}131}
120 132 
133+function update_version_info() {
134+ local version_file="${TOP_DIR}/version.info"
135+ [ "$VERSION" = "none" ] && return 0
136+ [ -f "$version_file" ] || { echo "ERROR: $version_file not found"; return 1; }
137+ 
138+ # Compatible with both cases with and without spaces
139+ sed -i "s/^[[:space:]]*Version=.*/Version=$VERSION/" "$version_file"
140+ echo "INFO: Updated Version to $VERSION in $version_file"
141+}
142+ 
121function get_version() {143function get_version() {
122 if [[ "$VERSION" != "none" ]]; then144 if [[ "$VERSION" != "none" ]]; then
123 echo "${VERSION}"145 echo "${VERSION}"
124 elif [ -f "${TOP_DIR}/version.info" ]; then146 elif [ -f "${TOP_DIR}/version.info" ]; then
125- local version=$(grep "Version=" "${TOP_DIR}/version.info" | sed 's/^[[:space:]]*//' | cut -d"=" -f2 | tr -d '[:space:]')147+ # Compatible with both cases with and without spaces
126- echo "${version}"148+ grep "Version=" "${TOP_DIR}/version.info" | sed 's/^[[:space:]]*Version=//'
127 else149 else
128 echo "${VERSION}"150 echo "${VERSION}"
129 fi151 fi
@@ -132,7 +154,7 @@ function get_version() {
132function get_package_name() {154function get_package_name() {
133 local name=${MSPROF_RUN_NAME}155 local name=${MSPROF_RUN_NAME}
134 156 
135- local version=$(echo $(get_version) | cut -d '.' -f 1,2,3)157+ local version=$(get_version)
136 local os_arch=$(arch)158 local os_arch=$(arch)
137 echo "${name}_${version}_${os_arch}.run"159 echo "${name}_${version}_${os_arch}.run"
138}160}
@@ -258,4 +280,5 @@ function main() {
258}280}
259 281 
260parse_script_args $*282parse_script_args $*
283+update_version_info
261main ${MAIN_SCRIPT} ${FILTER_PARAM_SCRIPT}284main ${MAIN_SCRIPT} ${FILTER_PARAM_SCRIPT}
Rscripts/execute_test_case.shscripts/execute_cpp_test_case.sh+0-0
文件重命名但无更改。
Mscripts/run_script/install.sh+5-4
@@ -71,10 +71,11 @@ function implement_install() {
71 # 5. install analyse71 # 5. install analyse
72 chmod -R 755 ${install_path}/${ANALYSIS_PATH}72 chmod -R 755 ${install_path}/${ANALYSIS_PATH}
73 copy_file ${ANALYSIS} ${install_path}/${ANALYSIS_PATH}/${ANALYSIS}73 copy_file ${ANALYSIS} ${install_path}/${ANALYSIS_PATH}/${ANALYSIS}
74- msprof_analyse_whl=${install_path}/${ANALYSIS_PATH}/${MSPROF_ANALYSIS_WHL}74+ source_whl=$(ls msprof-*-py3-none-any.whl 2>/dev/null | head -1)
75- copy_file ${MSPROF_ANALYSIS_WHL} $msprof_analyse_whl75+ if [ -f "$source_whl" ]; then
76- if [ -f "${MSPROF_ANALYSIS_WHL}" ]; then76+ rm -f "${install_path}/${ANALYSIS_PATH}"/msprof-*-py3-none-any.whl
77- install_whl_package $pylocal ${msprof_analyse_whl} ${install_path}/${ANALYSIS_PATH}77+ cp "$source_whl" "${install_path}/${ANALYSIS_PATH}"
78+ install_whl_package $pylocal ${source_whl} ${install_path}/${ANALYSIS_PATH}
78 chmod -R 755 ${install_path}/${ANALYSIS_PATH}79 chmod -R 755 ${install_path}/${ANALYSIS_PATH}
79 fi80 fi
80 if [ $? -ne 0 ]; then81 if [ $? -ne 0 ]; then
Mscripts/run_script/utils.sh+1-3
@@ -35,9 +35,6 @@ UTILS_SCRIPT="utils.sh"
35CANN_UNINSTALL_SCRIPT="cann_uninstall.sh"35CANN_UNINSTALL_SCRIPT="cann_uninstall.sh"
36VERSION_INFO="version.info"36VERSION_INFO="version.info"
37 37 
38-# msprof analysis whl
39-MSPROF_ANALYSIS_WHL="msprof-0.0.1-py3-none-any.whl"
40- 
41function print() {38function print() {
42 if [ ! -f "$log_file" ]; then39 if [ ! -f "$log_file" ]; then
43 echo "[${MSPROF_RUN_NAME}] [$(date +"%Y-%m-%d %H:%M:%S")] [$1]: $2"40 echo "[${MSPROF_RUN_NAME}] [$(date +"%Y-%m-%d %H:%M:%S")] [$1]: $2"
@@ -66,6 +63,7 @@ function get_log_file() {
66 else63 else
67 log_dir="${HOME}/var/log/ascend_seclog"64 log_dir="${HOME}/var/log/ascend_seclog"
68 fi65 fi
66+ mkdir -p "${log_dir}"
69 echo "${log_dir}/ascend_install.log"67 echo "${log_dir}/ascend_install.log"
70}68}
71 69 
Mversion.info+3-3
@@ -1,3 +1,3 @@
1- [PACKAGE]1+[PACKAGE]
2- Name=mindstudio-profiler2+Name=mindstudio-profiler
3- Version=26.0.03+Version=26.0.0
Dversion.txt+0-1
@@ -1 +0,0 @@
1-version=26.0.0