This commit is contained in:
hailin 2025-08-08 21:50:56 +08:00
parent af4cc28de2
commit 3c83bbb03e
1 changed files with 24 additions and 3 deletions

View File

@ -149,18 +149,39 @@ if git -C "${REPO_PATH}" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
if [[ "${cur_remote}" != "${REPO_URL}" ]]; then
log "remote 不匹配,重建仓库"
rm -rf "${REPO_PATH}"
git clone --branch "${REPO_BRANCH}" --depth 1 "${REPO_URL}" "${REPO_PATH}"
git clone --branch "${REPO_BRANCH}" --depth 1 --recurse-submodules --shallow-submodules "${REPO_URL}" "${REPO_PATH}"
else
log "更新已有仓库到 ${REPO_BRANCH}"
git -C "${REPO_PATH}" fetch --depth 1 origin "${REPO_BRANCH}"
git -C "${REPO_PATH}" checkout -f "${REPO_BRANCH}"
git -C "${REPO_PATH}" reset --hard "origin/${REPO_BRANCH}"
git -C "${REPO_PATH}" clean -fdx
# 同步并更新子模块到正确提交
git -C "${REPO_PATH}" submodule sync --recursive
git -C "${REPO_PATH}" submodule update --init --recursive --depth 1
fi
else
# 不存在或不是仓库:重拉
# 不存在或不是仓库:重拉(连带子模块)
rm -rf "${REPO_PATH}"
git clone --branch "${REPO_BRANCH}" --depth 1 "${REPO_URL}" "${REPO_PATH}"
git clone --branch "${REPO_BRANCH}" --depth 1 --recurse-submodules --shallow-submodules "${REPO_URL}" "${REPO_PATH}"
fi
# 再保险:确保子模块已到位
git -C "${REPO_PATH}" submodule sync --recursive
git -C "${REPO_PATH}" submodule update --init --recursive --depth 1
# 安装 ds-kernelsDeepSpeed Inference CUTLASS 依赖)
DK_DIR=""
# 从 .gitmodules 找子模块路径(不同版本命名可能是 ds-kernels 或 dskernels
if [[ -f "${REPO_PATH}/.gitmodules" ]]; then
DK_DIR=$(git -C "${REPO_PATH}" config --file .gitmodules --get-regexp path | awk '/ds[-_]?kernels/{print $2; exit}' || true)
fi
if [[ -n "${DK_DIR}" && -f "${REPO_PATH}/${DK_DIR}/setup.py" ]]; then
log "Install ds-kernels from submodule: ${DK_DIR}"
pip install -v "${REPO_PATH}/${DK_DIR}"
else
log "Submodule ds-kernels 不存在或未包含构建脚本,直接从仓库安装"
pip install -v "git+https://github.com/microsoft/ds-kernels.git"
fi
# 基本健检