-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ci: Enable detection of unresponsive or crashed Python backend stub process #8552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pskiran1
merged 19 commits into
main
from
spolisetty/tri-231-backend-endpoint-reports-to-be-healthy-when-using
Dec 9, 2025
Merged
Changes from 4 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
80ce52e
Update
pskiran1 748feba
Fix pre-commit
pskiran1 0f998e5
Update
pskiran1 59b5be2
Fix pre-commit
pskiran1 0194ef6
Update qa/L0_backend_python/model_ready_check/check_model_ready.py
pskiran1 d4b929a
Update qa/L0_backend_python/model_ready_check/check_model_ready.py
pskiran1 b04956f
Update qa/L0_backend_python/model_ready_check/check_model_ready.py
pskiran1 a563c53
Update qa/L0_backend_python/model_ready_check/test.sh
pskiran1 65cd1eb
Update qa/L0_backend_python/model_ready_check/test.sh
pskiran1 f262812
Update
pskiran1 7c1ac81
Update
pskiran1 25072c1
Update test
pskiran1 8311c92
Merge branch 'main' into spolisetty/tri-231-backend-endpoint-reports-…
pskiran1 0b29cb4
Update test name
pskiran1 e525825
Update test name
pskiran1 a85a459
Fix pre-commit
pskiran1 839a813
Update
pskiran1 2127c42
Merge branch 'main' into spolisetty/tri-231-backend-endpoint-reports-…
pskiran1 56e4c8b
Update
pskiran1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
qa/L0_backend_python/model_ready_check/check_model_ready.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| #!/bin/bash | ||
| # Copyright 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions | ||
| # are met: | ||
| # * Redistributions of source code must retain the above copyright | ||
| # notice, this list of conditions and the following disclaimer. | ||
| # * Redistributions in binary form must reproduce the above copyright | ||
| # notice, this list of conditions and the following disclaimer in the | ||
| # documentation and/or other materials provided with the distribution. | ||
| # * Neither the name of NVIDIA CORPORATION nor the names of its | ||
| # contributors may be used to endorse or promote products derived | ||
| # from this software without specific prior written permission. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY | ||
| # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
| # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
| # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
| # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
| # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
| # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
|
||
| import unittest | ||
|
|
||
| import tritonclient.grpc as grpcclient | ||
| import tritonclient.http as httpclient | ||
|
|
||
|
|
||
| class ModelReadyTest(unittest.TestCase): | ||
| def setUp(self): | ||
| self.model_name = "identity_fp32" | ||
| self.url_http = "localhost:8000" | ||
| self.url_grpc = "localhost:8001" | ||
| self.client_http = httpclient.InferenceServerClient(url=self.url_http) | ||
| self.client_grpc = grpcclient.InferenceServerClient(url=self.url_grpc) | ||
|
|
||
| def test_model_ready(self): | ||
| print(f"\nTesting if model '{self.model_name}' is READY ...") | ||
|
|
||
| # Check HTTP | ||
| try: | ||
| is_ready = self.client_http.is_model_ready(self.model_name) | ||
| self.assertTrue( | ||
| is_ready, f"[HTTP] Model {self.model_name} should be READY but is NOT" | ||
| ) | ||
| except Exception as e: | ||
| self.fail(f"[HTTP] Unexpected error: {str(e)}") | ||
|
|
||
| # Check gRPC | ||
| try: | ||
| is_ready = self.client_grpc.is_model_ready(self.model_name) | ||
| self.assertTrue( | ||
| is_ready, f"[gRPC] Model {self.model_name} should be READY but is NOT" | ||
| ) | ||
| except Exception as e: | ||
| self.fail(f"[gRPC] Unexpected error: {str(e)}") | ||
|
|
||
| def test_model_not_ready(self): | ||
| print(f"\nTesting if model '{self.model_name}' is NOT READY ...") | ||
|
|
||
| # Check HTTP | ||
| try: | ||
| is_ready = self.client_http.is_model_ready(self.model_name) | ||
| self.assertFalse( | ||
| is_ready, | ||
| f"[HTTP] Model {self.model_name} should be NOT READY but is READY.", | ||
pskiran1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
| except Exception as e: | ||
| self.fail(f"[HTTP] Unexpected error: {str(e)}") | ||
|
|
||
| # Check gRPC | ||
| try: | ||
| is_ready = self.client_grpc.is_model_ready(self.model_name) | ||
| self.assertFalse( | ||
| is_ready, | ||
| f"[gRPC] Model {self.model_name} should be NOT READY but is READY", | ||
pskiran1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
| except Exception as e: | ||
| self.fail(f"[gRPC] Unexpected error: {str(e)}") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| #!/bin/bash | ||
| # Copyright 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions | ||
| # are met: | ||
| # * Redistributions of source code must retain the above copyright | ||
| # notice, this list of conditions and the following disclaimer. | ||
| # * Redistributions in binary form must reproduce the above copyright | ||
| # notice, this list of conditions and the following disclaimer in the | ||
| # documentation and/or other materials provided with the distribution. | ||
| # * Neither the name of NVIDIA CORPORATION nor the names of its | ||
| # contributors may be used to endorse or promote products derived | ||
| # from this software without specific prior written permission. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY | ||
| # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
| # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
| # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
| # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
| # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
| # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
|
||
| CLIENT_LOG="./model_ready_check_client.log" | ||
| TEST_RESULT_FILE='test_results.txt' | ||
| source ../common.sh | ||
| source ../../common/util.sh | ||
|
|
||
| SERVER_ARGS="--model-repository=${MODELDIR}/model_ready_check/models --backend-directory=${BACKEND_DIR} --log-verbose=1" | ||
| SERVER_LOG="./model_ready_check_server.log" | ||
|
|
||
| RET=0 | ||
| rm -fr *.log ./models | ||
|
|
||
| mkdir -p models/identity_fp32/1/ | ||
| cp ../../python_models/identity_fp32/model.py ./models/identity_fp32/1/model.py | ||
| cp ../../python_models/identity_fp32/config.pbtxt ./models/identity_fp32/config.pbtxt | ||
|
|
||
| # | ||
| # Test Model Ready Check (TRITONBACKEND_ModelInstanceReady) | ||
| # Test with different signals to simulate various crash/exit scenarios | ||
| # 11 (SIGSEGV) - Segmentation fault / crash | ||
| # 9 (SIGKILL) - Force kill | ||
| for SIGNAL in 11 9; do | ||
| echo -e "\n***\n*** Testing Model Ready Check with Signal $SIGNAL\n***" | ||
|
|
||
| run_server | ||
| if [ "$SERVER_PID" == "0" ]; then | ||
| cat $SERVER_LOG | ||
| echo -e "\n***\n*** Failed to start $SERVER\n***" | ||
| exit 1 | ||
| fi | ||
|
|
||
| set +e | ||
|
|
||
| # 1. Verify model is initially ready | ||
| echo "Checking Initial Readiness..." | ||
| python3 -m unittest check_model_ready.ModelReadyTest.test_model_ready | ||
| if [ $? -ne 0 ]; then | ||
| echo -e "\n***\n*** Model Ready Check Failed (Signal $SIGNAL): Initial readiness check failed \n***" | ||
| RET=1 | ||
| kill_server | ||
| exit 1 | ||
| fi | ||
|
|
||
| # 2. Find the stub process PID | ||
| stub_pid=$(pgrep -f "triton_python_backend_stub*") | ||
pskiran1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if [ -z "$stub_pid" ]; then | ||
| echo -e "\n***\n*** Model Ready Check Failed (Signal $SIGNAL): Could not find stub process \n***" | ||
| RET=1 | ||
| kill_server | ||
| else | ||
| echo "Found stub process: $stub_pid" | ||
|
|
||
| # 3. Kill the stub process | ||
| echo "Killing stub with signal $SIGNAL..." | ||
| kill -$SIGNAL $stub_pid | ||
| sleep 1 | ||
|
|
||
| # 4. Verify model is now NOT ready | ||
| echo "Checking Not Ready Status..." | ||
| python3 -m unittest check_model_ready.ModelReadyTest.test_model_not_ready | ||
| if [ $? -ne 0 ]; then | ||
| echo -e "\n***\n*** Model Ready Check Failed (Signal $SIGNAL): Model reported ready after kill \n***" | ||
| RET=1 | ||
| else | ||
| echo "***\n Model Ready Check Passed for Signal $SIGNAL" | ||
pskiran1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fi | ||
| fi | ||
|
|
||
| set -e | ||
| kill_server | ||
| done | ||
|
|
||
| if [ $RET -eq 0 ]; then | ||
| echo -e "\n***\n*** Test Passed\n***" | ||
| else | ||
| echo -e "\n***\n*** Test FAILED\n***" | ||
| fi | ||
|
|
||
| exit $RET | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.