Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tgerdesnv committed Mar 30, 2024
1 parent 71e7a90 commit 6b3a199
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
14 changes: 8 additions & 6 deletions tests/test_perf_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def test_perf_analyzer_config(self):

def test_perf_analyzer_boolean_args(self):
"""Test that only positive boolean args get added"""
expected_cli_str = "-m test_model --measurement-interval=1000 --binary-search --measurement-request-count=50"
expected_cli_str = "-m test_model -b 1 --measurement-interval=1000 --binary-search --measurement-request-count=50"

self.config["async"] = "False"
self.config["binary-search"] = "True"
Expand All @@ -141,15 +141,15 @@ def test_perf_analyzer_boolean_args(self):

def test_perf_analyzer_additive_args(self):
shape = ["name1:1,2,3", "name2:4,5,6"]
expected_cli_str = "-m test_model --measurement-interval=1000 --shape=name1:1,2,3 --shape=name2:4,5,6 --measurement-request-count=50"
expected_cli_str = "-m test_model -b 1 --measurement-interval=1000 --shape=name1:1,2,3 --shape=name2:4,5,6 --measurement-request-count=50"

self.config["shape"] = shape[:]

self.assertEqual(self.config["shape"], shape)
self.assertEqual(self.config.to_cli_string(), expected_cli_str)

shape = "name1:1,2,3"
expected_cli_str = "-m test_model --measurement-interval=1000 --shape=name1:1,2,3 --measurement-request-count=50"
expected_cli_str = "-m test_model -b 1 --measurement-interval=1000 --shape=name1:1,2,3 --measurement-request-count=50"
self.config["shape"] = shape

self.assertEqual(self.config.to_cli_string(), expected_cli_str)
Expand Down Expand Up @@ -177,7 +177,7 @@ def test_perf_analyzer_ssl_args(self):
ssl_https_private_key_file = "h"

expected_cli_str = (
f"-m test_model --measurement-interval=1000 --measurement-request-count=50 --ssl-grpc-use-ssl "
f"-m test_model -b 1 --measurement-interval=1000 --measurement-request-count=50 --ssl-grpc-use-ssl "
f"--ssl-grpc-root-certifications-file=a --ssl-grpc-private-key-file=b --ssl-grpc-certificate-chain-file=c "
f"--ssl-https-verify-peer=1 --ssl-https-verify-host=2 --ssl-https-ca-certificates-file=d --ssl-https-client-certificate-type=e "
f"--ssl-https-client-certificate-file=f --ssl-https-private-key-type=g --ssl-https-private-key-file=h"
Expand Down Expand Up @@ -241,7 +241,7 @@ def test_perf_analyzer_ssl_args(self):
self.config["ssl-grpc-use-ssl"] = ssl_grpc_use_ssl
self.assertEqual(self.config["ssl-grpc-use-ssl"], ssl_grpc_use_ssl)
expected_cli_str = (
f"-m test_model --measurement-interval=1000 --measurement-request-count=50 "
f"-m test_model -b 1 --measurement-interval=1000 --measurement-request-count=50 "
f"--ssl-grpc-root-certifications-file=a --ssl-grpc-private-key-file=b --ssl-grpc-certificate-chain-file=c "
f"--ssl-https-verify-peer=1 --ssl-https-verify-host=2 --ssl-https-ca-certificates-file=d --ssl-https-client-certificate-type=e "
f"--ssl-https-client-certificate-file=f --ssl-https-private-key-type=g --ssl-https-private-key-file=h"
Expand Down Expand Up @@ -651,6 +651,8 @@ def test_get_cmd_single_model(self):
"perf_analyzer",
"-m",
"test_model",
"-b",
"1",
"--measurement-interval",
"1000",
"--measurement-request-count",
Expand Down Expand Up @@ -688,7 +690,7 @@ def test_get_cmd_multi_model(self):
expected_cmd = [
'mpiexec', '--allow-run-as-root', '--tag-output',
'-n', '1', 'perf_analyzer', '--enable-mpi',
'-m', 'MultiModel1',
'-m', 'MultiModel1', '-b', '1',
'--measurement-interval', '1000',
'--measurement-request-count', '50',
':', '-n', '1', 'perf_analyzer', '--enable-mpi',
Expand Down
18 changes: 9 additions & 9 deletions tests/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,23 +179,23 @@ def _construct_results(self):
self._measurements = []
self._measurements.append(
{
"model_config_0 -m key_A": "1",
"model_config_0 -m key_B": "2",
"model_config_0 -m key_C": "3",
"model_config_0 -m key_A -b 1": "1",
"model_config_0 -m key_B -b 1": "2",
"model_config_0 -m key_C -b 1": "3",
}
)
self._measurements.append(
{
"model_config_1 -m key_D": "4",
"model_config_1 -m key_E": "5",
"model_config_1 -m key_F": "6",
"model_config_1 -m key_D -b 1": "4",
"model_config_1 -m key_E -b 1": "5",
"model_config_1 -m key_F -b 1": "6",
}
)
self._measurements.append(
{
"model_config_2 -m key_G": "7",
"model_config_2 -m key_H": "8",
"model_config_2 -m key_I": "9",
"model_config_2 -m key_G -b 1": "7",
"model_config_2 -m key_H -b 1": "8",
"model_config_2 -m key_I -b 1": "9",
}
)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_run_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_representation_mrc_removal(self):
"model1", ModelConfigVariant(MagicMock(), "model1_config_0"), pc
)

expected_representation = "model1_config_0 -m TestModel1"
expected_representation = "model1_config_0 -m TestModel1 -b 1"
self.assertEqual(mrc.representation(), expected_representation)

def test_cpu_only(self):
Expand Down

0 comments on commit 6b3a199

Please sign in to comment.