Skip to content

Commit 2847211

Browse files
Add GitHub action to format and lint code (#6022)
* Add pre-commit * Fix typos, exec/shebang, formatting * Remove clang-format * Update contributing md to include pre-commit * Update spacing in CONTRIBUTING * Fix contributing pre-commit link * Link to pre-commit install directions * Wording * Restore clang-format * Fix yaml spacing * Exclude templates folder for check-yaml * Remove unused vars * Normalize spacing * Remove unused variable * Normalize config indentation * Update .clang-format to enforce max line length of 80 * Update copyrights * Update copyrights * Run workflows on every PR * Fix copyright year * Fix grammar * Entrypoint.d files are not executable * Run pre-commit hooks * Mark not executable * Run pre-commit hooks * Remove unused variable * Run pre-commit hooks after rebase * Update copyrights * Fix README.md typo (decoupled) Co-authored-by: Ryan McCormick <[email protected]> * Run pre-commit hooks * Grammar fix Co-authored-by: Ryan McCormick <[email protected]> * Redundant word Co-authored-by: Ryan McCormick <[email protected]> * Revert docker file changes * Executable shebang revert * Make model.py files non-executable * Passin is proper flag * Run pre-commit hooks on init_args/model.py * Fix typo in init_args/model.py * Make copyrights one line --------- Co-authored-by: Ryan McCormick <[email protected]>
1 parent 00fee98 commit 2847211

File tree

461 files changed

+26817
-20332
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

461 files changed

+26817
-20332
lines changed

.clang-format

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
BasedOnStyle: Google
33

44
IndentWidth: 2
5+
ColumnLimit: 80
56
ContinuationIndentWidth: 4
67
UseTab: Never
78
MaxEmptyLinesToKeep: 2
@@ -34,4 +35,5 @@ BinPackArguments: true
3435
BinPackParameters: true
3536
ConstructorInitializerAllOnOneLineOrOnePerLine: false
3637

37-
IndentCaseLabels: true
38+
IndentCaseLabels: true
39+

.github/workflows/codeql.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@
2727
name: "CodeQL"
2828

2929
on:
30-
push:
31-
branches: [ 'main' ]
3230
pull_request:
33-
# The branches below must be a subset of the branches above
34-
branches: [ 'main' ]
35-
schedule:
36-
- cron: '0 1 * * 1-6'
3731

3832
jobs:
3933
analyze:
@@ -63,12 +57,12 @@ jobs:
6357
# If you wish to specify custom queries, you can do so here or in a config file.
6458
# By default, queries listed here will override any specified in a config file.
6559
# Prefix the list here with "+" to use these queries and those in the config file.
66-
60+
6761
# Details on CodeQL's query packs refer to:
6862
# https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
6963
queries: +security-and-quality
7064

71-
65+
7266
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
7367
# If this step fails, then you should remove it and run the build manually (see below)
7468
- name: Autobuild
@@ -77,7 +71,7 @@ jobs:
7771
# Command-line programs to run using the OS shell.
7872
# See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
7973

80-
# If the Autobuild fails above, remove it and uncomment the following three lines.
74+
# If the Autobuild fails above, remove it and uncomment the following three lines.
8175
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
8276

8377
# - run: |

.github/workflows/pre-commit.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# Redistribution and use in source and binary forms, with or without
4+
# modification, are permitted provided that the following conditions
5+
# are met:
6+
# * Redistributions of source code must retain the above copyright
7+
# notice, this list of conditions and the following disclaimer.
8+
# * Redistributions in binary form must reproduce the above copyright
9+
# notice, this list of conditions and the following disclaimer in the
10+
# documentation and/or other materials provided with the distribution.
11+
# * Neither the name of NVIDIA CORPORATION nor the names of its
12+
# contributors may be used to endorse or promote products derived
13+
# from this software without specific prior written permission.
14+
#
15+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
16+
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23+
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
27+
name: pre-commit
28+
29+
on:
30+
pull_request:
31+
32+
jobs:
33+
pre-commit:
34+
runs-on: ubuntu-22.04
35+
steps:
36+
- uses: actions/checkout@v3
37+
- uses: actions/setup-python@v3
38+
- uses: pre-commit/[email protected]
39+

.pre-commit-config.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Copyright 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# Redistribution and use in source and binary forms, with or without
4+
# modification, are permitted provided that the following conditions
5+
# are met:
6+
# * Redistributions of source code must retain the above copyright
7+
# notice, this list of conditions and the following disclaimer.
8+
# * Redistributions in binary form must reproduce the above copyright
9+
# notice, this list of conditions and the following disclaimer in the
10+
# documentation and/or other materials provided with the distribution.
11+
# * Neither the name of NVIDIA CORPORATION nor the names of its
12+
# contributors may be used to endorse or promote products derived
13+
# from this software without specific prior written permission.
14+
#
15+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
16+
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23+
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
27+
repos:
28+
- repo: https://github.com/timothycrosley/isort
29+
rev: 5.12.0
30+
hooks:
31+
- id: isort
32+
additional_dependencies: [toml]
33+
- repo: https://github.com/psf/black
34+
rev: 23.1.0
35+
hooks:
36+
- id: black
37+
types_or: [python, cython]
38+
- repo: https://github.com/PyCQA/flake8
39+
rev: 5.0.4
40+
hooks:
41+
- id: flake8
42+
args: [--max-line-length=88, --select=C,E,F,W,B,B950, --extend-ignore = E203,E501]
43+
types_or: [python, cython]
44+
- repo: https://github.com/pre-commit/mirrors-clang-format
45+
rev: v16.0.5
46+
hooks:
47+
- id: clang-format
48+
types_or: [c, c++, cuda, proto, textproto, java]
49+
args: ["-fallback-style=none", "-style=file", "-i"]
50+
- repo: https://github.com/codespell-project/codespell
51+
rev: v2.2.4
52+
hooks:
53+
- id: codespell
54+
additional_dependencies: [tomli]
55+
args: ["--toml", "pyproject.toml"]
56+
exclude: (?x)^(.*stemmer.*|.*stop_words.*|^CHANGELOG.md$)
57+
# More details about these pre-commit hooks here:
58+
# https://pre-commit.com/hooks.html
59+
- repo: https://github.com/pre-commit/pre-commit-hooks
60+
rev: v4.4.0
61+
hooks:
62+
- id: check-case-conflict
63+
- id: check-executables-have-shebangs
64+
- id: check-merge-conflict
65+
- id: check-json
66+
- id: check-toml
67+
- id: check-yaml
68+
exclude: ^deploy(\/[^\/]+)*\/templates\/.*$
69+
- id: check-shebang-scripts-are-executable
70+
- id: end-of-file-fixer
71+
types_or: [c, c++, cuda, proto, textproto, java, python]
72+
- id: mixed-line-ending
73+
- id: requirements-txt-fixer
74+
- id: trailing-whitespace

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ if(EXISTS "/etc/os-release")
130130
set (LIB_DIR "lib64")
131131
endif()
132132
endif()
133-
133+
134134
set(TRITON_CORE_HEADERS_ONLY OFF)
135135

136136
FetchContent_MakeAvailable(repo-third-party repo-core)

CONTRIBUTING.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
# Copyright 2018-2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# Copyright 2018-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
33
#
44
# Redistribution and use in source and binary forms, with or without
55
# modification, are permitted provided that the following conditions
@@ -103,21 +103,19 @@ proposed change so that the Triton team can provide feedback.
103103

104104
# Coding Convention
105105

106-
Use clang-format to format all source files (\*.h, \*.cc, \*.proto,
107-
*.py) to a consistent format. You should run clang-format on all
108-
source files before submitting a pull request:
109-
110-
```
111-
$ apt-get install clang-format-15
112-
```
113-
114-
For convenience there is a format.py script in the
115-
triton-inference-server/common repo in the "tools" directory that can
116-
be used to clang-format all files within the repo:
117-
118-
```
119-
$ python3 ../common/tools/format.py *
120-
```
106+
All pull requests are checked against the
107+
[pre-commit hooks](https://github.com/pre-commit/pre-commit-hooks)
108+
located [in the repository's top-level .pre-commit-config.yaml](https://github.com/NVIDIA/triton-inference-server/blob/master/pre-commit-config.yaml).
109+
The hooks do some sanity checking like linting and formatting.
110+
These checks must pass to merge a change.
111+
112+
To run these locally, you can
113+
[install pre-commit,](https://pre-commit.com/#install)
114+
then run `pre-commit install` inside the cloned repo. When you
115+
commit a change, the pre-commit hooks will run automatically.
116+
If a fix is implemented by a pre-commit hook, adding the file again
117+
and running `git commit` a second time will pass and successfully
118+
commit.
121119

122120
# Contributor License Agreement (CLA)
123121

Dockerfile.QA

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ RUN apt update && apt install -y gpg wget && \
7070
echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $UBUNTU_CODENAME main" | \
7171
tee /etc/apt/sources.list.d/kitware.list >/dev/null && \
7272
apt-get update && \
73-
apt-get install -y --no-install-recommends cmake cmake-data
73+
apt-get install -y --no-install-recommends cmake cmake-data
7474

7575
# Add inception_graphdef model to example repo
7676
WORKDIR /workspace/docs/examples/model_repository

Dockerfile.sdk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ RUN apt update && apt install -y gpg wget && \
9797
tee /etc/apt/sources.list.d/kitware.list >/dev/null && \
9898
apt-get update && \
9999
apt-get install -y --no-install-recommends cmake cmake-data && \
100-
cmake --version
100+
cmake --version
101101

102102
# Build expects "python" executable (not python3).
103103
RUN rm -f /usr/bin/python && \
@@ -197,8 +197,8 @@ RUN mkdir qa
197197
COPY qa/L0_sdk qa/L0_sdk
198198
COPY qa/L0_client_build_variants qa/L0_client_build_variants
199199

200-
# Create a directory for all the python client tests to enable unit testing
201-
RUN mkdir -p qa/python_client_unit_tests/
200+
# Create a directory for all the python client tests to enable unit testing
201+
RUN mkdir -p qa/python_client_unit_tests/
202202
COPY --from=sdk_build /workspace/client/src/python/library/tests/* qa/python_client_unit_tests/
203203

204204
# Install an image needed by the quickstart and other documentation.

Dockerfile.win10.min

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ RUN copy "%CUDA_INSTALL_ROOT_WP%\extras\visual_studio_integration\MSBuildExtensi
130130

131131
RUN setx PATH "%CUDA_INSTALL_ROOT_WP%\bin;%PATH%"
132132

133-
LABEL CUDA_VERSION="${CUDA_VERSION}"
133+
LABEL CUDA_VERSION="${CUDA_VERSION}"
134134

135135
#
136136
# Installing Tensorrt
@@ -159,7 +159,7 @@ ARG CUDNN_SOURCE=${CUDNN_ZIP}
159159

160160
ADD ${CUDNN_SOURCE} /tmp/${CUDNN_ZIP}
161161

162-
RUN unzip /tmp/%CUDNN_ZIP%
162+
RUN unzip /tmp/%CUDNN_ZIP%
163163
RUN move cudnn-* cudnn
164164
RUN copy cudnn\bin\cudnn*.dll "%CUDA_INSTALL_ROOT_WP%\bin\."
165165
RUN copy cudnn\lib\x64\cudnn*.lib "%CUDA_INSTALL_ROOT_WP%\lib\x64\."

0 commit comments

Comments
 (0)