-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for multiple model versions (#79)
Signed-off-by: szalpal <[email protected]>
- Loading branch information
Showing
8 changed files
with
275 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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,80 @@ | ||
#!/usr/bin/env python | ||
|
||
# The MIT License (MIT) | ||
# | ||
# Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
# this software and associated documentation files (the "Software"), to deal in | ||
# the Software without restriction, including without limitation the rights to | ||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
# the Software, and to permit persons to whom the Software is furnished to do so, | ||
# subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
import argparse, os, sys | ||
import numpy as np | ||
from numpy.random import randint | ||
import tritongrpcclient | ||
from PIL import Image | ||
import math | ||
|
||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('-v', '--verbose', action="store_true", required=False, default=False, | ||
help='Enable verbose output') | ||
parser.add_argument('-u', '--url', type=str, required=False, default='localhost:8001', | ||
help='Inference server URL. Default is localhost:8001.') | ||
return parser.parse_args() | ||
|
||
|
||
|
||
def main(): | ||
FLAGS = parse_args() | ||
try: | ||
triton_client = tritongrpcclient.InferenceServerClient(url=FLAGS.url, verbose=FLAGS.verbose) | ||
except Exception as e: | ||
print("channel creation failed: " + str(e)) | ||
sys.exit(1) | ||
|
||
if not (triton_client.is_server_live() or triton_client.is_server_ready()): | ||
print("Error connecting to server: Server live {}. Server ready {}.".format( | ||
triton_client.is_server_live(), triton_client.is_server_ready())) | ||
sys.exit(1) | ||
|
||
models_loaded = { | ||
"dali_all": [1, 2, 3], | ||
"dali_latest": [2, 3], | ||
"dali_specific": [2, 3], | ||
} | ||
|
||
models_not_loaded = { | ||
"dali_latest": [1], | ||
"dali_specific": [1], | ||
} | ||
|
||
for name, versions in models_loaded.items(): | ||
for ver in versions: | ||
if not triton_client.is_model_ready(name, str(ver)): | ||
print("FAILED: Model {} version {} not ready".format(name, ver)) | ||
sys.exit(1) | ||
|
||
for name, versions in models_not_loaded.items(): | ||
for ver in versions: | ||
if triton_client.is_model_ready(name, str(ver)): | ||
print("FAILED: Model {} version {} incorrectly loaded".format(name, ver)) | ||
sys.exit(1) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains 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,46 @@ | ||
# The MIT License (MIT) | ||
# | ||
# Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
# this software and associated documentation files (the "Software"), to deal in | ||
# the Software without restriction, including without limitation the rights to | ||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
# the Software, and to permit persons to whom the Software is furnished to do so, | ||
# subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
import nvidia.dali as dali | ||
|
||
|
||
def _parse_args(): | ||
import argparse | ||
parser = argparse.ArgumentParser(description="Serialize the pipeline and save it to a file") | ||
parser.add_argument('file_path', type=str, help='The path where to save the serialized pipeline') | ||
parser.add_argument('add_value', type=int, help='Value to add to the input') | ||
return parser.parse_args() | ||
|
||
|
||
@dali.pipeline_def(batch_size=3, num_threads=1, device_id=0) | ||
def pipe(add_value): | ||
data = dali.fn.external_source(device="cpu", name="DALI_INPUT_0") | ||
return data + add_value | ||
|
||
|
||
def main(filename, add_value): | ||
pipe(add_value=add_value).serialize(filename=filename) | ||
|
||
|
||
if __name__ == '__main__': | ||
args = _parse_args() | ||
print(args) | ||
main(args.file_path, args.add_value) |
41 changes: 41 additions & 0 deletions
41
qa/L0_many_versions/model_repository/dali_all/config.pbtxt
This file contains 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,41 @@ | ||
# The MIT License (MIT) | ||
# | ||
# Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
# this software and associated documentation files (the "Software"), to deal in | ||
# the Software without restriction, including without limitation the rights to | ||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
# the Software, and to permit persons to whom the Software is furnished to do so, | ||
# subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
name: "dali_all" | ||
backend: "dali" | ||
max_batch_size: 256 | ||
input [ | ||
{ | ||
name: "DALI_INPUT_0" | ||
data_type: TYPE_UINT8 | ||
dims: [ -1 ] | ||
} | ||
] | ||
|
||
output [ | ||
{ | ||
name: "DALI_OUTPUT_0" | ||
data_type: TYPE_UINT8 | ||
dims: [ -1 ] | ||
} | ||
] | ||
|
||
version_policy: { all{} } |
43 changes: 43 additions & 0 deletions
43
qa/L0_many_versions/model_repository/dali_latest/config.pbtxt
This file contains 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,43 @@ | ||
# The MIT License (MIT) | ||
# | ||
# Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
# this software and associated documentation files (the "Software"), to deal in | ||
# the Software without restriction, including without limitation the rights to | ||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
# the Software, and to permit persons to whom the Software is furnished to do so, | ||
# subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
name: "dali_latest" | ||
backend: "dali" | ||
max_batch_size: 256 | ||
input [ | ||
{ | ||
name: "DALI_INPUT_0" | ||
data_type: TYPE_UINT8 | ||
dims: [ -1 ] | ||
} | ||
] | ||
|
||
output [ | ||
{ | ||
name: "DALI_OUTPUT_0" | ||
data_type: TYPE_UINT8 | ||
dims: [ -1 ] | ||
} | ||
] | ||
|
||
version_policy: { | ||
latest: { num_versions: 2 } | ||
} |
43 changes: 43 additions & 0 deletions
43
qa/L0_many_versions/model_repository/dali_specific/config.pbtxt
This file contains 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,43 @@ | ||
# The MIT License (MIT) | ||
# | ||
# Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
# this software and associated documentation files (the "Software"), to deal in | ||
# the Software without restriction, including without limitation the rights to | ||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
# the Software, and to permit persons to whom the Software is furnished to do so, | ||
# subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
name: "dali_specific" | ||
backend: "dali" | ||
max_batch_size: 256 | ||
input [ | ||
{ | ||
name: "DALI_INPUT_0" | ||
data_type: TYPE_UINT8 | ||
dims: [ -1 ] | ||
} | ||
] | ||
|
||
output [ | ||
{ | ||
name: "DALI_OUTPUT_0" | ||
data_type: TYPE_UINT8 | ||
dims: [ -1 ] | ||
} | ||
] | ||
|
||
version_policy: { | ||
specific: { versions: [2, 3] } | ||
} |
This file contains 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,16 @@ | ||
#!/bin/bash -ex | ||
|
||
pushd model_repository | ||
|
||
for policy in all latest specific | ||
do | ||
for version in 1 2 3 | ||
do | ||
mkdir -p dali_$policy/$version | ||
python addition_pipeline.py "dali_$policy/$version/model.dali" $(( version * 10 )) | ||
done | ||
done | ||
|
||
echo "Many-versions model ready." | ||
|
||
popd |
This file contains 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,5 @@ | ||
#!/bin/bash -ex | ||
|
||
: ${GRPC_ADDR:=${1:-"localhost:8001"}} | ||
|
||
python many_versions_client.py -u $GRPC_ADDR |
This file contains 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