From 881929f1d4cab26ff6957cc4ab854f3c126739e6 Mon Sep 17 00:00:00 2001 From: Costa Huang Date: Tue, 20 Jun 2023 09:29:47 -0400 Subject: [PATCH 1/7] Pre-commit --- .pre-commit-config.yaml | 42 +++++++++++++++++++++++++++++++++++++++++ scripts/stale.py | 7 ++++--- setup.cfg | 4 ---- setup.py | 5 +++-- 4 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..34d2c6c806 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,42 @@ +repos: + - repo: https://github.com/PyCQA/isort + rev: 5.12.0 + hooks: + - id: isort + args: + - --profile=black + - --skip-glob=wandb/**/* + - --thirdparty=wandb + - repo: https://github.com/myint/autoflake + rev: v1.4 + hooks: + - id: autoflake + args: + - -r + - --exclude=wandb,__init__.py + - --in-place + - --remove-unused-variables + - --remove-all-unused-imports + - repo: https://github.com/python/black + rev: 22.3.0 + hooks: + - id: black + args: + - --line-length=119 + - --target-version=py38 + - --exclude=wandb + - repo: https://github.com/pycqa/flake8 + rev: 6.0.0 + hooks: + - id: flake8 + args: + - --ignore=E203,E501,W503,E128 + - --max-line-length=119 + + - repo: https://github.com/codespell-project/codespell + rev: v2.1.0 + hooks: + - id: codespell + args: + - --ignore-words-list=nd,reacher,thist,ths,magent,ba + - --skip=docs/css/termynal.css,docs/js/termynal.js diff --git a/scripts/stale.py b/scripts/stale.py index 8bbb20f5af..09ef7b9ba8 100644 --- a/scripts/stale.py +++ b/scripts/stale.py @@ -15,8 +15,8 @@ Script to close stale issue. Taken in part from the AllenNLP repository. https://github.com/allenai/allennlp. """ -from datetime import datetime as dt import os +from datetime import datetime as dt from github import Github @@ -37,7 +37,8 @@ def main(): comments = sorted([comment for comment in issue.get_comments()], key=lambda i: i.created_at, reverse=True) last_comment = comments[0] if len(comments) > 0 else None if ( - last_comment is not None and last_comment.user.login == "github-actions[bot]" + last_comment is not None + and last_comment.user.login == "github-actions[bot]" and (dt.utcnow() - issue.updated_at).days > 7 and (dt.utcnow() - issue.created_at).days >= 30 and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels()) @@ -56,4 +57,4 @@ def main(): if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/setup.cfg b/setup.cfg index 63c83bc500..cb69438f56 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,7 +9,3 @@ line_length = 119 lines_after_imports = 2 multi_line_output = 3 use_parentheses = True - -[flake8] -ignore = E203, E501, W503 -max-line-length = 119 \ No newline at end of file diff --git a/setup.py b/setup.py index e930130716..87ff3c4215 100644 --- a/setup.py +++ b/setup.py @@ -54,7 +54,8 @@ Then push the change with a message 'set dev version' """ -from setuptools import setup, find_packages +from setuptools import find_packages, setup + __version__ = "0.4.5.dev0" # expected format is one of x.y.z.dev0, or x.y.z.rc1 or x.y.z (no to dashes, yes to dots) @@ -68,7 +69,7 @@ EXTRAS = { "test": ["parameterized", "pytest", "pytest-xdist", "accelerate", "peft"], "peft": ["peft>=0.2.0"], - "dev": ["parameterized", "pytest", "pytest-xdist", "black", "isort", "flake8>=3.8.3", "peft>=0.2.0"], + "dev": ["parameterized", "pytest", "pytest-xdist", "pre-commit", "peft>=0.2.0"], } setup( From 49d91e0b987f336b0d5de2c1ad0ea7308859f803 Mon Sep 17 00:00:00 2001 From: Costa Huang Date: Tue, 20 Jun 2023 09:39:17 -0400 Subject: [PATCH 2/7] modify CI --- .github/workflows/tests.yml | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2fe0caf599..91fc4682f8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,26 +7,24 @@ on: branches: [ main ] jobs: - check_code_quality: runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.9] + steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 + - uses: actions/checkout@v2 with: - python-version: "3.8" - cache: "pip" - cache-dependency-path: | - setup.py - requirements.txt - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install .[dev] - - name: Check quality - run: | - make quality + fetch-depth: 0 + submodules: recursive + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - uses: pre-commit/action@v2.0.3 + with: + extra_args: --all-files tests: needs: check_code_quality From 6105a65d2f746d37e31a261d49cd51624f29a0b0 Mon Sep 17 00:00:00 2001 From: Costa Huang Date: Tue, 20 Jun 2023 09:40:32 -0400 Subject: [PATCH 3/7] modify make file --- Makefile | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Makefile b/Makefile index a18ca9aa3b..38cc34371e 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,6 @@ -.PHONY: quality style test +.PHONY: test check_dirs := examples tests trl test: python -m pytest -n auto --dist=loadfile -s -v ./tests/ - -quality: - black --check --line-length 119 --target-version py38 $(check_dirs) - isort --check-only $(check_dirs) - flake8 $(check_dirs) - -style: - black --line-length 119 --target-version py38 $(check_dirs) - isort $(check_dirs) \ No newline at end of file From 476e9196491a68a57cee9067c5b6c9e3c94d741a Mon Sep 17 00:00:00 2001 From: Costa Huang Date: Tue, 20 Jun 2023 09:43:03 -0400 Subject: [PATCH 4/7] temporarily disable codespell --- .pre-commit-config.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 34d2c6c806..545815fe67 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,10 +33,10 @@ repos: - --ignore=E203,E501,W503,E128 - --max-line-length=119 - - repo: https://github.com/codespell-project/codespell - rev: v2.1.0 - hooks: - - id: codespell - args: - - --ignore-words-list=nd,reacher,thist,ths,magent,ba - - --skip=docs/css/termynal.css,docs/js/termynal.js + # - repo: https://github.com/codespell-project/codespell + # rev: v2.1.0 + # hooks: + # - id: codespell + # args: + # - --ignore-words-list=nd,reacher,thist,ths,magent,ba + # - --skip=docs/css/termynal.css,docs/js/termynal.js From 4aa85b3fbd53daf011f79031d81e3da6d37e574b Mon Sep 17 00:00:00 2001 From: Costa Huang Date: Fri, 23 Jun 2023 08:55:41 -0400 Subject: [PATCH 5/7] update make file --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 38cc34371e..32149ca3e2 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ -.PHONY: test +.PHONY: test commit check_dirs := examples tests trl test: python -m pytest -n auto --dist=loadfile -s -v ./tests/ + +commit: + pre-commit run --all-files From 862fd8adef6da9f46b915548df1f19aa2f2c73a6 Mon Sep 17 00:00:00 2001 From: Costa Huang Date: Fri, 23 Jun 2023 08:56:30 -0400 Subject: [PATCH 6/7] update contribution guide --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9f744b4709..671f9ba692 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,10 +36,10 @@ First you want to make sure that all the tests pass: make test ``` -Then before submitting your PR make sure the code quality follows the standards. You can run the following command to format and test: +Then before submitting your PR make sure the code quality follows the standards. You can run the following command to format: ```bash -make style && make quality +make commit ``` ## Do you want to contribute to the documentation? From 7fff6b801da92b991890867cbe59f54dbe86dd59 Mon Sep 17 00:00:00 2001 From: Costa Huang Date: Fri, 23 Jun 2023 09:17:50 -0400 Subject: [PATCH 7/7] pushc changes --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 32149ca3e2..a9b9b772b0 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ -.PHONY: test commit +.PHONY: test precommit check_dirs := examples tests trl test: python -m pytest -n auto --dist=loadfile -s -v ./tests/ -commit: +precommit: pre-commit run --all-files