mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
Separate clang lint? (#119575)
25 min -> 17 + 13 min, which is still not as fast as I want it to be but I'll take it
Lintrunner provides some parallelism by default, but it's not perfect
Reducing fetch-depth from all to 1 further reduces time by ~2-3 minutes
From non clang's logs:
```
2024-02-09T22:05:39.5297616Z Requirement already satisfied: PyYAML==6.0 in /opt/conda/lib/python3.11/site-packages (6.0)
2024-02-09T22:12:23.6164708Z Collecting black==23.12.1
```
I don't know why this part takes so long, maybe it's just buffering? Clang version doesn't show this issue
See 5a750c8035
Pull Request resolved: https://github.com/pytorch/pytorch/pull/119575
Approved by: https://github.com/huydhn, https://github.com/malfet
This commit is contained in:
parent
bc521f2ce3
commit
059bf1baa4
2 changed files with 61 additions and 39 deletions
43
.github/scripts/lintrunner.sh
vendored
Executable file
43
.github/scripts/lintrunner.sh
vendored
Executable file
|
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/env bash
|
||||
set -x
|
||||
|
||||
# The generic Linux job chooses to use base env, not the one setup by the image
|
||||
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
|
||||
conda activate "${CONDA_ENV}"
|
||||
|
||||
CACHE_DIRECTORY="/tmp/.lintbin"
|
||||
# Try to recover the cached binaries
|
||||
if [[ -d "${CACHE_DIRECTORY}" ]]; then
|
||||
# It's ok to fail this as lintrunner init would download these binaries
|
||||
# again if they do not exist
|
||||
cp -r "${CACHE_DIRECTORY}" . || true
|
||||
fi
|
||||
|
||||
# This has already been cached in the docker image
|
||||
lintrunner init 2> /dev/null
|
||||
|
||||
# Do build steps necessary for linters
|
||||
if [[ "${CLANG}" == "1" ]]; then
|
||||
python3 -m tools.linter.clang_tidy.generate_build_files
|
||||
fi
|
||||
python3 -m tools.generate_torch_version --is_debug=false
|
||||
python3 -m tools.pyi.gen_pyi \
|
||||
--native-functions-path aten/src/ATen/native/native_functions.yaml \
|
||||
--tags-path aten/src/ATen/native/tags.yaml \
|
||||
--deprecated-functions-path "tools/autograd/deprecated.yaml"
|
||||
|
||||
RC=0
|
||||
# Run lintrunner on all files
|
||||
if ! lintrunner --force-color --all-files --tee-json=lint.json ${ADDITIONAL_LINTRUNNER_ARGS} 2> /dev/null; then
|
||||
echo ""
|
||||
echo -e "\e[1m\e[36mYou can reproduce these results locally by using \`lintrunner -m origin/main\`. (If you don't get the same results, run \'lintrunner init\' to update your local linter)\e[0m"
|
||||
echo -e "\e[1m\e[36mSee https://github.com/pytorch/pytorch/wiki/lintrunner for setup instructions.\e[0m"
|
||||
RC=1
|
||||
fi
|
||||
|
||||
# Use jq to massage the JSON lint output into GitHub Actions workflow commands.
|
||||
jq --raw-output \
|
||||
'"::\(if .severity == "advice" or .severity == "disabled" then "warning" else .severity end) file=\(.path),line=\(.line),col=\(.char),title=\(.code) \(.name)::" + (.description | gsub("\\n"; "%0A"))' \
|
||||
lint.json || true
|
||||
|
||||
exit $RC
|
||||
57
.github/workflows/lint.yml
vendored
57
.github/workflows/lint.yml
vendored
|
|
@ -15,53 +15,32 @@ permissions: read-all
|
|||
# The names of steps that actually test the code should be suffixed with `(nonretryable)`.
|
||||
# When any other step fails, it's job will be retried once by retryBot.
|
||||
jobs:
|
||||
lintrunner:
|
||||
lintrunner-clang:
|
||||
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
|
||||
with:
|
||||
timeout: 120
|
||||
runner: linux.2xlarge
|
||||
docker-image: pytorch-linux-jammy-cuda11.8-cudnn8-py3.9-linter
|
||||
fetch-depth: 0
|
||||
fetch-depth: 1
|
||||
submodules: true
|
||||
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
|
||||
script: |
|
||||
# The generic Linux job chooses to use base env, not the one setup by the image
|
||||
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
|
||||
conda activate "${CONDA_ENV}"
|
||||
export ADDITIONAL_LINTRUNNER_ARGS="--take CLANGTIDY,CLANGFORMAT"
|
||||
export CLANG=1
|
||||
.github/scripts/lintrunner.sh
|
||||
|
||||
CACHE_DIRECTORY="/tmp/.lintbin"
|
||||
# Try to recover the cached binaries
|
||||
if [[ -d "${CACHE_DIRECTORY}" ]]; then
|
||||
# It's ok to fail this as lintrunner init would download these binaries
|
||||
# again if they do not exist
|
||||
cp -r "${CACHE_DIRECTORY}" . || true
|
||||
fi
|
||||
|
||||
# This has already been cached in the docker image
|
||||
lintrunner init 2> /dev/null
|
||||
|
||||
# Do build steps necessary for linters
|
||||
python3 -m tools.linter.clang_tidy.generate_build_files
|
||||
python3 -m tools.generate_torch_version --is_debug=false
|
||||
python3 -m tools.pyi.gen_pyi \
|
||||
--native-functions-path aten/src/ATen/native/native_functions.yaml \
|
||||
--tags-path aten/src/ATen/native/tags.yaml \
|
||||
--deprecated-functions-path "tools/autograd/deprecated.yaml"
|
||||
|
||||
RC=0
|
||||
# Run lintrunner on all files
|
||||
if ! lintrunner --force-color --all-files --tee-json=lint.json 2> /dev/null; then
|
||||
echo ""
|
||||
echo -e "\e[1m\e[36mYou can reproduce these results locally by using \`lintrunner -m origin/main\`. (If you don't get the same results, run \'lintrunner init\' to update your local linter)\e[0m"
|
||||
echo -e "\e[1m\e[36mSee https://github.com/pytorch/pytorch/wiki/lintrunner for setup instructions.\e[0m"
|
||||
RC=1
|
||||
fi
|
||||
|
||||
# Use jq to massage the JSON lint output into GitHub Actions workflow commands.
|
||||
jq --raw-output \
|
||||
'"::\(if .severity == "advice" or .severity == "disabled" then "warning" else .severity end) file=\(.path),line=\(.line),col=\(.char),title=\(.code) \(.name)::" + (.description | gsub("\\n"; "%0A"))' \
|
||||
lint.json || true
|
||||
|
||||
exit $RC
|
||||
lintrunner-noclang:
|
||||
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
|
||||
with:
|
||||
timeout: 120
|
||||
runner: linux.2xlarge
|
||||
docker-image: pytorch-linux-jammy-cuda11.8-cudnn8-py3.9-linter
|
||||
fetch-depth: 1
|
||||
submodules: true
|
||||
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
|
||||
script: |
|
||||
export ADDITIONAL_LINTRUNNER_ARGS="--skip CLANGTIDY,CLANGFORMAT"
|
||||
.github/scripts/lintrunner.sh
|
||||
|
||||
quick-checks:
|
||||
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
|
||||
|
|
|
|||
Loading…
Reference in a new issue