From cc65abde0322acca870579dd3fdc56909620ae4a Mon Sep 17 00:00:00 2001 From: David Yastremsky Date: Mon, 26 Feb 2024 11:59:09 -0800 Subject: [PATCH 1/4] Copy over unittest files --- .../temp/qa/L0_unit_tests/count_tests.py | 57 + .../temp/qa/L0_unit_tests/test.sh | 50 + .../temp/qa/common/check_analyzer_results.sh | 115 + .../temp/qa/common/check_copyright.py | 239 + src/c++/perf_analyzer/temp/qa/common/util.sh | 341 + src/c++/perf_analyzer/tests/__init__.py | 15 + .../tests/common/bls-ckpt/0.ckpt | 17358 ++++++++++++++++ .../tests/common/bls-ckpt/README | 15 + .../bls-ckpt/golden-metrics-model-gpu.csv | 28 + .../golden-metrics-model-inference.csv | 55 + .../bls-ckpt/golden-metrics-server-only.csv | 3 + .../tests/common/ensemble-ckpt/0.ckpt | 7257 +++++++ .../tests/common/ensemble-ckpt/README | 15 + .../golden-metrics-model-gpu.csv | 23 + .../golden-metrics-model-inference.csv | 23 + .../golden-metrics-server-only.csv | 3 + .../tests/common/multi-model-ckpt/0.ckpt | 7767 +++++++ .../tests/common/multi-model-ckpt/README | 19 + .../golden-metrics-model-gpu.csv | 14 + .../golden-metrics-model-inference.csv | 14 + .../golden-metrics-server-only.csv | 3 + .../common/multi-model-ckpt/plot_manager.json | 1 + .../tests/common/request-rate-ckpt/0.ckpt | 11428 ++++++++++ .../tests/common/request-rate-ckpt/README | 21 + .../golden-metrics-model-gpu.csv | 36 + .../golden-metrics-model-inference.csv | 36 + .../golden-metrics-server-only.csv | 3 + .../tests/common/single-model-ckpt/0.ckpt | 5350 +++++ .../tests/common/single-model-ckpt/README | 22 + .../golden-metrics-model-gpu.csv | 18 + .../golden-metrics-model-inference.csv | 18 + .../golden-metrics-server-only.csv | 3 + .../single-model-ckpt/plot_manager.json | 1 + .../tests/common/test_result_collector.py | 47 + .../perf_analyzer/tests/common/test_utils.py | 525 + src/c++/perf_analyzer/tests/mocks/__init__.py | 15 + .../tests/mocks/mock_api_error.py | 24 + .../perf_analyzer/tests/mocks/mock_base.py | 38 + .../perf_analyzer/tests/mocks/mock_client.py | 221 + .../perf_analyzer/tests/mocks/mock_config.py | 36 + .../perf_analyzer/tests/mocks/mock_dcgm.py | 55 + .../tests/mocks/mock_dcgm_agent.py | 197 + .../mocks/mock_dcgm_field_group_watcher.py | 94 + .../perf_analyzer/tests/mocks/mock_glob.py | 54 + .../tests/mocks/mock_gpu_device_factory.py | 34 + src/c++/perf_analyzer/tests/mocks/mock_io.py | 105 + .../perf_analyzer/tests/mocks/mock_json.py | 61 + .../tests/mocks/mock_matplotlib.py | 71 + .../tests/mocks/mock_model_config.py | 49 + .../perf_analyzer/tests/mocks/mock_numba.py | 66 + src/c++/perf_analyzer/tests/mocks/mock_os.py | 91 + .../tests/mocks/mock_perf_analyzer.py | 104 + .../perf_analyzer/tests/mocks/mock_psutil.py | 35 + .../tests/mocks/mock_requests.py | 54 + .../tests/mocks/mock_run_configs.py | 144 + .../perf_analyzer/tests/mocks/mock_server.py | 46 + .../tests/mocks/mock_server_docker.py | 179 + .../tests/mocks/mock_server_local.py | 131 + src/c++/perf_analyzer/tests/test_analyzer.py | 241 + .../tests/test_bls_report_manager.py | 172 + src/c++/perf_analyzer/tests/test_cli.py | 604 + src/c++/perf_analyzer/tests/test_config.py | 2382 +++ .../tests/test_constraint_manager.py | 620 + .../perf_analyzer/tests/test_coordinate.py | 138 + .../tests/test_coordinate_data.py | 123 + .../perf_analyzer/tests/test_cpu_monitor.py | 111 + .../perf_analyzer/tests/test_dcgm_monitor.py | 155 + .../tests/test_ensemble_report_manager.py | 178 + .../perf_analyzer/tests/test_file_writer.py | 67 + .../perf_analyzer/tests/test_html_report.py | 167 + src/c++/perf_analyzer/tests/test_logger.py | 175 + .../perf_analyzer/tests/test_model_config.py | 472 + .../tests/test_model_config_generator.py | 927 + .../tests/test_model_config_measurement.py | 242 + .../tests/test_model_constraints.py | 119 + .../perf_analyzer/tests/test_model_manager.py | 1319 ++ .../tests/test_model_variant_name_manager.py | 266 + .../perf_analyzer/tests/test_neighborhood.py | 916 + .../tests/test_parameter_search.py | 336 + .../perf_analyzer/tests/test_pdf_report.py | 61 + .../perf_analyzer/tests/test_perf_analyzer.py | 873 + .../test_perf_analyzer_config_generator.py | 842 + src/c++/perf_analyzer/tests/test_plot.py | 131 + .../perf_analyzer/tests/test_plot_manager.py | 196 + .../tests/test_quick_run_config_generator.py | 1359 ++ .../tests/test_record_aggregator.py | 175 + .../perf_analyzer/tests/test_record_types.py | 191 + .../tests/test_remote_monitor.py | 174 + .../tests/test_report_manager.py | 642 + .../perf_analyzer/tests/test_report_utils.py | 60 + .../tests/test_result_manager.py | 199 + .../perf_analyzer/tests/test_result_table.py | 121 + .../tests/test_result_table_manager.py | 344 + src/c++/perf_analyzer/tests/test_results.py | 248 + .../perf_analyzer/tests/test_run_config.py | 212 + .../tests/test_run_config_generator.py | 729 + .../tests/test_run_config_measurement.py | 739 + .../tests/test_run_config_result.py | 341 + .../test_run_config_result_comparator.py | 258 + .../perf_analyzer/tests/test_search_config.py | 88 + .../tests/test_search_dimension.py | 53 + .../tests/test_search_dimensions.py | 79 + .../tests/test_sorted_results.py | 306 + .../perf_analyzer/tests/test_state_manager.py | 148 + .../perf_analyzer/tests/test_triton_client.py | 214 + .../perf_analyzer/tests/test_triton_server.py | 361 + .../tests/test_triton_server_factory.py | 126 + .../perf_analyzer/tests/test_yaml_options.py | 117 + 108 files changed, 71944 insertions(+) create mode 100755 src/c++/perf_analyzer/temp/qa/L0_unit_tests/count_tests.py create mode 100755 src/c++/perf_analyzer/temp/qa/L0_unit_tests/test.sh create mode 100755 src/c++/perf_analyzer/temp/qa/common/check_analyzer_results.sh create mode 100755 src/c++/perf_analyzer/temp/qa/common/check_copyright.py create mode 100755 src/c++/perf_analyzer/temp/qa/common/util.sh create mode 100755 src/c++/perf_analyzer/tests/__init__.py create mode 100644 src/c++/perf_analyzer/tests/common/bls-ckpt/0.ckpt create mode 100644 src/c++/perf_analyzer/tests/common/bls-ckpt/README create mode 100644 src/c++/perf_analyzer/tests/common/bls-ckpt/golden-metrics-model-gpu.csv create mode 100644 src/c++/perf_analyzer/tests/common/bls-ckpt/golden-metrics-model-inference.csv create mode 100644 src/c++/perf_analyzer/tests/common/bls-ckpt/golden-metrics-server-only.csv create mode 100644 src/c++/perf_analyzer/tests/common/ensemble-ckpt/0.ckpt create mode 100644 src/c++/perf_analyzer/tests/common/ensemble-ckpt/README create mode 100644 src/c++/perf_analyzer/tests/common/ensemble-ckpt/golden-metrics-model-gpu.csv create mode 100644 src/c++/perf_analyzer/tests/common/ensemble-ckpt/golden-metrics-model-inference.csv create mode 100644 src/c++/perf_analyzer/tests/common/ensemble-ckpt/golden-metrics-server-only.csv create mode 100644 src/c++/perf_analyzer/tests/common/multi-model-ckpt/0.ckpt create mode 100644 src/c++/perf_analyzer/tests/common/multi-model-ckpt/README create mode 100644 src/c++/perf_analyzer/tests/common/multi-model-ckpt/golden-metrics-model-gpu.csv create mode 100644 src/c++/perf_analyzer/tests/common/multi-model-ckpt/golden-metrics-model-inference.csv create mode 100644 src/c++/perf_analyzer/tests/common/multi-model-ckpt/golden-metrics-server-only.csv create mode 100644 src/c++/perf_analyzer/tests/common/multi-model-ckpt/plot_manager.json create mode 100644 src/c++/perf_analyzer/tests/common/request-rate-ckpt/0.ckpt create mode 100644 src/c++/perf_analyzer/tests/common/request-rate-ckpt/README create mode 100644 src/c++/perf_analyzer/tests/common/request-rate-ckpt/golden-metrics-model-gpu.csv create mode 100644 src/c++/perf_analyzer/tests/common/request-rate-ckpt/golden-metrics-model-inference.csv create mode 100644 src/c++/perf_analyzer/tests/common/request-rate-ckpt/golden-metrics-server-only.csv create mode 100644 src/c++/perf_analyzer/tests/common/single-model-ckpt/0.ckpt create mode 100644 src/c++/perf_analyzer/tests/common/single-model-ckpt/README create mode 100644 src/c++/perf_analyzer/tests/common/single-model-ckpt/golden-metrics-model-gpu.csv create mode 100644 src/c++/perf_analyzer/tests/common/single-model-ckpt/golden-metrics-model-inference.csv create mode 100644 src/c++/perf_analyzer/tests/common/single-model-ckpt/golden-metrics-server-only.csv create mode 100644 src/c++/perf_analyzer/tests/common/single-model-ckpt/plot_manager.json create mode 100755 src/c++/perf_analyzer/tests/common/test_result_collector.py create mode 100755 src/c++/perf_analyzer/tests/common/test_utils.py create mode 100755 src/c++/perf_analyzer/tests/mocks/__init__.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_api_error.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_base.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_client.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_config.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_dcgm.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_dcgm_agent.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_dcgm_field_group_watcher.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_glob.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_gpu_device_factory.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_io.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_json.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_matplotlib.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_model_config.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_numba.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_os.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_perf_analyzer.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_psutil.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_requests.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_run_configs.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_server.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_server_docker.py create mode 100755 src/c++/perf_analyzer/tests/mocks/mock_server_local.py create mode 100755 src/c++/perf_analyzer/tests/test_analyzer.py create mode 100755 src/c++/perf_analyzer/tests/test_bls_report_manager.py create mode 100755 src/c++/perf_analyzer/tests/test_cli.py create mode 100755 src/c++/perf_analyzer/tests/test_config.py create mode 100755 src/c++/perf_analyzer/tests/test_constraint_manager.py create mode 100755 src/c++/perf_analyzer/tests/test_coordinate.py create mode 100755 src/c++/perf_analyzer/tests/test_coordinate_data.py create mode 100755 src/c++/perf_analyzer/tests/test_cpu_monitor.py create mode 100755 src/c++/perf_analyzer/tests/test_dcgm_monitor.py create mode 100755 src/c++/perf_analyzer/tests/test_ensemble_report_manager.py create mode 100755 src/c++/perf_analyzer/tests/test_file_writer.py create mode 100755 src/c++/perf_analyzer/tests/test_html_report.py create mode 100755 src/c++/perf_analyzer/tests/test_logger.py create mode 100755 src/c++/perf_analyzer/tests/test_model_config.py create mode 100755 src/c++/perf_analyzer/tests/test_model_config_generator.py create mode 100755 src/c++/perf_analyzer/tests/test_model_config_measurement.py create mode 100755 src/c++/perf_analyzer/tests/test_model_constraints.py create mode 100755 src/c++/perf_analyzer/tests/test_model_manager.py create mode 100755 src/c++/perf_analyzer/tests/test_model_variant_name_manager.py create mode 100755 src/c++/perf_analyzer/tests/test_neighborhood.py create mode 100755 src/c++/perf_analyzer/tests/test_parameter_search.py create mode 100755 src/c++/perf_analyzer/tests/test_pdf_report.py create mode 100755 src/c++/perf_analyzer/tests/test_perf_analyzer.py create mode 100755 src/c++/perf_analyzer/tests/test_perf_analyzer_config_generator.py create mode 100755 src/c++/perf_analyzer/tests/test_plot.py create mode 100755 src/c++/perf_analyzer/tests/test_plot_manager.py create mode 100755 src/c++/perf_analyzer/tests/test_quick_run_config_generator.py create mode 100755 src/c++/perf_analyzer/tests/test_record_aggregator.py create mode 100755 src/c++/perf_analyzer/tests/test_record_types.py create mode 100755 src/c++/perf_analyzer/tests/test_remote_monitor.py create mode 100755 src/c++/perf_analyzer/tests/test_report_manager.py create mode 100755 src/c++/perf_analyzer/tests/test_report_utils.py create mode 100755 src/c++/perf_analyzer/tests/test_result_manager.py create mode 100755 src/c++/perf_analyzer/tests/test_result_table.py create mode 100755 src/c++/perf_analyzer/tests/test_result_table_manager.py create mode 100755 src/c++/perf_analyzer/tests/test_results.py create mode 100755 src/c++/perf_analyzer/tests/test_run_config.py create mode 100755 src/c++/perf_analyzer/tests/test_run_config_generator.py create mode 100755 src/c++/perf_analyzer/tests/test_run_config_measurement.py create mode 100755 src/c++/perf_analyzer/tests/test_run_config_result.py create mode 100755 src/c++/perf_analyzer/tests/test_run_config_result_comparator.py create mode 100755 src/c++/perf_analyzer/tests/test_search_config.py create mode 100755 src/c++/perf_analyzer/tests/test_search_dimension.py create mode 100755 src/c++/perf_analyzer/tests/test_search_dimensions.py create mode 100755 src/c++/perf_analyzer/tests/test_sorted_results.py create mode 100755 src/c++/perf_analyzer/tests/test_state_manager.py create mode 100755 src/c++/perf_analyzer/tests/test_triton_client.py create mode 100755 src/c++/perf_analyzer/tests/test_triton_server.py create mode 100755 src/c++/perf_analyzer/tests/test_triton_server_factory.py create mode 100755 src/c++/perf_analyzer/tests/test_yaml_options.py diff --git a/src/c++/perf_analyzer/temp/qa/L0_unit_tests/count_tests.py b/src/c++/perf_analyzer/temp/qa/L0_unit_tests/count_tests.py new file mode 100755 index 000000000..d8bf8315d --- /dev/null +++ b/src/c++/perf_analyzer/temp/qa/L0_unit_tests/count_tests.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 + +# Copyright 2020-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import argparse +import importlib +import inspect +import os +import sys + +sys.path.insert(0, "../../") + + +def args(): + parser = argparse.ArgumentParser("test_counter") + parser.add_argument("--path", help="Path to use for counting the tests", type=str) + opt = parser.parse_args() + return opt + + +if __name__ == "__main__": + number_of_tests = 0 + opt = args() + path = opt.path + + for file_path in os.listdir(path): + # All the test files start with "Test" + if file_path.startswith("test_"): + module_name = "tests." + file_path.split(".")[0] + module = importlib.import_module(module_name) + classes = inspect.getmembers(module, inspect.isclass) + for class_tuple in classes: + class_name = class_tuple[0] + class_object = class_tuple[1] + + # All the test classes start with "Test" + if class_name.startswith("Test"): + methods = inspect.getmembers(class_object, inspect.isroutine) + for method_tuple in methods: + method_name = method_tuple[0] + if method_name.startswith("test_"): + number_of_tests += 1 + + # Print the number of tests + print(number_of_tests) diff --git a/src/c++/perf_analyzer/temp/qa/L0_unit_tests/test.sh b/src/c++/perf_analyzer/temp/qa/L0_unit_tests/test.sh new file mode 100755 index 000000000..b664ea1d4 --- /dev/null +++ b/src/c++/perf_analyzer/temp/qa/L0_unit_tests/test.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# Copyright (c) 2020-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +EXPECTED_NUM_TESTS=`python3 count_tests.py --path ../../tests/` +source ../common/check_analyzer_results.sh +source ../common/util.sh + +create_logs_dir "L0_unit_tests" +create_result_paths -export-path false -checkpoints false + +RET=0 + +set +e +coverage run --branch --source=../../model_analyzer -m unittest discover -v -s ../../tests -t ../../ > $ANALYZER_LOG 2>&1 +if [ $? -ne 0 ]; then + RET=1 +else + check_unit_test_results $ANALYZER_LOG $EXPECTED_NUM_TESTS + if [ $? -ne 0 ]; then + cat $ANALYZER_LOG + echo -e "\n***\n*** Test Result Verification Failed\n***" + RET=1 + fi +fi +set -e + +if [ $RET -eq 0 ]; then + echo -e "\n***\n*** Test PASSED\n***" +else + cat $ANALYZER_LOG + echo -e "\n***\n*** Test FAILED\n***" +fi + +# Generate html files +echo `pwd` +coverage html --directory $LOGS_DIR/html/ + +exit $RET diff --git a/src/c++/perf_analyzer/temp/qa/common/check_analyzer_results.sh b/src/c++/perf_analyzer/temp/qa/common/check_analyzer_results.sh new file mode 100755 index 000000000..79bc782d1 --- /dev/null +++ b/src/c++/perf_analyzer/temp/qa/common/check_analyzer_results.sh @@ -0,0 +1,115 @@ +#!/bin/bash +# Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +source ../common/util.sh + +# Check Python unittest results. +function check_unit_test_results () { + local log_file=$1 + local expected_num_tests=$2 + + if [[ -z "$expected_num_tests" ]]; then + echo "=== expected number of tests must be defined" + return 1 + fi + + local num_failures=`cat $log_file | grep -E ".*total.*errors.*failures.*" | tail -n 1 | jq .failures` + local num_tests=`cat $log_file | grep -E ".*total.*errors.*failures.*" | tail -n 1 | jq .total` + local num_errors=`cat $log_file | grep -E ".*total.*errors.*failures.*" | tail -n 1 | jq .errors` + + # Number regular expression + re='^[0-9]+$' + + if [[ $? -ne 0 ]] || ! [[ $num_failures =~ $re ]] || ! [[ $num_tests =~ $re ]] || \ + ! [[ $num_errors =~ $re ]]; then + cat $log_file + echo -e "\n***\n*** Test Failed: unable to parse test results\n***" >> $log_file + return 1 + fi + if [[ $num_errors != "0" ]] || [[ $num_failures != "0" ]] || [[ $num_tests -ne $expected_num_tests ]]; then + cat $log_file + echo -e "\n***\n*** Test Failed: Expected $expected_num_tests test(s), $num_tests test(s) executed, $num_errors test(s) had error, and $num_failures test(s) failed. \n***" >> $log_file + return 1 + fi + + return 0 +} + +# Check the table(s) by calling check_log_table_row_column and check_csv_table_row_column +# See if the logic generalizes to the specify testing needs +# Call check_log_table_row_column and check_csv_table_row_column in util.sh directly if not +function check_table_row_column() { + local inference_log_file=$1 + local gpu_log_file=$2 + local server_log_file=$3 + local inference_csv_file=$4 + local gpu_csv_file=$5 + local server_csv_file=$6 + + local inference_expected_num_columns=$7 + local inference_expected_num_rows=$8 + local gpu_expected_num_columns=$9 + local gpu_expected_num_rows=${10} + local server_expected_num_columns=${11} + local server_expected_num_rows=${12} + + local ret=0 + + if [ "$inference_log_file" != "" ]; then + check_log_table_row_column $inference_log_file $inference_expected_num_columns $inference_expected_num_rows "Models\ \(Inference\):" + if [ $? -ne 0 ]; then + echo -e "\n***\n*** Test Output Verification Failed for $inference_log_file.\n***" + ret=1 + fi + fi + if [ "$gpu_log_file" != "" ]; then + check_log_table_row_column $gpu_log_file $gpu_expected_num_columns $gpu_expected_num_rows "Models\ \(GPU\ Metrics\):" + if [ $? -ne 0 ]; then + echo -e "\n***\n*** Test Output Verification Failed for $gpu_log_file.\n***" + ret=1 + fi + fi + if [ "$server_log_file" != "" ]; then + check_log_table_row_column $server_log_file $server_expected_num_columns $server_expected_num_rows "Server\ Only:" + if [ $? -ne 0 ]; then + echo -e "\n***\n*** Test Output Verification Failed for $server_log_file.\n***" + ret=1 + fi + fi + + if [ "$inference_csv_file" != "" ]; then + check_csv_table_row_column $inference_csv_file $inference_expected_num_columns $inference_expected_num_rows "Model" + if [ $? -ne 0 ]; then + echo -e "\n***\n*** Test Output Verification Failed for $inference_csv_file.\n***" + ret=1 + fi + fi + if [ "$gpu_csv_file" != "" ]; then + check_csv_table_row_column $gpu_csv_file $gpu_expected_num_columns $gpu_expected_num_rows "Model" + if [ $? -ne 0 ]; then + echo -e "\n***\n*** Test Output Verification Failed for $gpu_csv_file.\n***" + ret=1 + fi + fi + if [ "$server_csv_file" != "" ]; then + check_csv_table_row_column $server_csv_file $server_expected_num_columns $server_expected_num_rows "Model" + if [ $? -ne 0 ]; then + echo -e "\n***\n*** Test Output Verification Failed for $server_csv_file.\n***" + ret=1 + fi + fi + + return $ret +} diff --git a/src/c++/perf_analyzer/temp/qa/common/check_copyright.py b/src/c++/perf_analyzer/temp/qa/common/check_copyright.py new file mode 100755 index 000000000..89c341512 --- /dev/null +++ b/src/c++/perf_analyzer/temp/qa/common/check_copyright.py @@ -0,0 +1,239 @@ +#!/usr/bin/env python3 + +# Copyright 2020-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import argparse +import os +import pathlib +import re + +FLAGS = None +SKIP_EXTS = ("pt", "log", "png", "pdf", "ckpt", "csv", "json") + +REPO_PATH_FROM_THIS_FILE = "../.." +SKIP_PATHS = (".git", "VERSION", "LICENSE") + +COPYRIGHT_YEAR_RE = "Copyright( \\(c\\))? 20[1-9][0-9](-(20)?[1-9][0-9])?(,((20[2-9][0-9](-(20)?[2-9][0-9])?)|([2-9][0-9](-[2-9][0-9])?)))*,? NVIDIA CORPORATION( & AFFILIATES)?. All rights reserved." + +COPYRIGHT = """ + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +""" + +repo_abs_path = ( + pathlib.Path(__file__).parent.joinpath(REPO_PATH_FROM_THIS_FILE).resolve() +) + +copyright_year_re = re.compile(COPYRIGHT_YEAR_RE) + + +def visit(path): + if FLAGS.verbose: + print("visiting " + path) + + for skip in SKIP_EXTS: + if path.endswith("." + skip): + if FLAGS.verbose: + print("skipping due to extension: " + path) + return True + + for skip in SKIP_PATHS: + if str(pathlib.Path(path).resolve()).startswith( + str(repo_abs_path.joinpath(skip).resolve()) + ): + if FLAGS.verbose: + print("skipping due to path prefix: " + path) + return True + + with open(path, "r") as f: + first_line = True + line = None + try: + for fline in f: + line = fline + + # Skip any '#!', '..', '