Skip to content

Commit 51c6508

Browse files
committed
Build CMD dynamically from available ENV
1 parent 9ab8ae7 commit 51c6508

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

build/Containerfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ LABEL org.opencontainers.image.description="GuideLLM Benchmark Container"
3737

3838
# Set the environment variable for the benchmark script
3939
# TODO: Replace with scenario environment variables
40-
ENV TARGET="http://localhost:8000" \
41-
MODEL="neuralmagic/Meta-Llama-3.1-8B-Instruct-quantized.w4a16" \
42-
RATE_TYPE="sweep" \
43-
DATA="prompt_tokens=256,output_tokens=128" \
44-
MAX_REQUESTS="100" \
45-
MAX_SECONDS="" \
46-
OUTPUT_PATH="/results/results.json"
40+
ENV GUIDELLM_TARGET="http://localhost:8000" \
41+
GUIDELLM_MODEL="neuralmagic/Meta-Llama-3.1-8B-Instruct-quantized.w4a16" \
42+
GUIDELLM_RATE_TYPE="sweep" \
43+
GUIDELLM_DATA="prompt_tokens=256,output_tokens=128" \
44+
GUIDELLM_MAX_REQUESTS="100" \
45+
GUIDELLM_MAX_SECONDS="" \
46+
GUIDELLM_OUTPUT_PATH="/results/results.json"
4747

4848
ENTRYPOINT [ "/opt/guidellm/bin/entrypoint.sh" ]

build/entrypoint.sh

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,26 @@ if [ $# -gt 0 ]; then
1010
exec $guidellm_bin "$@"
1111
fi
1212

13-
# NOTE: Bash vec + exec prevent shell escape issues
14-
CMD=("${guidellm_bin}" "benchmark" "--target" "${TARGET}" "--model" "${MODEL}" "--rate-type" "${RATE_TYPE}" "--data" "${DATA}")
13+
# Get a list of environment variables that start with GUIDELLM_
14+
args="$(printenv | cut -d= -f1 | grep -E '^GUIDELLM_')"
1515

16-
if [ -n "${MAX_REQUESTS}" ]; then
17-
CMD+=("--max-requests" "${MAX_REQUESTS}")
18-
fi
16+
# NOTE: Bash array + exec prevent shell escape issues
17+
CMD=("${guidellm_bin}" "benchmark")
1918

20-
if [ -n "${MAX_SECONDS}" ]; then
21-
CMD+=("--max-seconds" "${MAX_SECONDS}")
22-
fi
19+
# Parse environment variables for the benchmark command
20+
for var in $args; do
21+
# Remove GUIDELLM_ prefix
22+
arg_name="${var#GUIDELLM_}"
23+
# Convert to lowercase
24+
arg_name="${arg_name,,}"
25+
# Replace underscores with dashes
26+
arg_name="${arg_name//_/-}"
2327

24-
if [ -n "${OUTPUT_PATH}" ]; then
25-
CMD+=("--output-path" "${OUTPUT_PATH}")
26-
fi
28+
# Add the argument to the command array if set
29+
if [ -n "${!var}" ]; then
30+
CMD+=("--${arg_name}" "${!var}")
31+
fi
32+
done
2733

2834
# Execute the command
2935
echo "Running command: ${CMD[*]}"

0 commit comments

Comments
 (0)