"git@developer.sourcefind.cn:OpenDAS/sparseconvnet.git" did not exist on "d80ef3e21d183723b1135cea3579740b7c200ed7"
Commit aa83c8aa authored by Carsten Csiky's avatar Carsten Csiky Committed by GitHub
Browse files

fix: shellcheck errors (#298)


Co-authored-by: default avatarMeenakshi Sharma <163925564+nvda-mesharma@users.noreply.github.com>
parent 7cf75628
#!/bin/bash -e #!/usr/bin/env bash
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
set -e
TAG= TAG=
RUN_PREFIX= RUN_PREFIX=
...@@ -26,7 +27,7 @@ commit_id=$(git rev-parse --short HEAD) ...@@ -26,7 +27,7 @@ commit_id=$(git rev-parse --short HEAD)
current_tag=$(git describe --tags --exact-match 2>/dev/null | sed 's/^v//') || true current_tag=$(git describe --tags --exact-match 2>/dev/null | sed 's/^v//') || true
# Get latest TAG and add COMMIT_ID for dev # Get latest TAG and add COMMIT_ID for dev
latest_tag=$(git describe --tags --abbrev=0 $(git rev-list --tags --max-count=1 main) | sed 's/^v//') || true latest_tag=$(git describe --tags --abbrev=0 "$(git rev-list --tags --max-count=1 main)" | sed 's/^v//') || true
if [[ -z ${latest_tag} ]]; then if [[ -z ${latest_tag} ]]; then
latest_tag="0.0.1" latest_tag="0.0.1"
echo "No git release tag found, setting to unknown version: ${latest_tag}" echo "No git release tag found, setting to unknown version: ${latest_tag}"
...@@ -76,7 +77,7 @@ get_options() { ...@@ -76,7 +77,7 @@ get_options() {
PLATFORM=$2 PLATFORM=$2
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
--framework) --framework)
...@@ -84,7 +85,7 @@ get_options() { ...@@ -84,7 +85,7 @@ get_options() {
FRAMEWORK=$2 FRAMEWORK=$2
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
--tensorrtllm-pip-wheel-path) --tensorrtllm-pip-wheel-path)
...@@ -92,7 +93,7 @@ get_options() { ...@@ -92,7 +93,7 @@ get_options() {
TENSORRTLLM_PIP_WHEEL_PATH=$2 TENSORRTLLM_PIP_WHEEL_PATH=$2
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
--base-image) --base-image)
...@@ -100,7 +101,7 @@ get_options() { ...@@ -100,7 +101,7 @@ get_options() {
BASE_IMAGE=$2 BASE_IMAGE=$2
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
--base-image-tag) --base-image-tag)
...@@ -108,7 +109,7 @@ get_options() { ...@@ -108,7 +109,7 @@ get_options() {
BASE_IMAGE_TAG=$2 BASE_IMAGE_TAG=$2
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
--target) --target)
...@@ -116,7 +117,7 @@ get_options() { ...@@ -116,7 +117,7 @@ get_options() {
TARGET=$2 TARGET=$2
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
--build-arg) --build-arg)
...@@ -124,7 +125,7 @@ get_options() { ...@@ -124,7 +125,7 @@ get_options() {
BUILD_ARGS+="--build-arg $2 " BUILD_ARGS+="--build-arg $2 "
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
--tag) --tag)
...@@ -132,7 +133,7 @@ get_options() { ...@@ -132,7 +133,7 @@ get_options() {
TAG="--tag $2" TAG="--tag $2"
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
--dry-run) --dry-run)
...@@ -151,7 +152,7 @@ get_options() { ...@@ -151,7 +152,7 @@ get_options() {
CACHE_FROM="--cache-from $2" CACHE_FROM="--cache-from $2"
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
--cache-to) --cache-to)
...@@ -159,7 +160,7 @@ get_options() { ...@@ -159,7 +160,7 @@ get_options() {
CACHE_TO="--cache-to $2" CACHE_TO="--cache-to $2"
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
--build-context) --build-context)
...@@ -167,7 +168,7 @@ get_options() { ...@@ -167,7 +168,7 @@ get_options() {
BUILD_CONTEXT_ARG="--build-context $2" BUILD_CONTEXT_ARG="--build-context $2"
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
--release-build) --release-build)
...@@ -178,10 +179,10 @@ get_options() { ...@@ -178,10 +179,10 @@ get_options() {
break break
;; ;;
-?*) -?*)
error 'ERROR: Unknown option: ' $1 error 'ERROR: Unknown option: ' "$1"
;; ;;
?*) ?*)
error 'ERROR: Unknown option: ' $1 error 'ERROR: Unknown option: ' "$1"
;; ;;
*) *)
break break
...@@ -194,24 +195,24 @@ get_options() { ...@@ -194,24 +195,24 @@ get_options() {
FRAMEWORK=$DEFAULT_FRAMEWORK FRAMEWORK=$DEFAULT_FRAMEWORK
fi fi
if [ ! -z "$FRAMEWORK" ]; then if [ -n "$FRAMEWORK" ]; then
FRAMEWORK=${FRAMEWORK^^} FRAMEWORK=${FRAMEWORK^^}
if [[ ! -n "${FRAMEWORKS[$FRAMEWORK]}" ]]; then if [[ -z "${FRAMEWORKS[$FRAMEWORK]}" ]]; then
error 'ERROR: Unknown framework: ' $FRAMEWORK error 'ERROR: Unknown framework: ' "$FRAMEWORK"
fi fi
if [ -z $BASE_IMAGE_TAG ]; then if [ -z "$BASE_IMAGE_TAG" ]; then
BASE_IMAGE_TAG=${FRAMEWORK}_BASE_IMAGE_TAG BASE_IMAGE_TAG=${FRAMEWORK}_BASE_IMAGE_TAG
BASE_IMAGE_TAG=${!BASE_IMAGE_TAG} BASE_IMAGE_TAG=${!BASE_IMAGE_TAG}
fi fi
if [ -z $BASE_IMAGE ]; then if [ -z "$BASE_IMAGE" ]; then
BASE_IMAGE=${FRAMEWORK}_BASE_IMAGE BASE_IMAGE=${FRAMEWORK}_BASE_IMAGE
BASE_IMAGE=${!BASE_IMAGE} BASE_IMAGE=${!BASE_IMAGE}
fi fi
if [ -z $BASE_IMAGE ]; then if [ -z "$BASE_IMAGE" ]; then
error "ERROR: Framework $FRAMEWORK without BASE_IMAGE" error "ERROR: Framework $FRAMEWORK without BASE_IMAGE"
fi fi
...@@ -222,16 +223,16 @@ get_options() { ...@@ -222,16 +223,16 @@ get_options() {
if [ -z "$TAG" ]; then if [ -z "$TAG" ]; then
TAG="--tag dynamo:${VERSION}-${FRAMEWORK,,}" TAG="--tag dynamo:${VERSION}-${FRAMEWORK,,}"
if [ ! -z "${TARGET}" ]; then if [ -n "${TARGET}" ]; then
TAG="${TAG}-${TARGET}" TAG="${TAG}-${TARGET}"
fi fi
fi fi
if [ ! -z "$PLATFORM" ]; then if [ -n "$PLATFORM" ]; then
PLATFORM="--platform ${PLATFORM}" PLATFORM="--platform ${PLATFORM}"
fi fi
if [ ! -z "$TARGET" ]; then if [ -n "$TARGET" ]; then
TARGET_STR="--target ${TARGET}" TARGET_STR="--target ${TARGET}"
else else
TARGET_STR="--target dev" TARGET_STR="--target dev"
...@@ -257,9 +258,9 @@ show_image_options() { ...@@ -257,9 +258,9 @@ show_image_options() {
show_help() { show_help() {
echo "usage: build.sh" echo "usage: build.sh"
echo " [--base base image]" echo " [--base base image]"
echo " [--base-imge-tag base image tag]" echo " [--base-image-tag base image tag]"
echo " [--platform platform for docker build" echo " [--platform platform for docker build"
echo " [--framework framework one of ${!FRAMEWORKS[@]}]" echo " [--framework framework one of ${!FRAMEWORKS[*]}]"
echo " [--tensorrtllm-pip-wheel-path path to tensorrtllm pip wheel]" echo " [--tensorrtllm-pip-wheel-path path to tensorrtllm pip wheel]"
echo " [--build-arg additional build args to pass to docker build]" echo " [--build-arg additional build args to pass to docker build]"
echo " [--cache-from cache location to start from]" echo " [--cache-from cache location to start from]"
...@@ -298,8 +299,8 @@ if [[ $FRAMEWORK == "VLLM" ]]; then ...@@ -298,8 +299,8 @@ if [[ $FRAMEWORK == "VLLM" ]]; then
if [ -d "$NIXL_DIR" ]; then if [ -d "$NIXL_DIR" ]; then
echo "Warning: $NIXL_DIR already exists, skipping clone" echo "Warning: $NIXL_DIR already exists, skipping clone"
else else
if [ ! -z ${GITHUB_TOKEN} ]; then if [ -n "${GITHUB_TOKEN}" ]; then
git clone https://oauth2:${GITHUB_TOKEN}@github.com/${NIXL_REPO} "$NIXL_DIR" git clone "https://oauth2:${GITHUB_TOKEN}@github.com/${NIXL_REPO}" "$NIXL_DIR"
else else
# Try HTTPS first with credential prompting disabled, fall back to SSH if it fails # Try HTTPS first with credential prompting disabled, fall back to SSH if it fails
if ! GIT_TERMINAL_PROMPT=0 git clone https://github.com/${NIXL_REPO} "$NIXL_DIR"; then if ! GIT_TERMINAL_PROMPT=0 git clone https://github.com/${NIXL_REPO} "$NIXL_DIR"; then
...@@ -309,7 +310,7 @@ if [[ $FRAMEWORK == "VLLM" ]]; then ...@@ -309,7 +310,7 @@ if [[ $FRAMEWORK == "VLLM" ]]; then
fi fi
fi fi
cd "$NIXL_DIR" cd "$NIXL_DIR" || exit
if ! git checkout ${NIXL_COMMIT}; then if ! git checkout ${NIXL_COMMIT}; then
echo "ERROR: Failed to checkout NIXL commit ${NIXL_COMMIT}. The cached directory may be out of date." echo "ERROR: Failed to checkout NIXL commit ${NIXL_COMMIT}. The cached directory may be out of date."
echo "Please delete $NIXL_DIR and re-run the build script." echo "Please delete $NIXL_DIR and re-run the build script."
...@@ -326,21 +327,21 @@ fi ...@@ -326,21 +327,21 @@ fi
BUILD_ARGS+=" --build-arg BASE_IMAGE=$BASE_IMAGE --build-arg BASE_IMAGE_TAG=$BASE_IMAGE_TAG --build-arg FRAMEWORK=$FRAMEWORK --build-arg ${FRAMEWORK}_FRAMEWORK=1 --build-arg VERSION=$VERSION --build-arg PYTHON_PACKAGE_VERSION=$PYTHON_PACKAGE_VERSION" BUILD_ARGS+=" --build-arg BASE_IMAGE=$BASE_IMAGE --build-arg BASE_IMAGE_TAG=$BASE_IMAGE_TAG --build-arg FRAMEWORK=$FRAMEWORK --build-arg ${FRAMEWORK}_FRAMEWORK=1 --build-arg VERSION=$VERSION --build-arg PYTHON_PACKAGE_VERSION=$PYTHON_PACKAGE_VERSION"
if [ ! -z ${GITHUB_TOKEN} ]; then if [ -n "${GITHUB_TOKEN}" ]; then
BUILD_ARGS+=" --build-arg GITHUB_TOKEN=${GITHUB_TOKEN} " BUILD_ARGS+=" --build-arg GITHUB_TOKEN=${GITHUB_TOKEN} "
fi fi
if [ ! -z ${GITLAB_TOKEN} ]; then if [ -n "${GITLAB_TOKEN}" ]; then
BUILD_ARGS+=" --build-arg GITLAB_TOKEN=${GITLAB_TOKEN} " BUILD_ARGS+=" --build-arg GITLAB_TOKEN=${GITLAB_TOKEN} "
fi fi
if [[ $FRAMEWORK == "TENSORRTLLM" ]]; then if [[ $FRAMEWORK == "TENSORRTLLM" ]]; then
if [ ! -z ${TENSORRTLLM_PIP_WHEEL_PATH} ]; then if [ -n "${TENSORRTLLM_PIP_WHEEL_PATH}" ]; then
BUILD_ARGS+=" --build-arg TENSORRTLLM_PIP_WHEEL_PATH=${TENSORRTLLM_PIP_WHEEL_PATH} " BUILD_ARGS+=" --build-arg TENSORRTLLM_PIP_WHEEL_PATH=${TENSORRTLLM_PIP_WHEEL_PATH} "
fi fi
fi fi
if [ ! -z ${HF_TOKEN} ]; then if [ -n "${HF_TOKEN}" ]; then
BUILD_ARGS+=" --build-arg HF_TOKEN=${HF_TOKEN} " BUILD_ARGS+=" --build-arg HF_TOKEN=${HF_TOKEN} "
fi fi
if [ ! -z ${RELEASE_BUILD} ]; then if [ ! -z ${RELEASE_BUILD} ]; then
...@@ -349,7 +350,7 @@ if [ ! -z ${RELEASE_BUILD} ]; then ...@@ -349,7 +350,7 @@ if [ ! -z ${RELEASE_BUILD} ]; then
fi fi
LATEST_TAG="--tag dynamo:latest-${FRAMEWORK,,}" LATEST_TAG="--tag dynamo:latest-${FRAMEWORK,,}"
if [ ! -z ${TARGET} ]; then if [ -n "${TARGET}" ]; then
LATEST_TAG="${LATEST_TAG}-${TARGET}" LATEST_TAG="${LATEST_TAG}-${TARGET}"
fi fi
......
#!/bin/bash -e #!/usr/bin/env bash
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
set -e
RUN_PREFIX= RUN_PREFIX=
# Frameworks # Frameworks
...@@ -50,7 +52,7 @@ get_options() { ...@@ -50,7 +52,7 @@ get_options() {
FRAMEWORK=$2 FRAMEWORK=$2
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
--image) --image)
...@@ -58,7 +60,7 @@ get_options() { ...@@ -58,7 +60,7 @@ get_options() {
IMAGE=$2 IMAGE=$2
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
--target) --target)
...@@ -66,7 +68,7 @@ get_options() { ...@@ -66,7 +68,7 @@ get_options() {
TARGET=$2 TARGET=$2
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
--name) --name)
...@@ -74,7 +76,7 @@ get_options() { ...@@ -74,7 +76,7 @@ get_options() {
NAME=$2 NAME=$2
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
--hf-cache) --hf-cache)
...@@ -82,7 +84,7 @@ get_options() { ...@@ -82,7 +84,7 @@ get_options() {
HF_CACHE=$2 HF_CACHE=$2
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
...@@ -91,7 +93,7 @@ get_options() { ...@@ -91,7 +93,7 @@ get_options() {
GPUS=$2 GPUS=$2
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
--entrypoint) --entrypoint)
...@@ -99,7 +101,7 @@ get_options() { ...@@ -99,7 +101,7 @@ get_options() {
ENTRYPOINT=$2 ENTRYPOINT=$2
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
--privileged) --privileged)
...@@ -107,7 +109,7 @@ get_options() { ...@@ -107,7 +109,7 @@ get_options() {
PRIVILEGED=$2 PRIVILEGED=$2
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
--rm) --rm)
...@@ -115,7 +117,7 @@ get_options() { ...@@ -115,7 +117,7 @@ get_options() {
RM=$2 RM=$2
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
-v) -v)
...@@ -123,7 +125,7 @@ get_options() { ...@@ -123,7 +125,7 @@ get_options() {
VOLUME_MOUNTS+=" -v $2 " VOLUME_MOUNTS+=" -v $2 "
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
-e) -e)
...@@ -131,7 +133,7 @@ get_options() { ...@@ -131,7 +133,7 @@ get_options() {
ENVIRONMENT_VARIABLES+=" -e $2 " ENVIRONMENT_VARIABLES+=" -e $2 "
shift shift
else else
missing_requirement $1 missing_requirement "$1"
fi fi
;; ;;
-it) -it)
...@@ -153,10 +155,10 @@ get_options() { ...@@ -153,10 +155,10 @@ get_options() {
break break
;; ;;
-?*) -?*)
error 'ERROR: Unknown option: ' $1 error 'ERROR: Unknown option: ' "$1"
;; ;;
?*) ?*)
error 'ERROR: Unknown option: ' $1 error 'ERROR: Unknown option: ' "$1"
;; ;;
*) *)
break break
...@@ -170,16 +172,16 @@ get_options() { ...@@ -170,16 +172,16 @@ get_options() {
FRAMEWORK=$DEFAULT_FRAMEWORK FRAMEWORK=$DEFAULT_FRAMEWORK
fi fi
if [ ! -z "$FRAMEWORK" ]; then if [ -n "$FRAMEWORK" ]; then
FRAMEWORK=${FRAMEWORK^^} FRAMEWORK=${FRAMEWORK^^}
if [[ ! -n "${FRAMEWORKS[$FRAMEWORK]}" ]]; then if [[ -n "${FRAMEWORKS[$FRAMEWORK]}" ]]; then
error 'ERROR: Unknown framework: ' $FRAMEWORK error 'ERROR: Unknown framework: ' "$FRAMEWORK"
fi fi
fi fi
if [ -z "$IMAGE" ]; then if [ -z "$IMAGE" ]; then
IMAGE="dynamo:latest-${FRAMEWORK,,}" IMAGE="dynamo:latest-${FRAMEWORK,,}"
if [ ! -z ${TARGET} ]; then if [ -n "${TARGET}" ]; then
IMAGE="${IMAGE}-${TARGET}" IMAGE="${IMAGE}-${TARGET}"
fi fi
fi fi
...@@ -202,7 +204,7 @@ get_options() { ...@@ -202,7 +204,7 @@ get_options() {
ENTRYPOINT_STRING="--entrypoint ${ENTRYPOINT}" ENTRYPOINT_STRING="--entrypoint ${ENTRYPOINT}"
fi fi
if [ ! -z "$MOUNT_WORKSPACE" ]; then if [ -n "$MOUNT_WORKSPACE" ]; then
VOLUME_MOUNTS+=" -v ${SOURCE_DIR}/..:/workspace " VOLUME_MOUNTS+=" -v ${SOURCE_DIR}/..:/workspace "
VOLUME_MOUNTS+=" -v /tmp:/tmp " VOLUME_MOUNTS+=" -v /tmp:/tmp "
VOLUME_MOUNTS+=" -v /mnt/:/mnt " VOLUME_MOUNTS+=" -v /mnt/:/mnt "
...@@ -211,7 +213,7 @@ get_options() { ...@@ -211,7 +213,7 @@ get_options() {
HF_CACHE=$DEFAULT_HF_CACHE HF_CACHE=$DEFAULT_HF_CACHE
fi fi
if [ -z ${PRIVILEGED} ]; then if [ -z "${PRIVILEGED}" ]; then
PRIVILEGED="TRUE" PRIVILEGED="TRUE"
fi fi
...@@ -224,16 +226,16 @@ get_options() { ...@@ -224,16 +226,16 @@ get_options() {
HF_CACHE= HF_CACHE=
fi fi
if [ ! -z "$HF_CACHE" ]; then if [ -n "$HF_CACHE" ]; then
mkdir -p $HF_CACHE mkdir -p "$HF_CACHE"
VOLUME_MOUNTS+=" -v $HF_CACHE:/root/.cache/huggingface" VOLUME_MOUNTS+=" -v $HF_CACHE:/root/.cache/huggingface"
fi fi
if [ -z ${PRIVILEGED} ]; then if [ -z "${PRIVILEGED}" ]; then
PRIVILEGED="FALSE" PRIVILEGED="FALSE"
fi fi
if [ -z ${RM} ]; then if [ -z "${RM}" ]; then
RM="TRUE" RM="TRUE"
fi fi
...@@ -256,7 +258,7 @@ get_options() { ...@@ -256,7 +258,7 @@ get_options() {
show_help() { show_help() {
echo "usage: run.sh" echo "usage: run.sh"
echo " [--image image]" echo " [--image image]"
echo " [--framework framework one of ${!FRAMEWORKS[@]}]" echo " [--framework framework one of ${!FRAMEWORKS[*]}]"
echo " [--name name for launched container, default NONE] " echo " [--name name for launched container, default NONE] "
echo " [--privileged whether to launch in privileged mode, default FALSE unless mounting workspace]" echo " [--privileged whether to launch in privileged mode, default FALSE unless mounting workspace]"
echo " [--dry-run print docker commands without running]" echo " [--dry-run print docker commands without running]"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment