From 7b16f88bc5c50b22c9e8f8e79ac80f3077bb2b31 Mon Sep 17 00:00:00 2001 From: Bowen <81504862+Bowen12992@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:53:38 +0800 Subject: [PATCH] add pre-commit in CONTRIBUTING.md (#78) Co-authored-by: Bowen12992 --- CONTRIBUTING.md | 8 ++++++++ tests/test_special_ops.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1c5f5b3a..2fd6b023 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,6 +14,14 @@ Please report bugs using Github's issues. When reporting bugs, please provide In pull requests, contributor should describe what changed and why. Please also provide test cases if applicable. Pull requests require approvals from two members before merging. +Using pre-commit git hooks with FlagGems, you can format source Python code and perform basic code pre-checks when calling the git commit command + +```bash +pip install pre-commit +pre-commit install +pre-commit +``` + ## Project Structure ``` diff --git a/tests/test_special_ops.py b/tests/test_special_ops.py index 6966caa1..a907d453 100644 --- a/tests/test_special_ops.py +++ b/tests/test_special_ops.py @@ -57,7 +57,7 @@ def get_rope_cos_sin(max_seq_len, dim, dtype, base=10000, device="cuda"): def rotate_half(x): """Rotates half the hidden dims of the input.""" x1 = x[..., : x.shape[-1] // 2] - x2 = x[..., x.shape[-1] // 2 :] # noqa: E203 + x2 = x[..., x.shape[-1] // 2 :] return torch.cat((-x2, x1), dim=-1)