Skip to content
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

Run CPU-only unit tests automatically for pull requests #873

Merged
merged 7 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/python-package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright 2024, 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.

# This workflow will install Python dependencies and run unit tests.
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package

on:
pull_request:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-22.04"]
python-version: ["3.8", "3.11"]
env:
SKIP_GPU_TESTS: 1

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e .
- name: Test with unittest
run: |
pip install unittest-parallel
python3 -m unittest_parallel -v -s ./tests -t .
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,6 @@ MigrationBackup/

# Fody - auto-generated XML schema
FodyWeavers.xsd

# Files generated by linters
.mypy_cache/
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ docker>=4.3.1
gevent>=22.08.0
grpcio>=1.41.0
httplib2>=0.19.0
importlib_metadata>=7.1.0
matplotlib>=3.3.4
numba>=0.51.2
pdfkit>=0.6.1
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ def get_tag(self):
"Topic :: Utilities",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Environment :: Console",
"Natural Language :: English",
"Operating System :: POSIX :: Linux",
Expand Down
4 changes: 4 additions & 0 deletions tests/test_model_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ def test_write_config_to_file_with_relative_path(self, mock_os_symlink, *args):

def test_instance_group_string(self):
"""Test out all corner cases of instance_group_string()"""
if os.getenv("SKIP_GPU_TESTS"):
self.skipTest("Skipping this test as it requires GPU")

def _test_helper(config_dict, expected_result, gpu_count=None):
model_config = ModelConfig.create_from_dictionary(config_dict)
Expand Down Expand Up @@ -318,6 +320,8 @@ def _test_helper(config_dict, expected_result, gpu_count=None):

def test_instance_group_count(self):
"""Test out all corner cases of instance_group_count()"""
if os.getenv("SKIP_GPU_TESTS"):
self.skipTest("Skipping this test as it requires GPU")

def _test_helper(config_dict, expected_result, gpu_count=None):
model_config = ModelConfig.create_from_dictionary(config_dict)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_parameter_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def _create_single_model_no_constraints(self):

def _create_single_model_with_constraints(
self, latency_budget: str
) -> Union[ConfigCommandProfile | ConfigCommandReport]:
) -> Union[ConfigCommandProfile, ConfigCommandReport]:
args = [
"model-analyzer",
"profile",
Expand Down
3 changes: 3 additions & 0 deletions tests/test_result_table_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import unittest
from filecmp import cmp
from shutil import rmtree
Expand Down Expand Up @@ -79,6 +80,8 @@ def test_multi_model_csv_against_golden(self):
Match the csvs against the golden versions in
tests/common/multi-model-ckpt
"""
if os.getenv("SKIP_GPU_TESTS"):
self.skipTest("Skipping this test as it requires GPU")
table_manager = self._create_multi_model_result_table_manager()

table_manager.create_tables()
Expand Down
Loading