From 279522aed84d11df297eab81f5370b2ba882d7b7 Mon Sep 17 00:00:00 2001 From: zepingguo Date: Mon, 4 Nov 2024 18:21:44 +0800 Subject: [PATCH 01/10] pre commit config --- .pre-commit-config.yaml | 60 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000000..1fef3017e3f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,60 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + +- repo: https://github.com/psf/black + rev: 23.12.1 + hooks: + - id: black + files: sky/skylet/providers/ibm/.* + +- repo: https://github.com/pycqa/isort + rev: 5.13.2 + hooks: + - id: isort + exclude: sky/skylet/providers/ibm/.* + args: ["--profile", "google"] + - id: isort + files: sky/skylet/providers/ibm/.* + args: ["--profile", "black", "-l", "88", "-m", "3"] + stages: [pre-commit] + +- repo: https://github.com/google/yapf + rev: v0.40.2 + hooks: + - id: yapf + exclude: (build/.*|sky/skylet/providers/ibm/.*) + additional_dependencies: [toml] + +- repo: local + hooks: + - id: pylint + name: pylint + entry: pylint + language: python + types: [python] + additional_dependencies: + - pylint==2.14.5 + - pylint-quotes==0.2.3 + args: [ + "--load-plugins=pylint_quotes", + "--rcfile=.pylintrc" + ] + exclude: ^(build/.*|sky/skylet/providers/ibm/.*)$ + + - id: mypy + name: mypy + entry: mypy + language: system + types: [python] + files: | + (?x)^( + sky/global_user_state.py| + sky/serve/ + )$ + require_serial: true From 46f628f84a6ccde31e3c2a5c15fc6565c460159b Mon Sep 17 00:00:00 2001 From: zepingguo Date: Tue, 5 Nov 2024 19:02:38 +0800 Subject: [PATCH 02/10] yapf version --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1fef3017e3f..f705f39809b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,14 +18,14 @@ repos: hooks: - id: isort exclude: sky/skylet/providers/ibm/.* - args: ["--profile", "google"] + args: [“--profile”, “google”] - id: isort files: sky/skylet/providers/ibm/.* - args: ["--profile", "black", "-l", "88", "-m", "3"] + args: [“--profile”, “black”, “-l”, “88", “-m”, “3"] stages: [pre-commit] - repo: https://github.com/google/yapf - rev: v0.40.2 + rev: v0.32.0 hooks: - id: yapf exclude: (build/.*|sky/skylet/providers/ibm/.*) @@ -42,8 +42,8 @@ repos: - pylint==2.14.5 - pylint-quotes==0.2.3 args: [ - "--load-plugins=pylint_quotes", - "--rcfile=.pylintrc" + “--load-plugins=pylint_quotes”, + “--rcfile=.pylintrc” ] exclude: ^(build/.*|sky/skylet/providers/ibm/.*)$ From af9f3cca96c002134dcfc060480ab00c15ca99fa Mon Sep 17 00:00:00 2001 From: zepingguo Date: Tue, 5 Nov 2024 19:03:56 +0800 Subject: [PATCH 03/10] fix --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f705f39809b..5fb60c049f9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,10 +18,10 @@ repos: hooks: - id: isort exclude: sky/skylet/providers/ibm/.* - args: [“--profile”, “google”] + args: ["--profile", "google"] - id: isort files: sky/skylet/providers/ibm/.* - args: [“--profile”, “black”, “-l”, “88", “-m”, “3"] + args: ["--profile", "black", "-l", "88", "-m", "3"] stages: [pre-commit] - repo: https://github.com/google/yapf @@ -42,8 +42,8 @@ repos: - pylint==2.14.5 - pylint-quotes==0.2.3 args: [ - “--load-plugins=pylint_quotes”, - “--rcfile=.pylintrc” + "--load-plugins=pylint_quotes", + "--rcfile=.pylintrc" ] exclude: ^(build/.*|sky/skylet/providers/ibm/.*)$ From 50fb34edb82c799cfc0e46f4e84c46bbff6d344c Mon Sep 17 00:00:00 2001 From: zepingguo Date: Wed, 6 Nov 2024 16:53:58 +0800 Subject: [PATCH 04/10] mypy check all files --- .pre-commit-config.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5fb60c049f9..70941c31722 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -52,9 +52,4 @@ repos: entry: mypy language: system types: [python] - files: | - (?x)^( - sky/global_user_state.py| - sky/serve/ - )$ require_serial: true From f829a85bb57e1cd53040f27a7a2fca8c0ed8295d Mon Sep 17 00:00:00 2001 From: zepingguo Date: Thu, 7 Nov 2024 17:10:22 +0800 Subject: [PATCH 05/10] skip smoke_test.py --- .pre-commit-config.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 70941c31722..ad18791d6f4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -45,7 +45,7 @@ repos: "--load-plugins=pylint_quotes", "--rcfile=.pylintrc" ] - exclude: ^(build/.*|sky/skylet/providers/ibm/.*)$ + exclude: ^(build/.*|sky/skylet/providers/ibm/.*|tests/test_smoke\.py)$ - id: mypy name: mypy @@ -53,3 +53,4 @@ repos: language: system types: [python] require_serial: true + exclude: ^tests/test_smoke\.py$ From 2724c81c66b7eb37a41cc5b72b178c1ac3b76bbb Mon Sep 17 00:00:00 2001 From: ZePing Guo Date: Tue, 26 Nov 2024 17:14:39 +0800 Subject: [PATCH 06/10] add doc --- CONTRIBUTING.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6542f6add27..494f5b484e2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,7 @@ # Contributing to SkyPilot -Thank you for your interest in contributing to SkyPilot! We welcome and value -all contributions to the project, including but not limited to: +Thank you for your interest in contributing to SkyPilot! We welcome and value +all contributions to the project, including but not limited to: * [Bug reports](https://github.com/skypilot-org/skypilot/issues) and [discussions](https://github.com/skypilot-org/skypilot/discussions) * [Pull requests](https://github.com/skypilot-org/skypilot/pulls) for bug fixes and new features @@ -77,6 +77,7 @@ It has some convenience features which you might find helpful (see [Dockerfile]( - Fork the SkyPilot repository and create a new branch for your changes. - If relevant, add tests for your changes. For changes that touch the core system, run the [smoke tests](#testing) and ensure they pass. - Follow the [Google style guide](https://google.github.io/styleguide/pyguide.html). +- [Optional] Install pre-commit hooks by running `pre-commit install` to automatically format your code on commit. - Ensure code is properly formatted by running [`format.sh`](https://github.com/skypilot-org/skypilot/blob/master/format.sh). - Push your changes to your fork and open a pull request in the SkyPilot repository. - In the PR description, write a `Tested:` section to describe relevant tests performed. From 3eb73435bbe61e4ad6b8e5ab8a0dfe265c3135e1 Mon Sep 17 00:00:00 2001 From: ZePing Guo Date: Tue, 26 Nov 2024 17:16:58 +0800 Subject: [PATCH 07/10] better format --- .pre-commit-config.yaml | 1 + CONTRIBUTING.md | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ad18791d6f4..667ba9bcf38 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,4 @@ +# TODO(zpoint): Ensure it is synchronized with format.sh repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v5.0.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 494f5b484e2..d312516727a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,8 +77,7 @@ It has some convenience features which you might find helpful (see [Dockerfile]( - Fork the SkyPilot repository and create a new branch for your changes. - If relevant, add tests for your changes. For changes that touch the core system, run the [smoke tests](#testing) and ensure they pass. - Follow the [Google style guide](https://google.github.io/styleguide/pyguide.html). -- [Optional] Install pre-commit hooks by running `pre-commit install` to automatically format your code on commit. -- Ensure code is properly formatted by running [`format.sh`](https://github.com/skypilot-org/skypilot/blob/master/format.sh). +- Ensure code is properly formatted by running [`format.sh`](https://github.com/skypilot-org/skypilot/blob/master/format.sh). [Optional] You can also install pre-commit hooks by running `pre-commit install` to automatically format your code on commit. - Push your changes to your fork and open a pull request in the SkyPilot repository. - In the PR description, write a `Tested:` section to describe relevant tests performed. From 20088fb7a0a76e98dafc9265d562e1b7224480a5 Mon Sep 17 00:00:00 2001 From: ZePing Guo Date: Tue, 26 Nov 2024 17:18:48 +0800 Subject: [PATCH 08/10] newline format --- CONTRIBUTING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d312516727a..2918e13142c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,7 +77,8 @@ It has some convenience features which you might find helpful (see [Dockerfile]( - Fork the SkyPilot repository and create a new branch for your changes. - If relevant, add tests for your changes. For changes that touch the core system, run the [smoke tests](#testing) and ensure they pass. - Follow the [Google style guide](https://google.github.io/styleguide/pyguide.html). -- Ensure code is properly formatted by running [`format.sh`](https://github.com/skypilot-org/skypilot/blob/master/format.sh). [Optional] You can also install pre-commit hooks by running `pre-commit install` to automatically format your code on commit. +- Ensure code is properly formatted by running [`format.sh`](https://github.com/skypilot-org/skypilot/blob/master/format.sh). + - [Optional] You can also install pre-commit hooks by running `pre-commit install` to automatically format your code on commit. - Push your changes to your fork and open a pull request in the SkyPilot repository. - In the PR description, write a `Tested:` section to describe relevant tests performed. From e3a55f064782cddefc4303664e941c196b0f7316 Mon Sep 17 00:00:00 2001 From: ZePing Guo Date: Wed, 27 Nov 2024 13:17:55 +0800 Subject: [PATCH 09/10] sync with format.sh --- .pre-commit-config.yaml | 87 ++++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 32 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 667ba9bcf38..2e10afe2feb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,4 @@ -# TODO(zpoint): Ensure it is synchronized with format.sh +# Ensure this configuration aligns with format.sh and requirements.txt repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v5.0.0 @@ -9,49 +9,72 @@ repos: - id: check-added-large-files - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 22.10.0 # Match the version from requirements hooks: - id: black - files: sky/skylet/providers/ibm/.* + name: black (IBM specific) + files: "^sky/skylet/providers/ibm/.*" # Match only files in the IBM directory - repo: https://github.com/pycqa/isort - rev: 5.13.2 + rev: 5.12.0 # Match the version from requirements hooks: + # First isort command - id: isort - exclude: sky/skylet/providers/ibm/.* - args: ["--profile", "google"] + name: isort (general) + args: + - "--sg=build/**" # Matches "${ISORT_YAPF_EXCLUDES[@]}" + - "--sg=sky/skylet/providers/ibm/**" + files: "^(sky|tests|examples|llm|docs)/.*" # Only match these directories + # Second isort command - id: isort - files: sky/skylet/providers/ibm/.* - args: ["--profile", "black", "-l", "88", "-m", "3"] - stages: [pre-commit] + name: isort (IBM specific) + args: + - "--profile=black" + - "-l=88" + - "-m=3" + files: "^sky/skylet/providers/ibm/.*" # Only match IBM-specific directory + +- repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.991 # Match the version from requirements + hooks: + - id: mypy + args: + # from tests/mypy_files.txt + - "sky" + - "--exclude" + - "sky/benchmark|sky/callbacks|sky/skylet/providers/azure|sky/resources.py|sky/backends/monkey_patches" + pass_filenames: false + additional_dependencies: + - types-PyYAML + - types-requests<2.31 # Match the condition in requirements.txt + - types-setuptools + - types-cachetools + - types-pyvmomi - repo: https://github.com/google/yapf - rev: v0.32.0 + rev: v0.32.0 # Match the version from requirements hooks: - id: yapf - exclude: (build/.*|sky/skylet/providers/ibm/.*) - additional_dependencies: [toml] + name: yapf + exclude: (build/.*|sky/skylet/providers/ibm/.*) # Matches exclusions from the script + args: ['--recursive', '--parallel'] # Only necessary flags + additional_dependencies: [toml==0.10.2] -- repo: local +- repo: https://github.com/pylint-dev/pylint + rev: v2.14.5 # Match the version from requirements hooks: - id: pylint - name: pylint - entry: pylint - language: python - types: [python] additional_dependencies: - - pylint==2.14.5 - - pylint-quotes==0.2.3 - args: [ - "--load-plugins=pylint_quotes", - "--rcfile=.pylintrc" - ] - exclude: ^(build/.*|sky/skylet/providers/ibm/.*|tests/test_smoke\.py)$ - - - id: mypy - name: mypy - entry: mypy - language: system - types: [python] - require_serial: true - exclude: ^tests/test_smoke\.py$ + - pylint-quotes==0.2.3 # Match the version from requirements + name: pylint-only-changed-files + entry: > + bash -c ' + MERGEBASE=$(git merge-base origin/main HEAD); + changed_files=$(git diff --name-only --diff-filter=ACM "$MERGEBASE" -- "sky/*.py" "sky/*.pyi"); + if [[ -n "$changed_files" ]]; then + echo "$changed_files" | tr "\n" "\0" | xargs -0 pylint --load-plugins=pylint_quotes --rcfile=.pylintrc; + else + echo "Pylint skipped: no files changed in sky/."; + fi' + pass_filenames: false + always_run: true From 177e9e6725c57e59fb047dffc55d3109030d60ed Mon Sep 17 00:00:00 2001 From: ZePing Guo Date: Wed, 27 Nov 2024 13:20:28 +0800 Subject: [PATCH 10/10] comment fix --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2e10afe2feb..e2db4211454 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,7 +39,7 @@ repos: hooks: - id: mypy args: - # from tests/mypy_files.txt + # From tests/mypy_files.txt - "sky" - "--exclude" - "sky/benchmark|sky/callbacks|sky/skylet/providers/azure|sky/resources.py|sky/backends/monkey_patches"