Files
DeepInfer/CONTRIBUTING.md
2026-10-20 12:09:42 +08:00

1.6 KiB

Contributing

Run all commands below from the repository root. See README.md for environment setup.

Code formatting

Before committing, format the modified code and pass the corresponding checks.

Python

Ruff is configured in pyproject.toml.

ruff check --fix && ruff format                          # Format
ruff check --no-cache && ruff format --check --no-cache  # Check

C++

Use scripts/format_csrc.sh to format C++ and CUDA code under csrc/. Install clang-format or set CLANG_FORMAT to its executable path.

bash scripts/format_csrc.sh          # Format
bash scripts/format_csrc.sh --check  # Check

Testing

Directory conventions

  • tests/: pytest test scripts. All tests should be discoverable by pytest by default.
  • examples/: standalone offline inference and resource-intensive validation scripts. These typically require models or services and take longer to run; they are not collected by pytest.

Core test markers

Core tests must remain lightweight. Mark them according to the target platform:

  • Use @pytest.mark.ci for GPU core tests.
  • Use @pytest.mark.ci_npu for NPU-only core tests.
  • Apply both @pytest.mark.ci and @pytest.mark.ci_npu to tests that must run on both GPUs and NPUs.

Running tests

Run tests in an environment with the required hardware, models, and dependencies:

python -m pytest -v -s -m ci tests      # GPU core tests
python -m pytest -v -s -m ci_npu tests  # NPU core tests
python -m pytest -v -s tests            # Full pytest suite