Skip to content

Commit 61f318b

Browse files
authored
Add test for multiple model versions (#79)
Signed-off-by: szalpal <mszolucha@nvidia.com>
1 parent 752f93f commit 61f318b

File tree

8 files changed

+275
-1
lines changed

8 files changed

+275
-1
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/usr/bin/env python
2+
3+
# The MIT License (MIT)
4+
#
5+
# Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES
6+
#
7+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
8+
# this software and associated documentation files (the "Software"), to deal in
9+
# the Software without restriction, including without limitation the rights to
10+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11+
# the Software, and to permit persons to whom the Software is furnished to do so,
12+
# subject to the following conditions:
13+
#
14+
# The above copyright notice and this permission notice shall be included in all
15+
# copies or substantial portions of the Software.
16+
#
17+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23+
24+
import argparse, os, sys
25+
import numpy as np
26+
from numpy.random import randint
27+
import tritongrpcclient
28+
from PIL import Image
29+
import math
30+
31+
32+
def parse_args():
33+
parser = argparse.ArgumentParser()
34+
parser.add_argument('-v', '--verbose', action="store_true", required=False, default=False,
35+
help='Enable verbose output')
36+
parser.add_argument('-u', '--url', type=str, required=False, default='localhost:8001',
37+
help='Inference server URL. Default is localhost:8001.')
38+
return parser.parse_args()
39+
40+
41+
42+
def main():
43+
FLAGS = parse_args()
44+
try:
45+
triton_client = tritongrpcclient.InferenceServerClient(url=FLAGS.url, verbose=FLAGS.verbose)
46+
except Exception as e:
47+
print("channel creation failed: " + str(e))
48+
sys.exit(1)
49+
50+
if not (triton_client.is_server_live() or triton_client.is_server_ready()):
51+
print("Error connecting to server: Server live {}. Server ready {}.".format(
52+
triton_client.is_server_live(), triton_client.is_server_ready()))
53+
sys.exit(1)
54+
55+
models_loaded = {
56+
"dali_all": [1, 2, 3],
57+
"dali_latest": [2, 3],
58+
"dali_specific": [2, 3],
59+
}
60+
61+
models_not_loaded = {
62+
"dali_latest": [1],
63+
"dali_specific": [1],
64+
}
65+
66+
for name, versions in models_loaded.items():
67+
for ver in versions:
68+
if not triton_client.is_model_ready(name, str(ver)):
69+
print("FAILED: Model {} version {} not ready".format(name, ver))
70+
sys.exit(1)
71+
72+
for name, versions in models_not_loaded.items():
73+
for ver in versions:
74+
if triton_client.is_model_ready(name, str(ver)):
75+
print("FAILED: Model {} version {} incorrectly loaded".format(name, ver))
76+
sys.exit(1)
77+
78+
79+
if __name__ == '__main__':
80+
main()
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
# this software and associated documentation files (the "Software"), to deal in
7+
# the Software without restriction, including without limitation the rights to
8+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
# the Software, and to permit persons to whom the Software is furnished to do so,
10+
# subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
22+
import nvidia.dali as dali
23+
24+
25+
def _parse_args():
26+
import argparse
27+
parser = argparse.ArgumentParser(description="Serialize the pipeline and save it to a file")
28+
parser.add_argument('file_path', type=str, help='The path where to save the serialized pipeline')
29+
parser.add_argument('add_value', type=int, help='Value to add to the input')
30+
return parser.parse_args()
31+
32+
33+
@dali.pipeline_def(batch_size=3, num_threads=1, device_id=0)
34+
def pipe(add_value):
35+
data = dali.fn.external_source(device="cpu", name="DALI_INPUT_0")
36+
return data + add_value
37+
38+
39+
def main(filename, add_value):
40+
pipe(add_value=add_value).serialize(filename=filename)
41+
42+
43+
if __name__ == '__main__':
44+
args = _parse_args()
45+
print(args)
46+
main(args.file_path, args.add_value)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
# this software and associated documentation files (the "Software"), to deal in
7+
# the Software without restriction, including without limitation the rights to
8+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
# the Software, and to permit persons to whom the Software is furnished to do so,
10+
# subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
22+
name: "dali_all"
23+
backend: "dali"
24+
max_batch_size: 256
25+
input [
26+
{
27+
name: "DALI_INPUT_0"
28+
data_type: TYPE_UINT8
29+
dims: [ -1 ]
30+
}
31+
]
32+
33+
output [
34+
{
35+
name: "DALI_OUTPUT_0"
36+
data_type: TYPE_UINT8
37+
dims: [ -1 ]
38+
}
39+
]
40+
41+
version_policy: { all{} }
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
# this software and associated documentation files (the "Software"), to deal in
7+
# the Software without restriction, including without limitation the rights to
8+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
# the Software, and to permit persons to whom the Software is furnished to do so,
10+
# subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
22+
name: "dali_latest"
23+
backend: "dali"
24+
max_batch_size: 256
25+
input [
26+
{
27+
name: "DALI_INPUT_0"
28+
data_type: TYPE_UINT8
29+
dims: [ -1 ]
30+
}
31+
]
32+
33+
output [
34+
{
35+
name: "DALI_OUTPUT_0"
36+
data_type: TYPE_UINT8
37+
dims: [ -1 ]
38+
}
39+
]
40+
41+
version_policy: {
42+
latest: { num_versions: 2 }
43+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
# this software and associated documentation files (the "Software"), to deal in
7+
# the Software without restriction, including without limitation the rights to
8+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
# the Software, and to permit persons to whom the Software is furnished to do so,
10+
# subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
22+
name: "dali_specific"
23+
backend: "dali"
24+
max_batch_size: 256
25+
input [
26+
{
27+
name: "DALI_INPUT_0"
28+
data_type: TYPE_UINT8
29+
dims: [ -1 ]
30+
}
31+
]
32+
33+
output [
34+
{
35+
name: "DALI_OUTPUT_0"
36+
data_type: TYPE_UINT8
37+
dims: [ -1 ]
38+
}
39+
]
40+
41+
version_policy: {
42+
specific: { versions: [2, 3] }
43+
}

qa/L0_many_versions/setup.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash -ex
2+
3+
pushd model_repository
4+
5+
for policy in all latest specific
6+
do
7+
for version in 1 2 3
8+
do
9+
mkdir -p dali_$policy/$version
10+
python addition_pipeline.py "dali_$policy/$version/model.dali" $(( version * 10 ))
11+
done
12+
done
13+
14+
echo "Many-versions model ready."
15+
16+
popd

qa/L0_many_versions/test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash -ex
2+
3+
: ${GRPC_ADDR:=${1:-"localhost:8001"}}
4+
5+
python many_versions_client.py -u $GRPC_ADDR

src/dali_model.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class DaliModel : public ::triton::backend::BackendModel {
7676
// We have the json DOM for the model configuration...
7777
common::TritonJson::WriteBuffer buffer;
7878
RETURN_IF_ERROR(model_config_.PrettyWrite(&buffer));
79-
LOG_MESSAGE(TRITONSERVER_LOG_INFO,
79+
LOG_MESSAGE(TRITONSERVER_LOG_VERBOSE,
8080
(std::string("model configuration:\n") + buffer.Contents()).c_str());
8181

8282
return nullptr; // success

0 commit comments

Comments
 (0)