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

Add GitHub action to format and lint code #6022

Merged
merged 39 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2057e6d
Add pre-commit
dyastremsky Jul 4, 2023
36998f0
Fix typos, exec/shebang, formatting
dyastremsky Jul 4, 2023
b3288fc
Remove clang-format
dyastremsky Jul 4, 2023
2088a84
Update contributing md to include pre-commit
dyastremsky Jul 4, 2023
ada02e2
Update spacing in CONTRIBUTING
dyastremsky Jul 4, 2023
8e3d527
Fix contributing pre-commit link
dyastremsky Jul 4, 2023
ff54d19
Link to pre-commit install directions
dyastremsky Jul 4, 2023
42b9de0
Wording
dyastremsky Jul 4, 2023
d111bc9
Restore clang-format
dyastremsky Jul 4, 2023
3740d40
Fix yaml spacing
dyastremsky Jul 4, 2023
cf11ab4
Exclude templates folder for check-yaml
dyastremsky Jul 4, 2023
b8e24b2
Remove unused vars
dyastremsky Jul 4, 2023
5f44531
Normalize spacing
dyastremsky Jul 4, 2023
0e34e3d
Remove unused variable
dyastremsky Jul 5, 2023
a6861f8
Normalize config indentation
dyastremsky Jul 6, 2023
7fe4c3f
Update .clang-format to enforce max line length of 80
dyastremsky Jul 6, 2023
ca1d3c7
Update copyrights
dyastremsky Jul 6, 2023
cbd3897
Update copyrights
dyastremsky Jul 6, 2023
16d1c06
Run workflows on every PR
dyastremsky Jul 6, 2023
3d6612a
Fix copyright year
dyastremsky Jul 7, 2023
dd27ee5
Fix grammar
dyastremsky Jul 7, 2023
ef2da64
Entrypoint.d files are not executable
dyastremsky Jul 7, 2023
53a7ed3
Run pre-commit hooks
dyastremsky Jul 10, 2023
1144058
Mark not executable
dyastremsky Jul 10, 2023
62306b2
Run pre-commit hooks
dyastremsky Jul 11, 2023
26dbbd5
Remove unused variable
dyastremsky Jul 11, 2023
6382e49
Run pre-commit hooks after rebase
dyastremsky Jul 12, 2023
42012b3
Update copyrights
dyastremsky Jul 13, 2023
856531e
Fix README.md typo (decoupled)
dyastremsky Jul 13, 2023
e119d37
Run pre-commit hooks
dyastremsky Jul 13, 2023
91263a7
Grammar fix
dyastremsky Jul 17, 2023
1ff1a2f
Redundant word
dyastremsky Jul 17, 2023
46b931c
Revert docker file changes
dyastremsky Jul 17, 2023
ba9218b
Executable shebang revert
dyastremsky Jul 17, 2023
edcd3ef
Make model.py files non-executable
dyastremsky Jul 17, 2023
30df40c
Passin is proper flag
dyastremsky Jul 18, 2023
8738c9b
Run pre-commit hooks on init_args/model.py
dyastremsky Jul 19, 2023
bf67cbc
Fix typo in init_args/model.py
dyastremsky Jul 19, 2023
5148526
Make copyrights one line
dyastremsky Jul 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
BasedOnStyle: Google

IndentWidth: 2
ColumnLimit: 80
ContinuationIndentWidth: 4
UseTab: Never
MaxEmptyLinesToKeep: 2
Expand Down Expand Up @@ -34,4 +35,5 @@ BinPackArguments: true
BinPackParameters: true
ConstructorInitializerAllOnOneLineOrOnePerLine: false

IndentCaseLabels: true
IndentCaseLabels: true

12 changes: 3 additions & 9 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@
name: "CodeQL"

on:
push:
branches: [ 'main' ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ 'main' ]
schedule:
- cron: '0 1 * * 1-6'

jobs:
analyze:
Expand Down Expand Up @@ -63,12 +57,12 @@ jobs:
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to:
# 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
queries: +security-and-quality


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

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

# - run: |
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2023, 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.

name: pre-commit

on:
pull_request:

jobs:
pre-commit:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/action@v3.0.0

74 changes: 74 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Copyright 2023, 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.

repos:
- repo: https://github.com/timothycrosley/isort
rev: 5.12.0
hooks:
- id: isort
additional_dependencies: [toml]
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
types_or: [python, cython]
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
args: [--max-line-length=88, --select=C,E,F,W,B,B950, --extend-ignore = E203,E501]
types_or: [python, cython]
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v16.0.5
hooks:
- id: clang-format
types_or: [c, c++, cuda, proto, textproto, java]
args: ["-fallback-style=none", "-style=file", "-i"]
- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
hooks:
- id: codespell
additional_dependencies: [tomli]
args: ["--toml", "pyproject.toml"]
exclude: (?x)^(.*stemmer.*|.*stop_words.*|^CHANGELOG.md$)
# More details about these pre-commit hooks here:
# https://pre-commit.com/hooks.html
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-json
- id: check-toml
- id: check-yaml
exclude: ^deploy(\/[^\/]+)*\/templates\/.*$
- id: check-shebang-scripts-are-executable
- id: end-of-file-fixer
types_or: [c, c++, cuda, proto, textproto, java, python]
- id: mixed-line-ending
- id: requirements-txt-fixer
- id: trailing-whitespace
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ if(EXISTS "/etc/os-release")
set (LIB_DIR "lib64")
endif()
endif()

set(TRITON_CORE_HEADERS_ONLY OFF)

FetchContent_MakeAvailable(repo-third-party repo-core)
Expand Down
30 changes: 14 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
# Copyright 2018-2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Copyright 2018-2023, 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
Expand Down Expand Up @@ -103,21 +103,19 @@ proposed change so that the Triton team can provide feedback.

# Coding Convention

Use clang-format to format all source files (\*.h, \*.cc, \*.proto,
*.py) to a consistent format. You should run clang-format on all
source files before submitting a pull request:

```
$ apt-get install clang-format-15
```

For convenience there is a format.py script in the
triton-inference-server/common repo in the "tools" directory that can
be used to clang-format all files within the repo:

```
$ python3 ../common/tools/format.py *
```
All pull requests are checked against the
[pre-commit hooks](https://github.com/pre-commit/pre-commit-hooks)
located [in the repository's top-level .pre-commit-config.yaml](https://github.com/NVIDIA/triton-inference-server/blob/master/pre-commit-config.yaml).
The hooks do some sanity checking like linting and formatting.
These checks must pass to merge a change.

To run these locally, you can
[install pre-commit,](https://pre-commit.com/#install)
then run `pre-commit install` inside the cloned repo. When you
commit a change, the pre-commit hooks will run automatically.
If a fix is implemented by a pre-commit hook, adding the file again
and running `git commit` a second time will pass and successfully
commit.

# Contributor License Agreement (CLA)

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.QA
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ RUN apt update && apt install -y gpg wget && \
echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $UBUNTU_CODENAME main" | \
tee /etc/apt/sources.list.d/kitware.list >/dev/null && \
apt-get update && \
apt-get install -y --no-install-recommends cmake cmake-data
apt-get install -y --no-install-recommends cmake cmake-data

# Add inception_graphdef model to example repo
WORKDIR /workspace/docs/examples/model_repository
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile.sdk
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ RUN apt update && apt install -y gpg wget && \
tee /etc/apt/sources.list.d/kitware.list >/dev/null && \
apt-get update && \
apt-get install -y --no-install-recommends cmake cmake-data && \
cmake --version
cmake --version

# Build expects "python" executable (not python3).
RUN rm -f /usr/bin/python && \
Expand Down Expand Up @@ -197,8 +197,8 @@ RUN mkdir qa
COPY qa/L0_sdk qa/L0_sdk
COPY qa/L0_client_build_variants qa/L0_client_build_variants

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

# Install an image needed by the quickstart and other documentation.
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.win10.min
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ RUN copy "%CUDA_INSTALL_ROOT_WP%\extras\visual_studio_integration\MSBuildExtensi

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

LABEL CUDA_VERSION="${CUDA_VERSION}"
LABEL CUDA_VERSION="${CUDA_VERSION}"

#
# Installing Tensorrt
Expand Down Expand Up @@ -159,7 +159,7 @@ ARG CUDNN_SOURCE=${CUDNN_ZIP}

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

RUN unzip /tmp/%CUDNN_ZIP%
RUN unzip /tmp/%CUDNN_ZIP%
RUN move cudnn-* cudnn
RUN copy cudnn\bin\cudnn*.dll "%CUDA_INSTALL_ROOT_WP%\bin\."
RUN copy cudnn\lib\x64\cudnn*.lib "%CUDA_INSTALL_ROOT_WP%\lib\x64\."
Expand Down
Loading
Loading