Skip to content

Commit c991528

Browse files
maryamtahhanclaude
andcommitted
fix: remove duplicate usage() functions in embedding test scripts
Consolidate duplicate usage() function definitions in three embedding test scripts. Each script now has a single canonical usage() definition placed before the early help bypass loop, improving maintainability and preventing inconsistent help text. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Maryam Tahhan <mtahhan@redhat.com>
1 parent fad1881 commit c991528

File tree

3 files changed

+26
-135
lines changed

3 files changed

+26
-135
lines changed

automation/test-execution/bash/embedding/run-all.sh

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@ YELLOW='\033[1;33m'
2121
BLUE='\033[0;34m'
2222
NC='\033[0m'
2323

24-
# Early bypass for --help (before blocking guard)
25-
for arg in "$@"; do
26-
if [[ "$arg" == "-h" || "$arg" == "--help" ]]; then
27-
# Jump to usage function definition below
28-
usage() {
29-
cat <<EOF
24+
usage() {
25+
cat <<EOF
3026
Usage: $0 [OPTIONS]
3127
3228
Run complete embedding model performance test suite.
@@ -60,7 +56,11 @@ Examples:
6056
$0 --baseline-only
6157
6258
EOF
63-
}
59+
}
60+
61+
# Early bypass for --help (before blocking guard)
62+
for arg in "$@"; do
63+
if [[ "$arg" == "-h" || "$arg" == "--help" ]]; then
6464
usage
6565
exit 0
6666
fi
@@ -106,43 +106,6 @@ log_section() {
106106
echo ""
107107
}
108108

109-
usage() {
110-
cat <<EOF
111-
Usage: $0 [OPTIONS]
112-
113-
Run complete embedding model performance test suite.
114-
115-
Options:
116-
--vllm-host HOST vLLM server host (default: localhost)
117-
--vllm-port PORT vLLM server port (default: 8000)
118-
--models "MODEL..." Space-separated list of models to test
119-
--baseline-only Run only baseline tests
120-
--latency-only Run only latency tests
121-
-h, --help Show this help message
122-
123-
Environment Variables:
124-
VLLM_HOST Override vLLM host
125-
VLLM_PORT Override vLLM port
126-
MODELS Override models to test
127-
RUN_BASELINE Set to false to skip baseline tests
128-
RUN_LATENCY Set to false to skip latency tests
129-
130-
Examples:
131-
# Run all tests with local vLLM
132-
$0
133-
134-
# Run all tests with remote vLLM
135-
$0 --vllm-host 192.168.1.10
136-
137-
# Test specific models
138-
$0 --models "ibm-granite/granite-embedding-english-r2 ibm-granite/granite-embedding-278m-multilingual"
139-
140-
# Run only baseline tests
141-
$0 --baseline-only
142-
143-
EOF
144-
}
145-
146109
# Parse arguments
147110
while [[ $# -gt 0 ]]; do
148111
case $1 in

automation/test-execution/bash/embedding/run-baseline.sh

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@ YELLOW='\033[1;33m'
2323
BLUE='\033[0;34m'
2424
NC='\033[0m' # No Color
2525

26-
# Early bypass for --help (before blocking guard)
27-
for arg in "$@"; do
28-
if [[ "$arg" == "-h" || "$arg" == "--help" ]]; then
29-
usage() {
30-
cat <<EOF
26+
usage() {
27+
cat <<EOF
3128
Usage: $0 [MODEL] [OPTIONS]
3229
3330
Run baseline performance tests for embedding models.
@@ -47,18 +44,23 @@ Environment Variables:
4744
VLLM_HOST Override default vLLM host
4845
VLLM_PORT Override default vLLM port
4946
RESULTS_DIR Override default results directory
50-
NUM_PROMPTS Override default number of prompts
51-
INPUT_LEN Override default input length
5247
5348
Examples:
54-
# Run baseline test with default model
55-
$0
49+
# Test with local vLLM
50+
$0 ibm-granite/granite-embedding-english-r2
51+
52+
# Test with remote vLLM
53+
$0 ibm-granite/granite-embedding-278m-multilingual --vllm-host 192.168.1.10
5654
5755
# Custom configuration
5856
VLLM_HOST=10.0.0.5 VLLM_PORT=8080 $0 ibm-granite/granite-embedding-english-r2
5957
6058
EOF
61-
}
59+
}
60+
61+
# Early bypass for --help (before blocking guard)
62+
for arg in "$@"; do
63+
if [[ "$arg" == "-h" || "$arg" == "--help" ]]; then
6264
usage
6365
exit 0
6466
fi
@@ -101,41 +103,6 @@ log_warn() {
101103
echo -e "${YELLOW}[WARN]${NC} $*"
102104
}
103105

104-
usage() {
105-
cat <<EOF
106-
Usage: $0 [MODEL] [OPTIONS]
107-
108-
Run baseline performance tests for embedding models.
109-
110-
Arguments:
111-
MODEL Model to test (default: ibm-granite/granite-embedding-278m-multilingual)
112-
113-
Options:
114-
--vllm-host HOST vLLM server host (default: localhost)
115-
--vllm-port PORT vLLM server port (default: 8000)
116-
--results-dir DIR Results directory (default: PROJECT_ROOT/results/embedding-models)
117-
--num-prompts N Number of prompts (default: 1000)
118-
--input-len N Input sequence length (default: 512)
119-
-h, --help Show this help message
120-
121-
Environment Variables:
122-
VLLM_HOST Override default vLLM host
123-
VLLM_PORT Override default vLLM port
124-
RESULTS_DIR Override default results directory
125-
126-
Examples:
127-
# Test with local vLLM
128-
$0 ibm-granite/granite-embedding-english-r2
129-
130-
# Test with remote vLLM
131-
$0 ibm-granite/granite-embedding-278m-multilingual --vllm-host 192.168.1.10
132-
133-
# Custom configuration
134-
VLLM_HOST=10.0.0.5 VLLM_PORT=8080 $0 ibm-granite/granite-embedding-english-r2
135-
136-
EOF
137-
}
138-
139106
# Parse arguments
140107
while [[ $# -gt 0 ]]; do
141108
case $1 in

automation/test-execution/bash/embedding/run-latency.sh

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,8 @@ YELLOW='\033[1;33m'
2424
BLUE='\033[0;34m'
2525
NC='\033[0m' # No Color
2626

27-
# Early bypass for --help (before blocking guard)
28-
for arg in "$@"; do
29-
if [[ "$arg" == "-h" || "$arg" == "--help" ]]; then
30-
usage() {
31-
cat <<EOF
27+
usage() {
28+
cat <<EOF
3229
Usage: $0 [MODEL] [OPTIONS]
3330
3431
Run latency scaling tests for embedding models with varying concurrency.
@@ -65,7 +62,11 @@ Examples:
6562
ibm-granite/granite-embedding-english-r2
6663
6764
EOF
68-
}
65+
}
66+
67+
# Early bypass for --help (before blocking guard)
68+
for arg in "$@"; do
69+
if [[ "$arg" == "-h" || "$arg" == "--help" ]]; then
6970
usage
7071
exit 0
7172
fi
@@ -112,46 +113,6 @@ log_test() {
112113
echo -e "${BLUE}[TEST]${NC} $*"
113114
}
114115

115-
usage() {
116-
cat <<EOF
117-
Usage: $0 [MODEL] [OPTIONS]
118-
119-
Run latency scaling tests for embedding models with varying concurrency.
120-
121-
Arguments:
122-
MODEL Model to test (default: ibm-granite/granite-embedding-278m-multilingual)
123-
124-
Options:
125-
--vllm-host HOST vLLM server host (default: localhost)
126-
--vllm-port PORT vLLM server port (default: 8000)
127-
--results-dir DIR Results directory (default: PROJECT_ROOT/results/embedding-models)
128-
--num-prompts N Number of prompts (default: 1000)
129-
--input-len N Input sequence length (default: 512)
130-
--concurrency LEVELS Space-separated concurrency levels (default: "16 32 64 128 196")
131-
-h, --help Show this help message
132-
133-
Environment Variables:
134-
VLLM_HOST Override default vLLM host
135-
VLLM_PORT Override default vLLM port
136-
RESULTS_DIR Override default results directory
137-
CONCURRENCY_LEVELS Override concurrency levels to test
138-
139-
Examples:
140-
# Test with local vLLM
141-
$0 ibm-granite/granite-embedding-english-r2
142-
143-
# Test with remote vLLM and custom concurrency
144-
$0 ibm-granite/granite-embedding-278m-multilingual \\
145-
--vllm-host 192.168.1.10 \\
146-
--concurrency "8 16 32 64"
147-
148-
# Test with environment variables
149-
VLLM_HOST=10.0.0.5 CONCURRENCY_LEVELS="16 32 64" $0 \\
150-
ibm-granite/granite-embedding-english-r2
151-
152-
EOF
153-
}
154-
155116
# Parse arguments
156117
while [[ $# -gt 0 ]]; do
157118
case $1 in

0 commit comments

Comments
 (0)