triton-inference-server / local_cache

Implementation of a local in-memory cache for Triton Inference Server's TRITONCACHE API
BSD 3-Clause "New" or "Revised" License
5 stars 1 forks source link

Add GitHub action to format and lint code #10

Closed dyastremsky closed 1 year ago

dyastremsky commented 1 year ago

This pull request adds pre-commit hooks. It also includes running the pre-commit hooks on these files, plus making fixes based on them (e.g. making sure all .py and .sh executables are set to be executable and have shebangs, spelling corrections, etc.).

This pull request adds pre-commit hooks to run the following:

Black for formatting Python Flake8 for linting Python for conformance to PEP8, PyFlakes, and circular complexity (max-line-length set to match Black's 88 default/recommended character limit; this and other settings from Black's documentation here to avoid enforcement of limit when unnecessary). isort for deterministically sorting and organizing Python imports Clang for formatting C++, C, Java, TextProto, Proto, and CUDA Codespell for finding common spelling mistakes In addition, this adds these native pre-commit hooks, details here:

check-case-conflict check-executables-have-shebangs check-merge-conflict check-json check-toml check-yaml check-shebang-scripts-are-executable end-of-file-fixer mixed-line-ending requirements-txt-fixer trailing-whitespace To run these locally, you can go into the repo and run pip install pre-commit and pre-commit install. After that has been done once, you just need to run pre-commit run --all-files any time you want to apply them. Once installed, it should run automatically on commit for files included in a commit. To correct spelling errors found by codespell when possible, you can install codespell (pip install codespell and potentially pip install --upgrade codespell to use the toml file in the directory) and call codespell -w .

This pull request also adds a GitHub action so that these are run for every pull request and push to main. The core changes are in pre-commit.yml, pre-commit-config.yaml, and pyproject.toml. The rest of the changes are the effect of applying the action to the current repo.