|
1 | 1 | #!/bin/bash |
2 | | -# Copyright 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 2 | +# Copyright 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
3 | 3 | # |
4 | 4 | # Redistribution and use in source and binary forms, with or without |
5 | 5 | # modification, are permitted provided that the following conditions |
@@ -47,7 +47,7 @@ cp ../../python_models/$MODEL_NAME/config.pbtxt ./models/$MODEL_NAME/config.pbtx |
47 | 47 | for SIGNAL in 11 9; do |
48 | 48 | echo -e "\n***\n*** Testing model_readiness with Signal $SIGNAL\n***" |
49 | 49 | SERVER_LOG="./model_readiness_signal_${SIGNAL}_server.log" |
50 | | - CLIENT_LOG="./model_readiness_${SIGNAL}_client.log" |
| 50 | + CLIENT_LOG="./model_readiness_signal_${SIGNAL}_client.log" |
51 | 51 |
|
52 | 52 | run_server |
53 | 53 | if [ "$SERVER_PID" == "0" ]; then |
@@ -107,10 +107,87 @@ for SIGNAL in 11 9; do |
107 | 107 | kill_server |
108 | 108 | done |
109 | 109 |
|
| 110 | +# |
| 111 | +# Test User-Defined Model Readiness Function |
| 112 | +# |
| 113 | +echo -e "\n***\n*** Testing User-Defined is_ready() Function\n***" |
| 114 | + |
| 115 | +# Helper function to set up test models with different readiness behaviors based on config parameters |
| 116 | +setup_readiness_test_model() { |
| 117 | + local model_name=$1 |
| 118 | + local return_value=$2 |
| 119 | + local delay_secs=$3 |
| 120 | + |
| 121 | + mkdir -p ./models/$model_name/1/ |
| 122 | + if [ "$model_name" == "is_ready_fn_coroutine_returns_true" ]; then |
| 123 | + cp ./test_models/readiness_coroutine_model.py ./models/$model_name/1/model.py |
| 124 | + else |
| 125 | + cp ./test_models/readiness_model.py ./models/$model_name/1/model.py |
| 126 | + fi |
| 127 | + cp ./models/identity_fp32/config.pbtxt ./models/$model_name/config.pbtxt |
| 128 | + sed -i "s/^name:.*/name: \"$model_name\"/" ./models/$model_name/config.pbtxt |
| 129 | + cat >> ./models/$model_name/config.pbtxt << EOF |
| 130 | +parameters: { |
| 131 | + key: "READINESS_FN_RETURN_VALUE" |
| 132 | + value: { string_value: "$return_value" } |
| 133 | +} |
| 134 | +parameters: { |
| 135 | + key: "READINESS_FN_DELAY_SECS" |
| 136 | + value: { string_value: "$delay_secs" } |
| 137 | +} |
| 138 | +EOF |
| 139 | +} |
| 140 | + |
| 141 | +# Create readiness test models using shared model.py + config parameters |
| 142 | +setup_readiness_test_model "is_ready_fn_returns_true" "true" "0.1" |
| 143 | +setup_readiness_test_model "is_ready_fn_returns_false" "false" "0.1" |
| 144 | +setup_readiness_test_model "is_ready_fn_raises_error" "exception" "0.1" |
| 145 | +setup_readiness_test_model "is_ready_fn_returns_non_boolean" "non_boolean" "0.1" |
| 146 | +setup_readiness_test_model "is_ready_fn_timeout" "true" "8" |
| 147 | +setup_readiness_test_model "is_ready_fn_coroutine_returns_true" "coroutine" "0.1" |
| 148 | + |
| 149 | +# Decoupled model has a unique execute() and its own config |
| 150 | +mkdir -p ./models/is_ready_fn_returns_true_decoupled/1/ |
| 151 | +cp ./test_models/is_ready_fn_returns_true_decoupled/model.py \ |
| 152 | + ./models/is_ready_fn_returns_true_decoupled/1/model.py |
| 153 | +cp ./test_models/is_ready_fn_returns_true_decoupled/config.pbtxt \ |
| 154 | + ./models/is_ready_fn_returns_true_decoupled/config.pbtxt |
| 155 | + |
| 156 | +# Start server with all models |
| 157 | +SERVER_ARGS="--model-repository=$(pwd)/models --backend-directory=${BACKEND_DIR} --log-verbose=1" |
| 158 | +SERVER_LOG="./test_user_defined_model_readiness_function_server.log" |
| 159 | +CLIENT_LOG="./test_user_defined_model_readiness_function_client.log" |
| 160 | + |
| 161 | +run_server |
| 162 | +if [ "$SERVER_PID" == "0" ]; then |
| 163 | + cat $SERVER_LOG |
| 164 | + echo -e "\n***\n*** Failed to start $SERVER\n***" |
| 165 | + exit 1 |
| 166 | +fi |
| 167 | + |
| 168 | +set +e |
| 169 | + |
| 170 | +echo "Running TestUserDefinedModelReadinessFunction..." |
| 171 | +python3 -m unittest test_model_readiness.TestUserDefinedModelReadinessFunction -v >> ${CLIENT_LOG} 2>&1 |
| 172 | +TEST_EXIT_CODE=$? |
| 173 | + |
| 174 | +if [ $TEST_EXIT_CODE -ne 0 ]; then |
| 175 | + echo -e "\n***\n*** TestUserDefinedModelReadinessFunction FAILED\n***" |
| 176 | + cat ${CLIENT_LOG} |
| 177 | + RET=1 |
| 178 | +else |
| 179 | + echo -e "\n***\n*** TestUserDefinedModelReadinessFunction PASSED\n***" |
| 180 | +fi |
| 181 | + |
| 182 | +set -e |
| 183 | +kill_server |
| 184 | + |
| 185 | + |
| 186 | +# Final result |
110 | 187 | if [ $RET -eq 0 ]; then |
111 | | - echo -e "\n***\n*** Test Passed\n***" |
| 188 | + echo -e "\n***\n*** All Model Readiness Tests Passed\n***" |
112 | 189 | else |
113 | | - echo -e "\n***\n*** Test FAILED\n***" |
| 190 | + echo -e "\n***\n*** Model Readiness Tests FAILED\n***" |
114 | 191 | fi |
115 | 192 |
|
116 | 193 | exit $RET |
|
0 commit comments