From ca3a593130f6269e4bee7c9b0af80c1eb513ce80 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Thu, 31 Aug 2023 23:04:11 -0700 Subject: [PATCH 01/49] Add workflow yml --- .github/workflows/test-linux-cpu.yml | 45 ++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/test-linux-cpu.yml diff --git a/.github/workflows/test-linux-cpu.yml b/.github/workflows/test-linux-cpu.yml new file mode 100644 index 0000000000..83c09e5a0b --- /dev/null +++ b/.github/workflows/test-linux-cpu.yml @@ -0,0 +1,45 @@ +name: Unit-tests on Linux CPU + +on: + pull_request: + push: + branches: + - nightly + - main + - release/* + + workflow_dispatch: + +env: + CHANNEL: "nightly" + +jobs: + tests: + strategy: + matrix: + python_version: ["3.6", "3.7", "3.8", "3.9", "3.10"] + fail-fast: false + uses: pytorch/test-infra/.github/workflows/linux_job.yml@main + with: + runner: linux.12xlarge + repository: pytorch/captum + script: | + # Set up Environment Variables + export PYTHON_VERSION="${{ matrix.python_version }}" + export VERSION="cpu" + export CUDATOOLKIT="cpuonly" + + # Set CHANNEL + if [[ (${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then + export CHANNEL=test + else + export CHANNEL=nightly + fi + + # Create Conda Env + conda create -yp ci_env python="${PYTHON_VERSION}" + conda activate /work/ci_env + ./scripts/install_via_conda.sh + + # Run Tests + python3 -m pytest -ra --cov=. --cov-report term-missing From 63f435ad50f46b3756f1dba670ab2e2add0936b2 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Thu, 31 Aug 2023 23:53:35 -0700 Subject: [PATCH 02/49] Fix --- .github/workflows/test-linux-cpu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-linux-cpu.yml b/.github/workflows/test-linux-cpu.yml index 83c09e5a0b..d768d18b74 100644 --- a/.github/workflows/test-linux-cpu.yml +++ b/.github/workflows/test-linux-cpu.yml @@ -38,7 +38,7 @@ jobs: # Create Conda Env conda create -yp ci_env python="${PYTHON_VERSION}" - conda activate /work/ci_env + conda activate /pytorch/captum/ci_env ./scripts/install_via_conda.sh # Run Tests From ccec8a1a40b278e723b6aa175c09d17cf6f1152d Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Fri, 1 Sep 2023 00:27:07 -0700 Subject: [PATCH 03/49] Fix --- .github/workflows/test-linux-cpu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-linux-cpu.yml b/.github/workflows/test-linux-cpu.yml index d768d18b74..3672a6c26f 100644 --- a/.github/workflows/test-linux-cpu.yml +++ b/.github/workflows/test-linux-cpu.yml @@ -39,7 +39,7 @@ jobs: # Create Conda Env conda create -yp ci_env python="${PYTHON_VERSION}" conda activate /pytorch/captum/ci_env - ./scripts/install_via_conda.sh + ./scripts/install_via_conda.sh -n # Run Tests python3 -m pytest -ra --cov=. --cov-report term-missing From 5f137f273245affdbbd5a055136b33da80e6ce41 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Sun, 3 Sep 2023 23:35:26 -0700 Subject: [PATCH 04/49] Adding tests --- .github/workflows/lint.yml | 51 +++++++++++++++++++ ...{test-linux-cpu.yml => test-conda-cpu.yml} | 4 +- .github/workflows/test-pip-cpu.yml | 46 +++++++++++++++++ 3 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/lint.yml rename .github/workflows/{test-linux-cpu.yml => test-conda-cpu.yml} (91%) create mode 100644 .github/workflows/test-pip-cpu.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000000..0664fcf378 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,51 @@ +name: Unit-tests for Pip install + +on: + pull_request: + push: + branches: + - nightly + - main + - release/* + + workflow_dispatch: + +env: + CHANNEL: "nightly" + +jobs: + tests: + strategy: + matrix: + python_version: ["3.6"] + fail-fast: false + uses: pytorch/test-infra/.github/workflows/linux_job.yml@main + with: + runner: linux.12xlarge + repository: pytorch/captum + script: | + # Set up Environment Variables + export PYTHON_VERSION="${{ matrix.python_version }}" + export VERSION="cpu" + export CUDATOOLKIT="cpuonly" + + # Set CHANNEL + if [[ (${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then + export CHANNEL=test + else + export CHANNEL=nightly + fi + + # Create Conda Env + conda create -yp ci_env python="${PYTHON_VERSION}" + conda activate /pytorch/captum/ci_env + ./scripts/install_via_pip.sh + + # Check formatting with ufmt + ufmt check . + + # Lint with flake8 + flake8 + + # Run sphinx + sphinx-build -WT --keep-going sphinx/source sphinx/build diff --git a/.github/workflows/test-linux-cpu.yml b/.github/workflows/test-conda-cpu.yml similarity index 91% rename from .github/workflows/test-linux-cpu.yml rename to .github/workflows/test-conda-cpu.yml index 3672a6c26f..acf21543f9 100644 --- a/.github/workflows/test-linux-cpu.yml +++ b/.github/workflows/test-conda-cpu.yml @@ -1,4 +1,4 @@ -name: Unit-tests on Linux CPU +name: Unit-tests for Conda install on: pull_request: @@ -17,7 +17,7 @@ jobs: tests: strategy: matrix: - python_version: ["3.6", "3.7", "3.8", "3.9", "3.10"] + python_version: ["3.7", "3.8", "3.9", "3.10"] fail-fast: false uses: pytorch/test-infra/.github/workflows/linux_job.yml@main with: diff --git a/.github/workflows/test-pip-cpu.yml b/.github/workflows/test-pip-cpu.yml new file mode 100644 index 0000000000..0ecaf4d351 --- /dev/null +++ b/.github/workflows/test-pip-cpu.yml @@ -0,0 +1,46 @@ +name: Unit-tests for Pip install + +on: + pull_request: + push: + branches: + - nightly + - main + - release/* + + workflow_dispatch: + +env: + CHANNEL: "nightly" + +jobs: + tests: + strategy: + matrix: + python_version: ["3.6"] + pytorch_args: ["", "-n", "-v 1.6", "-v 1.7", " -v 1.8", "-v 1.9"] + fail-fast: false + uses: pytorch/test-infra/.github/workflows/linux_job.yml@main + with: + runner: linux.12xlarge + repository: pytorch/captum + script: | + # Set up Environment Variables + export PYTHON_VERSION="${{ matrix.python_version }}" + export VERSION="cpu" + export CUDATOOLKIT="cpuonly" + + # Set CHANNEL + if [[ (${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then + export CHANNEL=test + else + export CHANNEL=nightly + fi + + # Create Conda Env + conda create -yp ci_env python="${PYTHON_VERSION}" + conda activate /pytorch/captum/ci_env + ./scripts/install_via_pip.sh ${{ matrix.pytorch_args }} + + # Run Tests + python3 -m pytest -ra --cov=. --cov-report term-missing From 9e477da0606d55a908a8be1532459533c481d603 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Sun, 3 Sep 2023 23:45:15 -0700 Subject: [PATCH 05/49] Gpu test --- .github/workflows/test-pip-gpu.yml | 54 ++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/test-pip-gpu.yml diff --git a/.github/workflows/test-pip-gpu.yml b/.github/workflows/test-pip-gpu.yml new file mode 100644 index 0000000000..4e0ee31521 --- /dev/null +++ b/.github/workflows/test-pip-gpu.yml @@ -0,0 +1,54 @@ +name: Unit-tests for Pip install + +on: + pull_request: + push: + branches: + - nightly + - main + - release/* + + workflow_dispatch: + +env: + CHANNEL: "nightly" + +jobs: + tests: + strategy: + matrix: + python_version: ["3.8"] + cuda_arch_version: ["11.7"] + fail-fast: false + uses: pytorch/test-infra/.github/workflows/linux_job.yml@main + with: + runner: linux.g5.4xlarge.nvidia.gpu + repository: pytorch/captum + gpu-arch-type: cuda + gpu-arch-version: ${{ matrix.cuda_arch_version }} + script: | + # Set up Environment Variables + export PYTHON_VERSION="${{ matrix.python_version }}" + export VERSION="${{ matrix.cuda_arch_version }}" + export CUDATOOLKIT="pytorch-cuda=${VERSION}" + + # Set CHANNEL + if [[ (${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then + export CHANNEL=test + else + export CHANNEL=nightly + fi + + # Create Conda Env + conda create -yp ci_env python="${PYTHON_VERSION}" + conda activate /pytorch/captum/ci_env + + python3 -m pip install --upgrade pip + python3 -m pip install -e .[dev] + + # Build package + python3 -m pip install build + python3 -m build + + # Run Tests + python3 -m pytest -ra --cov=. --cov-report term-missing From 15ce461d168fa66a0b4b6566710e6f32f3638333 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 4 Sep 2023 00:00:20 -0700 Subject: [PATCH 06/49] Install pip --- scripts/install_via_pip.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/scripts/install_via_pip.sh b/scripts/install_via_pip.sh index 7fb8286fe9..56a937fb96 100755 --- a/scripts/install_via_pip.sh +++ b/scripts/install_via_pip.sh @@ -22,14 +22,8 @@ while getopts 'ndfv:' flag; do # but users should hopefully be using conda installs. # install nodejs and yarn for insights build -sudo apt-get update -sudo apt install apt-transport-https ca-certificates -curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - -curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - -echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list -sudo apt update -sudo apt install nodejs -sudo apt install yarn +sudo yum -y install nodejs +npm install --global yarn # yarn needs terminal info export TERM=xterm From 3885592c65f0dd90ec56ae8ddce8f7318586a0ca Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 4 Sep 2023 02:02:58 -0700 Subject: [PATCH 07/49] Npm install --- scripts/install_via_pip.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install_via_pip.sh b/scripts/install_via_pip.sh index 56a937fb96..7532ebf03c 100755 --- a/scripts/install_via_pip.sh +++ b/scripts/install_via_pip.sh @@ -22,7 +22,7 @@ while getopts 'ndfv:' flag; do # but users should hopefully be using conda installs. # install nodejs and yarn for insights build -sudo yum -y install nodejs +sudo yum -y install nodejs npm npm install --global yarn # yarn needs terminal info From 87cdbf60ce71976a6d7bc1d94960782c644c4866 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 4 Sep 2023 04:49:41 -0700 Subject: [PATCH 08/49] test conda --- .github/workflows/test-pip-cpu.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-pip-cpu.yml b/.github/workflows/test-pip-cpu.yml index 0ecaf4d351..a245e9ea62 100644 --- a/.github/workflows/test-pip-cpu.yml +++ b/.github/workflows/test-pip-cpu.yml @@ -38,8 +38,8 @@ jobs: fi # Create Conda Env - conda create -yp ci_env python="${PYTHON_VERSION}" - conda activate /pytorch/captum/ci_env + #conda create -yp ci_env python="${PYTHON_VERSION}" + #conda activate /pytorch/captum/ci_env ./scripts/install_via_pip.sh ${{ matrix.pytorch_args }} # Run Tests From 7c3c705ae4bd1bfdf6aea41be33fda475dd0c14f Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 4 Sep 2023 05:03:35 -0700 Subject: [PATCH 09/49] Remove env vars --- .github/workflows/test-pip-cpu.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/test-pip-cpu.yml b/.github/workflows/test-pip-cpu.yml index a245e9ea62..76f34bcef8 100644 --- a/.github/workflows/test-pip-cpu.yml +++ b/.github/workflows/test-pip-cpu.yml @@ -25,17 +25,6 @@ jobs: runner: linux.12xlarge repository: pytorch/captum script: | - # Set up Environment Variables - export PYTHON_VERSION="${{ matrix.python_version }}" - export VERSION="cpu" - export CUDATOOLKIT="cpuonly" - - # Set CHANNEL - if [[ (${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then - export CHANNEL=test - else - export CHANNEL=nightly - fi # Create Conda Env #conda create -yp ci_env python="${PYTHON_VERSION}" From 661cd1bd6c28262aab83b4fdab4d7334c49e119e Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 4 Sep 2023 05:32:25 -0700 Subject: [PATCH 10/49] Test alternatives --- .github/workflows/test-pip-cpu.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-pip-cpu.yml b/.github/workflows/test-pip-cpu.yml index 76f34bcef8..2557025e3d 100644 --- a/.github/workflows/test-pip-cpu.yml +++ b/.github/workflows/test-pip-cpu.yml @@ -25,7 +25,8 @@ jobs: runner: linux.12xlarge repository: pytorch/captum script: | - + which python + sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1 # Create Conda Env #conda create -yp ci_env python="${PYTHON_VERSION}" #conda activate /pytorch/captum/ci_env From 092bcbf997825d59cbb9bf56c2ff9624e934279e Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Wed, 13 Sep 2023 02:22:08 -0700 Subject: [PATCH 11/49] Fix --- .github/workflows/test-pip-cpu.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test-pip-cpu.yml b/.github/workflows/test-pip-cpu.yml index 2557025e3d..4fc3dee5ba 100644 --- a/.github/workflows/test-pip-cpu.yml +++ b/.github/workflows/test-pip-cpu.yml @@ -23,10 +23,9 @@ jobs: uses: pytorch/test-infra/.github/workflows/linux_job.yml@main with: runner: linux.12xlarge + docker-image: cimg/python:3.6 repository: pytorch/captum script: | - which python - sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1 # Create Conda Env #conda create -yp ci_env python="${PYTHON_VERSION}" #conda activate /pytorch/captum/ci_env From 9d5abceb23e375804b45fdac0f58fb04e172c463 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Wed, 13 Sep 2023 05:31:59 -0700 Subject: [PATCH 12/49] Revert pip script change --- scripts/install_via_pip.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/install_via_pip.sh b/scripts/install_via_pip.sh index 7532ebf03c..7fb8286fe9 100755 --- a/scripts/install_via_pip.sh +++ b/scripts/install_via_pip.sh @@ -22,8 +22,14 @@ while getopts 'ndfv:' flag; do # but users should hopefully be using conda installs. # install nodejs and yarn for insights build -sudo yum -y install nodejs npm -npm install --global yarn +sudo apt-get update +sudo apt install apt-transport-https ca-certificates +curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - +curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - +echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list +sudo apt update +sudo apt install nodejs +sudo apt install yarn # yarn needs terminal info export TERM=xterm From 8c8e85978a27bbd471cd8d3253aab3b2e66cfc91 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Wed, 13 Sep 2023 05:44:01 -0700 Subject: [PATCH 13/49] Add sudo --- scripts/install_via_pip.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install_via_pip.sh b/scripts/install_via_pip.sh index 7fb8286fe9..a5c831b18f 100755 --- a/scripts/install_via_pip.sh +++ b/scripts/install_via_pip.sh @@ -38,8 +38,8 @@ export TERM=xterm pip install --upgrade pip # install captum with dev deps -pip install -e .[dev] -BUILD_INSIGHTS=1 python setup.py develop +sudo pip install -e .[dev] +BUILD_INSIGHTS=1 sudo python setup.py develop # install other frameworks if asked for and make sure this is before pytorch if [[ $FRAMEWORKS == true ]]; then From 36783c8f9fc23057bbadd1705cbee2131613c468 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Wed, 13 Sep 2023 05:49:20 -0700 Subject: [PATCH 14/49] Remove --- scripts/install_via_pip.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install_via_pip.sh b/scripts/install_via_pip.sh index a5c831b18f..602f4a63e7 100755 --- a/scripts/install_via_pip.sh +++ b/scripts/install_via_pip.sh @@ -38,7 +38,7 @@ export TERM=xterm pip install --upgrade pip # install captum with dev deps -sudo pip install -e .[dev] +pip install -e .[dev] BUILD_INSIGHTS=1 sudo python setup.py develop # install other frameworks if asked for and make sure this is before pytorch From eee6031c9e277cd50ada6a85785666b57746399d Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Wed, 13 Sep 2023 11:39:14 -0700 Subject: [PATCH 15/49] Test permissions --- .github/workflows/test-pip-cpu.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-pip-cpu.yml b/.github/workflows/test-pip-cpu.yml index 4fc3dee5ba..f9a465f5ed 100644 --- a/.github/workflows/test-pip-cpu.yml +++ b/.github/workflows/test-pip-cpu.yml @@ -29,6 +29,7 @@ jobs: # Create Conda Env #conda create -yp ci_env python="${PYTHON_VERSION}" #conda activate /pytorch/captum/ci_env + sudo chmod -R 777 . ./scripts/install_via_pip.sh ${{ matrix.pytorch_args }} # Run Tests From 15e6d755038ae47a033d1fd8d54c9dd6b2ed4ab6 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Wed, 13 Sep 2023 11:48:36 -0700 Subject: [PATCH 16/49] Remove sudo --- scripts/install_via_pip.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install_via_pip.sh b/scripts/install_via_pip.sh index 602f4a63e7..7fb8286fe9 100755 --- a/scripts/install_via_pip.sh +++ b/scripts/install_via_pip.sh @@ -39,7 +39,7 @@ pip install --upgrade pip # install captum with dev deps pip install -e .[dev] -BUILD_INSIGHTS=1 sudo python setup.py develop +BUILD_INSIGHTS=1 python setup.py develop # install other frameworks if asked for and make sure this is before pytorch if [[ $FRAMEWORKS == true ]]; then From 023154fb574318ad6a0c0ae1c899b4c83aeaff8b Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Wed, 13 Sep 2023 12:05:22 -0700 Subject: [PATCH 17/49] Fix lint --- .github/workflows/lint.yml | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0664fcf378..9312a93b04 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: Unit-tests for Pip install +name: Captum Lint on: pull_request: @@ -15,37 +15,14 @@ env: jobs: tests: - strategy: - matrix: - python_version: ["3.6"] - fail-fast: false uses: pytorch/test-infra/.github/workflows/linux_job.yml@main with: runner: linux.12xlarge + docker-image: cimg/python:3.6 repository: pytorch/captum script: | - # Set up Environment Variables - export PYTHON_VERSION="${{ matrix.python_version }}" - export VERSION="cpu" - export CUDATOOLKIT="cpuonly" - - # Set CHANNEL - if [[ (${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then - export CHANNEL=test - else - export CHANNEL=nightly - fi - - # Create Conda Env - conda create -yp ci_env python="${PYTHON_VERSION}" - conda activate /pytorch/captum/ci_env + sudo chmod -R 777 . ./scripts/install_via_pip.sh - - # Check formatting with ufmt ufmt check . - - # Lint with flake8 flake8 - - # Run sphinx sphinx-build -WT --keep-going sphinx/source sphinx/build From d035800a25e79f97608b6e1b63ddb82dfa1d08c8 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Wed, 13 Sep 2023 12:06:48 -0700 Subject: [PATCH 18/49] Mypy checks --- .github/workflows/test-pip-cpu.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-pip-cpu.yml b/.github/workflows/test-pip-cpu.yml index f9a465f5ed..4d28d262b4 100644 --- a/.github/workflows/test-pip-cpu.yml +++ b/.github/workflows/test-pip-cpu.yml @@ -34,3 +34,4 @@ jobs: # Run Tests python3 -m pytest -ra --cov=. --cov-report term-missing + ./scripts/run_mypy.sh From 6c068dfcd256f548b02d444e5e311615ab225eee Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Thu, 14 Sep 2023 04:21:09 -0700 Subject: [PATCH 19/49] split mypy --- .github/workflows/test-pip-cpu-with-mypy.yml | 32 ++++++++++++++++++++ .github/workflows/test-pip-cpu.yml | 5 ++- 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/test-pip-cpu-with-mypy.yml diff --git a/.github/workflows/test-pip-cpu-with-mypy.yml b/.github/workflows/test-pip-cpu-with-mypy.yml new file mode 100644 index 0000000000..a0b9a7aa7b --- /dev/null +++ b/.github/workflows/test-pip-cpu-with-mypy.yml @@ -0,0 +1,32 @@ +name: Unit-tests for Pip install with mypy type checks + +on: + pull_request: + push: + branches: + - nightly + - main + - release/* + + workflow_dispatch: + +env: + CHANNEL: "nightly" + +jobs: + tests: + strategy: + matrix: + pytorch_args: ["", "-n"] + fail-fast: false + uses: pytorch/test-infra/.github/workflows/linux_job.yml@main + with: + runner: linux.12xlarge + docker-image: cimg/python:3.6 + repository: pytorch/captum + script: | + sudo chmod -R 777 . + ./scripts/install_via_pip.sh ${{ matrix.pytorch_args }} + ./scripts/run_mypy.sh + # Run Tests + python3 -m pytest -ra --cov=. --cov-report term-missing diff --git a/.github/workflows/test-pip-cpu.yml b/.github/workflows/test-pip-cpu.yml index 4d28d262b4..130c373c71 100644 --- a/.github/workflows/test-pip-cpu.yml +++ b/.github/workflows/test-pip-cpu.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: python_version: ["3.6"] - pytorch_args: ["", "-n", "-v 1.6", "-v 1.7", " -v 1.8", "-v 1.9"] + pytorch_args: ["-v 1.6", "-v 1.7", " -v 1.8", "-v 1.9"] fail-fast: false uses: pytorch/test-infra/.github/workflows/linux_job.yml@main with: @@ -31,7 +31,6 @@ jobs: #conda activate /pytorch/captum/ci_env sudo chmod -R 777 . ./scripts/install_via_pip.sh ${{ matrix.pytorch_args }} - + ./scripts/run_mypy.sh # Run Tests python3 -m pytest -ra --cov=. --cov-report term-missing - ./scripts/run_mypy.sh From d11974fd178374b3fa8ce44137669b2bd3fa203d Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Thu, 14 Sep 2023 05:08:16 -0700 Subject: [PATCH 20/49] split mypy --- .github/workflows/test-pip-cpu.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test-pip-cpu.yml b/.github/workflows/test-pip-cpu.yml index 130c373c71..907c57946c 100644 --- a/.github/workflows/test-pip-cpu.yml +++ b/.github/workflows/test-pip-cpu.yml @@ -31,6 +31,5 @@ jobs: #conda activate /pytorch/captum/ci_env sudo chmod -R 777 . ./scripts/install_via_pip.sh ${{ matrix.pytorch_args }} - ./scripts/run_mypy.sh # Run Tests python3 -m pytest -ra --cov=. --cov-report term-missing From b0b47c3cc76999d25550897264b789e83fd3bb4d Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Sun, 17 Sep 2023 11:08:26 -0700 Subject: [PATCH 21/49] Remove conda activate --- .github/workflows/test-pip-gpu.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test-pip-gpu.yml b/.github/workflows/test-pip-gpu.yml index 4e0ee31521..8e1453e138 100644 --- a/.github/workflows/test-pip-gpu.yml +++ b/.github/workflows/test-pip-gpu.yml @@ -40,9 +40,6 @@ jobs: fi # Create Conda Env - conda create -yp ci_env python="${PYTHON_VERSION}" - conda activate /pytorch/captum/ci_env - python3 -m pip install --upgrade pip python3 -m pip install -e .[dev] From 098ec4e5de5be754de713d886ab651e39bc38368 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 18 Sep 2023 03:30:30 -0700 Subject: [PATCH 22/49] Fix --- .github/workflows/test-pip-gpu.yml | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/.github/workflows/test-pip-gpu.yml b/.github/workflows/test-pip-gpu.yml index 8e1453e138..6d4c956e1f 100644 --- a/.github/workflows/test-pip-gpu.yml +++ b/.github/workflows/test-pip-gpu.yml @@ -27,20 +27,9 @@ jobs: gpu-arch-type: cuda gpu-arch-version: ${{ matrix.cuda_arch_version }} script: | - # Set up Environment Variables - export PYTHON_VERSION="${{ matrix.python_version }}" - export VERSION="${{ matrix.cuda_arch_version }}" - export CUDATOOLKIT="pytorch-cuda=${VERSION}" - - # Set CHANNEL - if [[ (${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then - export CHANNEL=test - else - export CHANNEL=nightly - fi - # Create Conda Env python3 -m pip install --upgrade pip + python3 pip install --upgrade --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html python3 -m pip install -e .[dev] # Build package From eff23be2813ceab9185266d4e46afeffc062ccb2 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 18 Sep 2023 05:13:59 -0700 Subject: [PATCH 23/49] Add option --- .github/workflows/test-pip-gpu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-pip-gpu.yml b/.github/workflows/test-pip-gpu.yml index 6d4c956e1f..a95bee1c6e 100644 --- a/.github/workflows/test-pip-gpu.yml +++ b/.github/workflows/test-pip-gpu.yml @@ -29,7 +29,7 @@ jobs: script: | # Create Conda Env python3 -m pip install --upgrade pip - python3 pip install --upgrade --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html + python3 -m pip install --upgrade --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html python3 -m pip install -e .[dev] # Build package From 09afb0b2a0a1f15b7c91e3369717f0bb3993a380 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 18 Sep 2023 05:30:18 -0700 Subject: [PATCH 24/49] Fix torch version --- .github/workflows/test-pip-gpu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-pip-gpu.yml b/.github/workflows/test-pip-gpu.yml index a95bee1c6e..2599fa47c2 100644 --- a/.github/workflows/test-pip-gpu.yml +++ b/.github/workflows/test-pip-gpu.yml @@ -29,7 +29,7 @@ jobs: script: | # Create Conda Env python3 -m pip install --upgrade pip - python3 -m pip install --upgrade --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html + python3 -m pip install torch==1.7 python3 -m pip install -e .[dev] # Build package From 939d818fecbf8ac0b2d6bd66e63bb702023f4488 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 18 Sep 2023 05:39:25 -0700 Subject: [PATCH 25/49] Fix torch version --- .github/workflows/test-pip-gpu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-pip-gpu.yml b/.github/workflows/test-pip-gpu.yml index 2599fa47c2..cf2d8cfb15 100644 --- a/.github/workflows/test-pip-gpu.yml +++ b/.github/workflows/test-pip-gpu.yml @@ -29,7 +29,7 @@ jobs: script: | # Create Conda Env python3 -m pip install --upgrade pip - python3 -m pip install torch==1.7 + python3 -m pip install torch==1.11 python3 -m pip install -e .[dev] # Build package From 626f808a5e69370e893b50fefdabb0390106d980 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 9 Oct 2023 13:18:25 -0700 Subject: [PATCH 26/49] Add script --- scripts/install_via_conda.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install_via_conda.sh b/scripts/install_via_conda.sh index 14767c047a..a290fc3299 100755 --- a/scripts/install_via_conda.sh +++ b/scripts/install_via_conda.sh @@ -35,7 +35,7 @@ else fi # install other deps -conda install -q -y pytest ipywidgets ipython scikit-learn parameterized +conda install -q -y pytest ipywidgets ipython scikit-learn parameterized werkzeug==2.2.2 conda install -q -y -c conda-forge matplotlib pytest-cov flask flask-compress # install captum From b6bcd6602dd71c8353bf67429c28d848688656b9 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 9 Oct 2023 13:26:30 -0700 Subject: [PATCH 27/49] Update pytorch version --- .github/workflows/test-pip-gpu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-pip-gpu.yml b/.github/workflows/test-pip-gpu.yml index cf2d8cfb15..727142ddfc 100644 --- a/.github/workflows/test-pip-gpu.yml +++ b/.github/workflows/test-pip-gpu.yml @@ -29,7 +29,7 @@ jobs: script: | # Create Conda Env python3 -m pip install --upgrade pip - python3 -m pip install torch==1.11 + python3 -m pip install torch --index-url https://download.pytorch.org/whl/cu118 python3 -m pip install -e .[dev] # Build package From 12961637254141e643fb6e4eaae41219abc7a4dc Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 9 Oct 2023 13:30:53 -0700 Subject: [PATCH 28/49] Switch to 11.8 --- .github/workflows/test-pip-gpu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-pip-gpu.yml b/.github/workflows/test-pip-gpu.yml index 727142ddfc..7593d5357e 100644 --- a/.github/workflows/test-pip-gpu.yml +++ b/.github/workflows/test-pip-gpu.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: python_version: ["3.8"] - cuda_arch_version: ["11.7"] + cuda_arch_version: ["11.8"] fail-fast: false uses: pytorch/test-infra/.github/workflows/linux_job.yml@main with: From 4c99efc8cefb2843f993bdaf4a4d0e5eeb298687 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 9 Oct 2023 13:48:43 -0700 Subject: [PATCH 29/49] Upgrade cuda --- .github/workflows/test-pip-gpu.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test-pip-gpu.yml b/.github/workflows/test-pip-gpu.yml index 7593d5357e..8f310f4bfd 100644 --- a/.github/workflows/test-pip-gpu.yml +++ b/.github/workflows/test-pip-gpu.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: python_version: ["3.8"] - cuda_arch_version: ["11.8"] + cuda_arch_version: ["12.1"] fail-fast: false uses: pytorch/test-infra/.github/workflows/linux_job.yml@main with: @@ -29,7 +29,6 @@ jobs: script: | # Create Conda Env python3 -m pip install --upgrade pip - python3 -m pip install torch --index-url https://download.pytorch.org/whl/cu118 python3 -m pip install -e .[dev] # Build package From 65d837fd4ddc084ac9be9bd6f29636e3c751f45c Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 9 Oct 2023 14:06:24 -0700 Subject: [PATCH 30/49] Change architecture --- .github/workflows/test-pip-gpu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-pip-gpu.yml b/.github/workflows/test-pip-gpu.yml index 8f310f4bfd..da7eeeb223 100644 --- a/.github/workflows/test-pip-gpu.yml +++ b/.github/workflows/test-pip-gpu.yml @@ -22,7 +22,7 @@ jobs: fail-fast: false uses: pytorch/test-infra/.github/workflows/linux_job.yml@main with: - runner: linux.g5.4xlarge.nvidia.gpu + runner: linux.4xlarge.nvidia.gpu repository: pytorch/captum gpu-arch-type: cuda gpu-arch-version: ${{ matrix.cuda_arch_version }} From 6eeb0c06ac1dceefa74fd6aeea0b524cf24c0069 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 9 Oct 2023 14:34:57 -0700 Subject: [PATCH 31/49] Remove circleci --- .circleci/config.yml | 89 -------------------------------- tests/attr/test_gradient_shap.py | 2 + 2 files changed, 2 insertions(+), 89 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 334536a1d1..fc2a5fbeb2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -134,95 +134,6 @@ commands: sudo apt-get --yes --force-yes install cuda jobs: - - lint_py36: - docker: - - image: cimg/python:3.6 - steps: - - checkout - - pip_install - - ufmt_check - - lint_flake8 - - sphinx - - test_py36_pip: - docker: - - image: cimg/python:3.6 - steps: - - checkout - - pip_install: - args: "-n" - - mypy_check - - unit_tests - - test_py36_pip_release: - docker: - - image: cimg/python:3.6 - steps: - - checkout - - pip_install - - mypy_check - - unit_tests - - test_py36_pip_torch_1_6: - docker: - - image: cimg/python:3.6 - steps: - - checkout - - pip_install: - args: "-v 1.6" - - unit_tests - - test_py36_pip_torch_1_7: - docker: - - image: cimg/python:3.6 - steps: - - checkout - - pip_install: - args: "-v 1.7" - - unit_tests - - test_py36_pip_torch_1_8: - docker: - - image: cimg/python:3.6 - steps: - - checkout - - pip_install: - args: "-v 1.8" - - unit_tests - - test_py36_pip_torch_1_9: - docker: - - image: cimg/python:3.6 - steps: - - checkout - - pip_install: - args: "-v 1.9" - - unit_tests - - - test_py37_conda: - docker: - - image: continuumio/miniconda3 - steps: - - checkout - - conda_install: - args: "-n" - - unit_tests - - - test_cuda_multi_gpu: - machine: - image: ubuntu-2004:202201-02 - resource_class: gpu.nvidia.medium.multi - steps: - - checkout - - install_cuda - - py_3_7_setup - - simple_pip_install - - build_package - - unit_tests - auto_deploy_site: docker: - image: cimg/python:3.6-node diff --git a/tests/attr/test_gradient_shap.py b/tests/attr/test_gradient_shap.py index 56b0c544b7..2b66a5b09d 100644 --- a/tests/attr/test_gradient_shap.py +++ b/tests/attr/test_gradient_shap.py @@ -262,6 +262,8 @@ def _assert_attribution_delta( if isinstance(inputs, tuple): bsz = inputs[0].shape[0] else: + + bsz = inputs.shape[0] test.assertEqual([bsz * n_samples], list(delta.shape)) From 47d224a85789ab390177d0cd124384db45d40207 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 9 Oct 2023 14:45:22 -0700 Subject: [PATCH 32/49] Add deploy --- .github/workflows/deploy.yml | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000000..c732ab0fd7 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,42 @@ +name: Captum Deploy Website + +on: + pull_request: + push: + branches: + - nightly + - main + - release/* + + workflow_dispatch: + +env: + CHANNEL: "nightly" + +jobs: + tests: + uses: pytorch/test-infra/.github/workflows/linux_job.yml@main + with: + runner: linux.12xlarge + docker-image: cimg/python:3.6-node + repository: pytorch/captum + script: | + sudo chmod -R 777 . + ./scripts/install_via_pip.sh -n -d + + if [[ $CIRCLE_PROJECT_USERNAME == "pytorch" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then + git config --global user.email "docusaurus-bot@users.noreply.github.com" + git config --global user.name "Captum website deployment script" + echo "machine github.com login docusaurus-bot password $DOCUSAURUS_GITHUB_TOKEN" > ~/.netrc + fi + + if ! git diff --name-only HEAD^ | grep -E "(^captum\/.*)|(^\.circleci\/.*)|(^docs\/.*)|(^website\/.*)|(^scripts\/.*)|(^sphinx\/.*)|(^tutorials\/.*)"; then + echo "Skipping deploy. No relevant website files have changed" + elif [[ $CIRCLE_PROJECT_USERNAME == "pytorch" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then + mkdir -p website/static/.circleci && cp -a .circleci/. website/static/.circleci/. + ./scripts/build_docs.sh -b + cd website + GIT_USER=docusaurus-bot yarn run publish-gh-pages + else + echo "Skipping deploy." + fi From be2ea2e12820d27bdc533a00e8033bb9334d0875 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 9 Oct 2023 14:59:02 -0700 Subject: [PATCH 33/49] Fixes --- .circleci/config.yml | 194 ------------------------------- tests/attr/test_gradient_shap.py | 2 - 2 files changed, 196 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index fc2a5fbeb2..0000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,194 +0,0 @@ -version: 2.1 - -commands: - - pip_install: - description: "Install dependencies via pip" - parameters: - args: - type: string - default: "" - steps: - - run: - name: "Install dependencies via pip" - command: ./scripts/install_via_pip.sh << parameters.args >> - - conda_install: - description: "Install dependencies via conda" - parameters: - args: - type: string - default: "" - steps: - - run: - name: "Install dependencies via conda" - command: ./scripts/install_via_conda.sh << parameters.args >> - - lint_flake8: - description: "Lint with flake8" - steps: - - run: - name: "Lint with flake8" - command: flake8 - - ufmt_check: - description: "Check formatting with ufmt" - steps: - - run: - name: "Check formatting with ufmt" - command: ufmt check . - - mypy_check: - description: "Static type checking with mypy" - steps: - - run: - name: "Mypy checks" - command: ./scripts/run_mypy.sh - - unit_tests: - description: "Run unit tests" - steps: - - run: - name: "Run unit tests" - command: python -m pytest -ra --cov=. --cov-report term-missing - - sphinx: - description: "Run sphinx" - steps: - - run: - name: "Run sphinx" - command: sphinx-build -WT --keep-going sphinx/source sphinx/build - - configure_github_bot: - description: "Configure Docusaurus GitHub bot" - steps: - - run: - name: "Configure Docusaurus GitHub bot" - # Do not do this if we don't have the right org (pytorch), or if this is just a PR - command: | - if [[ $CIRCLE_PROJECT_USERNAME == "pytorch" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then - git config --global user.email "docusaurus-bot@users.noreply.github.com" - git config --global user.name "Captum website deployment script" - echo "machine github.com login docusaurus-bot password $DOCUSAURUS_GITHUB_TOKEN" > ~/.netrc - fi - - deploy_site: - description: "Deploy website to GitHub Pages" - steps: - - run: - name: "Deploy website to GitHub Pages" - # TODO: make the installation above conditional on there being relevant changes (no need to install if there are none) - command: | - if ! git diff --name-only HEAD^ | grep -E "(^captum\/.*)|(^\.circleci\/.*)|(^docs\/.*)|(^website\/.*)|(^scripts\/.*)|(^sphinx\/.*)|(^tutorials\/.*)"; then - echo "Skipping deploy. No relevant website files have changed" - elif [[ $CIRCLE_PROJECT_USERNAME == "pytorch" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then - mkdir -p website/static/.circleci && cp -a .circleci/. website/static/.circleci/. - ./scripts/build_docs.sh -b - cd website - GIT_USER=docusaurus-bot yarn run publish-gh-pages - else - echo "Skipping deploy." - fi - - simple_pip_install: - description: "Simple install of Captum via pip. Does not include extra dependencies such as yarn and nodejs needed for building insights." - steps: - - run: - name: "Simple PIP install" - command: | - python -m pip install --upgrade pip - python -m pip install -e .[dev] - - build_package: - description: "Build the source and wheel packages" - steps: - - run: - name: "Build captum" - command: | - python -m pip install build - python -m build - - py_3_7_setup: - description: "Set python version to 3.7 and install pip and pytest" - steps: - - run: - name: "Switch to Python v3.7" - command: | - pyenv versions - pyenv install 3.7.0 - pyenv global 3.7.0 - - install_cuda: - description: "Install CUDA for GPU Machine" - steps: - - run: - name: "Install CUDA" - command: | - sudo dpkg --configure -a - wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin - sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600 - wget https://developer.download.nvidia.com/compute/cuda/11.4.2/local_installers/cuda-repo-ubuntu2004-11-4-local_11.4.2-470.57.02-1_amd64.deb - sudo dpkg -i cuda-repo-ubuntu2004-11-4-local_11.4.2-470.57.02-1_amd64.deb - sudo apt-key add /var/cuda-repo-ubuntu2004-11-4-local/7fa2af80.pub - sudo apt-get update - sudo apt-get --yes --force-yes install cuda - -jobs: - auto_deploy_site: - docker: - - image: cimg/python:3.6-node - steps: - - checkout - - pip_install: - args: "-n -d" - - configure_github_bot - - deploy_site - - -aliases: - - - &exclude_ghpages_fbconfig - branches: - ignore: - - gh-pages - - fb-config - - -workflows: - - lint_test_and_deploy_site: - jobs: - - lint_py36: - filters: *exclude_ghpages_fbconfig - - test_py36_pip: - filters: *exclude_ghpages_fbconfig - - test_py36_pip_release: - filters: *exclude_ghpages_fbconfig - - test_py37_conda: - filters: *exclude_ghpages_fbconfig - - test_py36_pip_torch_1_6: - filters: *exclude_ghpages_fbconfig - - test_py36_pip_torch_1_7: - filters: *exclude_ghpages_fbconfig - - test_py36_pip_torch_1_8: - filters: *exclude_ghpages_fbconfig - - test_py36_pip_torch_1_9: - filters: *exclude_ghpages_fbconfig - - test_cuda_multi_gpu: - filters: *exclude_ghpages_fbconfig - - - auto_deploy_site: - requires: - - lint_py36 - - test_py36_pip - - test_py36_pip_release - - test_py37_conda - - test_py36_pip_torch_1_6 - - test_py36_pip_torch_1_7 - - test_py36_pip_torch_1_8 - - test_py36_pip_torch_1_9 - - test_cuda_multi_gpu - filters: - branches: - only: - - master diff --git a/tests/attr/test_gradient_shap.py b/tests/attr/test_gradient_shap.py index 2b66a5b09d..56b0c544b7 100644 --- a/tests/attr/test_gradient_shap.py +++ b/tests/attr/test_gradient_shap.py @@ -262,8 +262,6 @@ def _assert_attribution_delta( if isinstance(inputs, tuple): bsz = inputs[0].shape[0] else: - - bsz = inputs.shape[0] test.assertEqual([bsz * n_samples], list(delta.shape)) From a21247f4cf39f9d1597ce941b70c2ff6c7598656 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 9 Oct 2023 15:03:11 -0700 Subject: [PATCH 34/49] Remove ci env vars --- .github/workflows/deploy.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c732ab0fd7..38d2587c36 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -24,19 +24,15 @@ jobs: sudo chmod -R 777 . ./scripts/install_via_pip.sh -n -d - if [[ $CIRCLE_PROJECT_USERNAME == "pytorch" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then - git config --global user.email "docusaurus-bot@users.noreply.github.com" - git config --global user.name "Captum website deployment script" - echo "machine github.com login docusaurus-bot password $DOCUSAURUS_GITHUB_TOKEN" > ~/.netrc - fi + git config --global user.email "docusaurus-bot@users.noreply.github.com" + git config --global user.name "Captum website deployment script" + echo "machine github.com login docusaurus-bot password $DOCUSAURUS_GITHUB_TOKEN" > ~/.netrc if ! git diff --name-only HEAD^ | grep -E "(^captum\/.*)|(^\.circleci\/.*)|(^docs\/.*)|(^website\/.*)|(^scripts\/.*)|(^sphinx\/.*)|(^tutorials\/.*)"; then echo "Skipping deploy. No relevant website files have changed" - elif [[ $CIRCLE_PROJECT_USERNAME == "pytorch" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then + else mkdir -p website/static/.circleci && cp -a .circleci/. website/static/.circleci/. ./scripts/build_docs.sh -b cd website GIT_USER=docusaurus-bot yarn run publish-gh-pages - else - echo "Skipping deploy." fi From 90f97d9f092e8861ba7edd95ec49902c7663ed91 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 9 Oct 2023 15:43:15 -0700 Subject: [PATCH 35/49] Deploy fix --- .circleci/config.yml | 164 +++++++++++++++++++++++++++++++++++ .github/workflows/deploy.yml | 2 + 2 files changed, 166 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000000..1d4da01c4d --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,164 @@ +version: 2.1 + +commands: + + pip_install: + description: "Install dependencies via pip" + parameters: + args: + type: string + default: "" + steps: + - run: + name: "Install dependencies via pip" + command: ./scripts/install_via_pip.sh << parameters.args >> + + conda_install: + description: "Install dependencies via conda" + parameters: + args: + type: string + default: "" + steps: + - run: + name: "Install dependencies via conda" + command: ./scripts/install_via_conda.sh << parameters.args >> + + lint_flake8: + description: "Lint with flake8" + steps: + - run: + name: "Lint with flake8" + command: flake8 + + ufmt_check: + description: "Check formatting with ufmt" + steps: + - run: + name: "Check formatting with ufmt" + command: ufmt check . + + mypy_check: + description: "Static type checking with mypy" + steps: + - run: + name: "Mypy checks" + command: ./scripts/run_mypy.sh + + unit_tests: + description: "Run unit tests" + steps: + - run: + name: "Run unit tests" + command: python -m pytest -ra --cov=. --cov-report term-missing + + sphinx: + description: "Run sphinx" + steps: + - run: + name: "Run sphinx" + command: sphinx-build -WT --keep-going sphinx/source sphinx/build + + configure_github_bot: + description: "Configure Docusaurus GitHub bot" + steps: + - run: + name: "Configure Docusaurus GitHub bot" + # Do not do this if we don't have the right org (pytorch), or if this is just a PR + command: | + echo $DOCUSAURUS_GITHUB_TOKEN + if [[ $CIRCLE_PROJECT_USERNAME == "pytorch" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then + git config --global user.email "docusaurus-bot@users.noreply.github.com" + git config --global user.name "Captum website deployment script" + echo "machine github.com login docusaurus-bot password $DOCUSAURUS_GITHUB_TOKEN" > ~/.netrc + fi + + deploy_site: + description: "Deploy website to GitHub Pages" + steps: + - run: + name: "Deploy website to GitHub Pages" + # TODO: make the installation above conditional on there being relevant changes (no need to install if there are none) + command: | + if ! git diff --name-only HEAD^ | grep -E "(^captum\/.*)|(^\.circleci\/.*)|(^docs\/.*)|(^website\/.*)|(^scripts\/.*)|(^sphinx\/.*)|(^tutorials\/.*)"; then + echo "Skipping deploy. No relevant website files have changed" + elif [[ $CIRCLE_PROJECT_USERNAME == "pytorch" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then + mkdir -p website/static/.circleci && cp -a .circleci/. website/static/.circleci/. + ./scripts/build_docs.sh -b + cd website + GIT_USER=docusaurus-bot yarn run publish-gh-pages + else + echo "Skipping deploy." + fi + + simple_pip_install: + description: "Simple install of Captum via pip. Does not include extra dependencies such as yarn and nodejs needed for building insights." + steps: + - run: + name: "Simple PIP install" + command: | + python -m pip install --upgrade pip + python -m pip install -e .[dev] + + build_package: + description: "Build the source and wheel packages" + steps: + - run: + name: "Build captum" + command: | + python -m pip install build + python -m build + + py_3_7_setup: + description: "Set python version to 3.7 and install pip and pytest" + steps: + - run: + name: "Switch to Python v3.7" + command: | + pyenv versions + pyenv install 3.7.0 + pyenv global 3.7.0 + + install_cuda: + description: "Install CUDA for GPU Machine" + steps: + - run: + name: "Install CUDA" + command: | + sudo dpkg --configure -a + wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin + sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600 + wget https://developer.download.nvidia.com/compute/cuda/11.4.2/local_installers/cuda-repo-ubuntu2004-11-4-local_11.4.2-470.57.02-1_amd64.deb + sudo dpkg -i cuda-repo-ubuntu2004-11-4-local_11.4.2-470.57.02-1_amd64.deb + sudo apt-key add /var/cuda-repo-ubuntu2004-11-4-local/7fa2af80.pub + sudo apt-get update + sudo apt-get --yes --force-yes install cuda +jobs: + + lint_py36: + docker: + - image: cimg/python:3.6 + steps: + - checkout + - configure_github_bot + - pip_install + - ufmt_check + - lint_flake8 + - sphinx + + +aliases: + + - &exclude_ghpages_fbconfig + branches: + ignore: + - gh-pages + - fb-config + + +workflows: + + lint_test_and_deploy_site: + jobs: + - lint_py36: + filters: *exclude_ghpages_fbconfig diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 38d2587c36..241987be32 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -20,6 +20,8 @@ jobs: runner: linux.12xlarge docker-image: cimg/python:3.6-node repository: pytorch/captum + env: + DOCUSAURUS_GITHUB_TOKEN: ${{ secrets.DOCUSAURUS_GITHUB_TOKEN }} script: | sudo chmod -R 777 . ./scripts/install_via_pip.sh -n -d From c8b3c5a9705211e3367b951657aab85b246456a5 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 9 Oct 2023 15:50:31 -0700 Subject: [PATCH 36/49] Remove workflows --- .circleci/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1d4da01c4d..a8af162a1c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -66,7 +66,6 @@ commands: name: "Configure Docusaurus GitHub bot" # Do not do this if we don't have the right org (pytorch), or if this is just a PR command: | - echo $DOCUSAURUS_GITHUB_TOKEN if [[ $CIRCLE_PROJECT_USERNAME == "pytorch" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then git config --global user.email "docusaurus-bot@users.noreply.github.com" git config --global user.name "Captum website deployment script" From e55ea502820aa4fca461b1d93227e37128a343d2 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 9 Oct 2023 15:52:13 -0700 Subject: [PATCH 37/49] Fix --- .circleci/config.yml | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a8af162a1c..1629d76860 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -134,30 +134,9 @@ commands: sudo apt-get --yes --force-yes install cuda jobs: - lint_py36: - docker: - - image: cimg/python:3.6 - steps: - - checkout - - configure_github_bot - - pip_install - - ufmt_check - - lint_flake8 - - sphinx aliases: - - &exclude_ghpages_fbconfig - branches: - ignore: - - gh-pages - - fb-config - workflows: - - lint_test_and_deploy_site: - jobs: - - lint_py36: - filters: *exclude_ghpages_fbconfig From de848942905c896e0faad4158b0b51657647db7a Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Mon, 9 Oct 2023 15:54:32 -0700 Subject: [PATCH 38/49] Add job --- .circleci/config.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1629d76860..240d46d235 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -133,6 +133,15 @@ commands: sudo apt-get update sudo apt-get --yes --force-yes install cuda jobs: + lint_py36: + docker: + - image: cimg/python:3.6 + steps: + - checkout + - pip_install + - ufmt_check + - lint_flake8 + - sphinx From 345c71e395ae030f394142dd3707a7b2bf4e309c Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Thu, 12 Oct 2023 12:43:43 -0700 Subject: [PATCH 39/49] Fixes --- .circleci/config.yml | 151 ----------------------- .github/workflows/deploy.yml | 40 ------ .github/workflows/test-pip-gpu.yml | 6 +- .github/workflows/test-website-depoy.yml | 31 +++++ .github/workflows/website-depoy.yml | 53 ++++++++ scripts/install_via_pip.sh | 14 +-- 6 files changed, 94 insertions(+), 201 deletions(-) delete mode 100644 .circleci/config.yml delete mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/test-website-depoy.yml create mode 100644 .github/workflows/website-depoy.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 240d46d235..0000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,151 +0,0 @@ -version: 2.1 - -commands: - - pip_install: - description: "Install dependencies via pip" - parameters: - args: - type: string - default: "" - steps: - - run: - name: "Install dependencies via pip" - command: ./scripts/install_via_pip.sh << parameters.args >> - - conda_install: - description: "Install dependencies via conda" - parameters: - args: - type: string - default: "" - steps: - - run: - name: "Install dependencies via conda" - command: ./scripts/install_via_conda.sh << parameters.args >> - - lint_flake8: - description: "Lint with flake8" - steps: - - run: - name: "Lint with flake8" - command: flake8 - - ufmt_check: - description: "Check formatting with ufmt" - steps: - - run: - name: "Check formatting with ufmt" - command: ufmt check . - - mypy_check: - description: "Static type checking with mypy" - steps: - - run: - name: "Mypy checks" - command: ./scripts/run_mypy.sh - - unit_tests: - description: "Run unit tests" - steps: - - run: - name: "Run unit tests" - command: python -m pytest -ra --cov=. --cov-report term-missing - - sphinx: - description: "Run sphinx" - steps: - - run: - name: "Run sphinx" - command: sphinx-build -WT --keep-going sphinx/source sphinx/build - - configure_github_bot: - description: "Configure Docusaurus GitHub bot" - steps: - - run: - name: "Configure Docusaurus GitHub bot" - # Do not do this if we don't have the right org (pytorch), or if this is just a PR - command: | - if [[ $CIRCLE_PROJECT_USERNAME == "pytorch" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then - git config --global user.email "docusaurus-bot@users.noreply.github.com" - git config --global user.name "Captum website deployment script" - echo "machine github.com login docusaurus-bot password $DOCUSAURUS_GITHUB_TOKEN" > ~/.netrc - fi - - deploy_site: - description: "Deploy website to GitHub Pages" - steps: - - run: - name: "Deploy website to GitHub Pages" - # TODO: make the installation above conditional on there being relevant changes (no need to install if there are none) - command: | - if ! git diff --name-only HEAD^ | grep -E "(^captum\/.*)|(^\.circleci\/.*)|(^docs\/.*)|(^website\/.*)|(^scripts\/.*)|(^sphinx\/.*)|(^tutorials\/.*)"; then - echo "Skipping deploy. No relevant website files have changed" - elif [[ $CIRCLE_PROJECT_USERNAME == "pytorch" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then - mkdir -p website/static/.circleci && cp -a .circleci/. website/static/.circleci/. - ./scripts/build_docs.sh -b - cd website - GIT_USER=docusaurus-bot yarn run publish-gh-pages - else - echo "Skipping deploy." - fi - - simple_pip_install: - description: "Simple install of Captum via pip. Does not include extra dependencies such as yarn and nodejs needed for building insights." - steps: - - run: - name: "Simple PIP install" - command: | - python -m pip install --upgrade pip - python -m pip install -e .[dev] - - build_package: - description: "Build the source and wheel packages" - steps: - - run: - name: "Build captum" - command: | - python -m pip install build - python -m build - - py_3_7_setup: - description: "Set python version to 3.7 and install pip and pytest" - steps: - - run: - name: "Switch to Python v3.7" - command: | - pyenv versions - pyenv install 3.7.0 - pyenv global 3.7.0 - - install_cuda: - description: "Install CUDA for GPU Machine" - steps: - - run: - name: "Install CUDA" - command: | - sudo dpkg --configure -a - wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin - sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600 - wget https://developer.download.nvidia.com/compute/cuda/11.4.2/local_installers/cuda-repo-ubuntu2004-11-4-local_11.4.2-470.57.02-1_amd64.deb - sudo dpkg -i cuda-repo-ubuntu2004-11-4-local_11.4.2-470.57.02-1_amd64.deb - sudo apt-key add /var/cuda-repo-ubuntu2004-11-4-local/7fa2af80.pub - sudo apt-get update - sudo apt-get --yes --force-yes install cuda -jobs: - lint_py36: - docker: - - image: cimg/python:3.6 - steps: - - checkout - - pip_install - - ufmt_check - - lint_flake8 - - sphinx - - - -aliases: - - -workflows: diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 241987be32..0000000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Captum Deploy Website - -on: - pull_request: - push: - branches: - - nightly - - main - - release/* - - workflow_dispatch: - -env: - CHANNEL: "nightly" - -jobs: - tests: - uses: pytorch/test-infra/.github/workflows/linux_job.yml@main - with: - runner: linux.12xlarge - docker-image: cimg/python:3.6-node - repository: pytorch/captum - env: - DOCUSAURUS_GITHUB_TOKEN: ${{ secrets.DOCUSAURUS_GITHUB_TOKEN }} - script: | - sudo chmod -R 777 . - ./scripts/install_via_pip.sh -n -d - - git config --global user.email "docusaurus-bot@users.noreply.github.com" - git config --global user.name "Captum website deployment script" - echo "machine github.com login docusaurus-bot password $DOCUSAURUS_GITHUB_TOKEN" > ~/.netrc - - if ! git diff --name-only HEAD^ | grep -E "(^captum\/.*)|(^\.circleci\/.*)|(^docs\/.*)|(^website\/.*)|(^scripts\/.*)|(^sphinx\/.*)|(^tutorials\/.*)"; then - echo "Skipping deploy. No relevant website files have changed" - else - mkdir -p website/static/.circleci && cp -a .circleci/. website/static/.circleci/. - ./scripts/build_docs.sh -b - cd website - GIT_USER=docusaurus-bot yarn run publish-gh-pages - fi diff --git a/.github/workflows/test-pip-gpu.yml b/.github/workflows/test-pip-gpu.yml index da7eeeb223..5eb65f46f3 100644 --- a/.github/workflows/test-pip-gpu.yml +++ b/.github/workflows/test-pip-gpu.yml @@ -28,11 +28,11 @@ jobs: gpu-arch-version: ${{ matrix.cuda_arch_version }} script: | # Create Conda Env - python3 -m pip install --upgrade pip - python3 -m pip install -e .[dev] + python3 -m pip install --upgrade pip --progress-bar off + python3 -m pip install -e .[dev] --progress-bar off # Build package - python3 -m pip install build + python3 -m pip install build --progress-bar off python3 -m build # Run Tests diff --git a/.github/workflows/test-website-depoy.yml b/.github/workflows/test-website-depoy.yml new file mode 100644 index 0000000000..d4f3e273cf --- /dev/null +++ b/.github/workflows/test-website-depoy.yml @@ -0,0 +1,31 @@ +name: Test deployment + +on: + pull_request: + branches: + - main + # Review gh actions docs if you want to further define triggers, paths, etc + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on + +jobs: + test-deploy: + name: Test deployment + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + cache: yarn + + - name: Setup / build docs + run: | + sudo chmod -R 777 . + ./scripts/install_via_pip.sh -n -d + ./scripts/build_docs.sh -b + cd website + + - name: Install dependencies + run: yarn install --frozen-lockfile + - name: Test build website + run: yarn build diff --git a/.github/workflows/website-depoy.yml b/.github/workflows/website-depoy.yml new file mode 100644 index 0000000000..2ec2c23b07 --- /dev/null +++ b/.github/workflows/website-depoy.yml @@ -0,0 +1,53 @@ +name: Deploy to GitHub Pages + +on: + push: + branches: + - main + # Review gh actions docs if you want to further define triggers, paths, etc + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on + +permissions: + contents: write + +jobs: + deploy: + name: Deploy to GitHub Pages + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + cache: yarn + - name: Setup + run: mkdir -p website/static/.circleci && cp -a .circleci/. website/static/.circleci/. + ./scripts/build_docs.sh -b + + - name: Setup / build docs + run: | + sudo chmod -R 777 . + ./scripts/install_via_pip.sh -n -d + ./scripts/build_docs.sh -b + cd website + + - name: Install dependencies + run: yarn install --frozen-lockfile + - name: Build website + run: yarn build + + # Popular action to deploy to GitHub Pages: + # Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + # Build output to publish to the `gh-pages` branch: + publish_dir: ./build + # The following lines assign commit authorship to the official + # GH-Actions bot for deploys to `gh-pages` branch: + # https://github.com/actions/checkout/issues/13#issuecomment-724415212 + # The GH actions bot is used by default if you didn't specify the two fields. + # You can swap them out with your own user credentials. + user_name: github-actions[bot] + user_email: 41898282+github-actions[bot]@users.noreply.github.com diff --git a/scripts/install_via_pip.sh b/scripts/install_via_pip.sh index 7fb8286fe9..825804fa76 100755 --- a/scripts/install_via_pip.sh +++ b/scripts/install_via_pip.sh @@ -35,30 +35,30 @@ sudo apt install yarn export TERM=xterm # upgrade pip -pip install --upgrade pip +pip install --upgrade pip --progress-bar off # install captum with dev deps -pip install -e .[dev] +pip install -e .[dev] --progress-bar off BUILD_INSIGHTS=1 python setup.py develop # install other frameworks if asked for and make sure this is before pytorch if [[ $FRAMEWORKS == true ]]; then - pip install pytext-nlp + pip install pytext-nlp --progress-bar off fi # install pytorch nightly if asked for if [[ $PYTORCH_NIGHTLY == true ]]; then - pip install --upgrade --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html + pip install --upgrade --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html --progress-bar off else # If no version is specified, upgrade to the latest release. if [[ $CHOSEN_TORCH_VERSION == -1 ]]; then - pip install --upgrade torch + pip install --upgrade torch --progress-bar off else - pip install torch==$CHOSEN_TORCH_VERSION + pip install torch==$CHOSEN_TORCH_VERSION --progress-bar off fi fi # install deployment bits if asked for if [[ $DEPLOY == true ]]; then - pip install beautifulsoup4 ipython nbconvert==5.6.1 + pip install beautifulsoup4 ipython nbconvert==5.6.1 --progress-bar off fi From 0d83f102b1ffb4d80d5b756500ae35d140e4363a Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Thu, 12 Oct 2023 12:49:29 -0700 Subject: [PATCH 40/49] Clean up --- .github/workflows/lint.yml | 7 +------ .github/workflows/test-conda-cpu.yml | 4 +--- .github/workflows/test-pip-cpu-with-mypy.yml | 7 +------ .github/workflows/test-pip-cpu.yml | 11 +---------- .github/workflows/test-pip-gpu.yml | 7 +------ .github/workflows/test-website-depoy.yml | 2 +- .github/workflows/website-depoy.yml | 2 +- 7 files changed, 7 insertions(+), 33 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9312a93b04..0aa7c68b4c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,15 +4,10 @@ on: pull_request: push: branches: - - nightly - - main - - release/* + - master workflow_dispatch: -env: - CHANNEL: "nightly" - jobs: tests: uses: pytorch/test-infra/.github/workflows/linux_job.yml@main diff --git a/.github/workflows/test-conda-cpu.yml b/.github/workflows/test-conda-cpu.yml index acf21543f9..45eda3ea2f 100644 --- a/.github/workflows/test-conda-cpu.yml +++ b/.github/workflows/test-conda-cpu.yml @@ -4,9 +4,7 @@ on: pull_request: push: branches: - - nightly - - main - - release/* + - master workflow_dispatch: diff --git a/.github/workflows/test-pip-cpu-with-mypy.yml b/.github/workflows/test-pip-cpu-with-mypy.yml index a0b9a7aa7b..4a721cb85b 100644 --- a/.github/workflows/test-pip-cpu-with-mypy.yml +++ b/.github/workflows/test-pip-cpu-with-mypy.yml @@ -4,15 +4,10 @@ on: pull_request: push: branches: - - nightly - - main - - release/* + - master workflow_dispatch: -env: - CHANNEL: "nightly" - jobs: tests: strategy: diff --git a/.github/workflows/test-pip-cpu.yml b/.github/workflows/test-pip-cpu.yml index 907c57946c..b1e6028226 100644 --- a/.github/workflows/test-pip-cpu.yml +++ b/.github/workflows/test-pip-cpu.yml @@ -4,20 +4,14 @@ on: pull_request: push: branches: - - nightly - - main - - release/* + - master workflow_dispatch: -env: - CHANNEL: "nightly" - jobs: tests: strategy: matrix: - python_version: ["3.6"] pytorch_args: ["-v 1.6", "-v 1.7", " -v 1.8", "-v 1.9"] fail-fast: false uses: pytorch/test-infra/.github/workflows/linux_job.yml@main @@ -26,9 +20,6 @@ jobs: docker-image: cimg/python:3.6 repository: pytorch/captum script: | - # Create Conda Env - #conda create -yp ci_env python="${PYTHON_VERSION}" - #conda activate /pytorch/captum/ci_env sudo chmod -R 777 . ./scripts/install_via_pip.sh ${{ matrix.pytorch_args }} # Run Tests diff --git a/.github/workflows/test-pip-gpu.yml b/.github/workflows/test-pip-gpu.yml index 5eb65f46f3..624b9430c6 100644 --- a/.github/workflows/test-pip-gpu.yml +++ b/.github/workflows/test-pip-gpu.yml @@ -4,15 +4,10 @@ on: pull_request: push: branches: - - nightly - - main - - release/* + - master workflow_dispatch: -env: - CHANNEL: "nightly" - jobs: tests: strategy: diff --git a/.github/workflows/test-website-depoy.yml b/.github/workflows/test-website-depoy.yml index d4f3e273cf..1c9b7315f9 100644 --- a/.github/workflows/test-website-depoy.yml +++ b/.github/workflows/test-website-depoy.yml @@ -3,7 +3,7 @@ name: Test deployment on: pull_request: branches: - - main + - master # Review gh actions docs if you want to further define triggers, paths, etc # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on diff --git a/.github/workflows/website-depoy.yml b/.github/workflows/website-depoy.yml index 2ec2c23b07..408395c6d3 100644 --- a/.github/workflows/website-depoy.yml +++ b/.github/workflows/website-depoy.yml @@ -3,7 +3,7 @@ name: Deploy to GitHub Pages on: push: branches: - - main + - master # Review gh actions docs if you want to further define triggers, paths, etc # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on From 627e13b94ef50db0e907aef44a14ed7e2385ae99 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Fri, 20 Oct 2023 16:20:33 -0700 Subject: [PATCH 41/49] Remove insights from website pipeline --- .github/workflows/test-website-depoy.yml | 5 ++++- .github/workflows/website-depoy.yml | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-website-depoy.yml b/.github/workflows/test-website-depoy.yml index 1c9b7315f9..9b64c59605 100644 --- a/.github/workflows/test-website-depoy.yml +++ b/.github/workflows/test-website-depoy.yml @@ -21,11 +21,14 @@ jobs: - name: Setup / build docs run: | sudo chmod -R 777 . - ./scripts/install_via_pip.sh -n -d + python3 -m pip install --upgrade pip --progress-bar off + python3 -m pip install -e .[dev] --progress-bar off + python3 -m pip install beautifulsoup4 ipython nbconvert==5.6.1 --progress-bar off ./scripts/build_docs.sh -b cd website - name: Install dependencies run: yarn install --frozen-lockfile + - name: Test build website run: yarn build diff --git a/.github/workflows/website-depoy.yml b/.github/workflows/website-depoy.yml index 408395c6d3..5b9070ef7e 100644 --- a/.github/workflows/website-depoy.yml +++ b/.github/workflows/website-depoy.yml @@ -27,7 +27,9 @@ jobs: - name: Setup / build docs run: | sudo chmod -R 777 . - ./scripts/install_via_pip.sh -n -d + python3 -m pip install --upgrade pip --progress-bar off + python3 -m pip install -e .[dev] --progress-bar off + python3 -m pip install beautifulsoup4 ipython nbconvert==5.6.1 --progress-bar off ./scripts/build_docs.sh -b cd website From 34dd8cd70dd7984db40a32c6d95e03a96bb44a43 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Fri, 20 Oct 2023 16:26:26 -0700 Subject: [PATCH 42/49] Remove yarn --- .github/workflows/test-website-depoy.yml | 4 ---- .github/workflows/website-depoy.yml | 7 ------- 2 files changed, 11 deletions(-) diff --git a/.github/workflows/test-website-depoy.yml b/.github/workflows/test-website-depoy.yml index 9b64c59605..d26deed354 100644 --- a/.github/workflows/test-website-depoy.yml +++ b/.github/workflows/test-website-depoy.yml @@ -13,10 +13,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: yarn - name: Setup / build docs run: | diff --git a/.github/workflows/website-depoy.yml b/.github/workflows/website-depoy.yml index 5b9070ef7e..c3da48d442 100644 --- a/.github/workflows/website-depoy.yml +++ b/.github/workflows/website-depoy.yml @@ -16,13 +16,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: yarn - - name: Setup - run: mkdir -p website/static/.circleci && cp -a .circleci/. website/static/.circleci/. - ./scripts/build_docs.sh -b - name: Setup / build docs run: | From fdad86d5428bdd0fa5841d8c6034c9df1aec5a93 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Fri, 20 Oct 2023 16:49:53 -0700 Subject: [PATCH 43/49] Unpin nbconvert --- .github/workflows/test-pip-gpu.yml | 1 - .github/workflows/test-website-depoy.yml | 8 +------- .github/workflows/website-depoy.yml | 6 +----- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test-pip-gpu.yml b/.github/workflows/test-pip-gpu.yml index 624b9430c6..9f5c1dd1af 100644 --- a/.github/workflows/test-pip-gpu.yml +++ b/.github/workflows/test-pip-gpu.yml @@ -22,7 +22,6 @@ jobs: gpu-arch-type: cuda gpu-arch-version: ${{ matrix.cuda_arch_version }} script: | - # Create Conda Env python3 -m pip install --upgrade pip --progress-bar off python3 -m pip install -e .[dev] --progress-bar off diff --git a/.github/workflows/test-website-depoy.yml b/.github/workflows/test-website-depoy.yml index d26deed354..7a626e28fd 100644 --- a/.github/workflows/test-website-depoy.yml +++ b/.github/workflows/test-website-depoy.yml @@ -19,12 +19,6 @@ jobs: sudo chmod -R 777 . python3 -m pip install --upgrade pip --progress-bar off python3 -m pip install -e .[dev] --progress-bar off - python3 -m pip install beautifulsoup4 ipython nbconvert==5.6.1 --progress-bar off + python3 -m pip install beautifulsoup4 ipython nbconvert --progress-bar off ./scripts/build_docs.sh -b cd website - - - name: Install dependencies - run: yarn install --frozen-lockfile - - - name: Test build website - run: yarn build diff --git a/.github/workflows/website-depoy.yml b/.github/workflows/website-depoy.yml index c3da48d442..02496001c5 100644 --- a/.github/workflows/website-depoy.yml +++ b/.github/workflows/website-depoy.yml @@ -22,14 +22,10 @@ jobs: sudo chmod -R 777 . python3 -m pip install --upgrade pip --progress-bar off python3 -m pip install -e .[dev] --progress-bar off - python3 -m pip install beautifulsoup4 ipython nbconvert==5.6.1 --progress-bar off + python3 -m pip install beautifulsoup4 ipython nbconvert --progress-bar off ./scripts/build_docs.sh -b cd website - - name: Install dependencies - run: yarn install --frozen-lockfile - - name: Build website - run: yarn build # Popular action to deploy to GitHub Pages: # Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus From 789ca02115113996ac6b3268c633155220cc0bd9 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Fri, 20 Oct 2023 17:04:30 -0700 Subject: [PATCH 44/49] Pin jinja --- .github/workflows/test-website-depoy.yml | 2 +- .github/workflows/website-depoy.yml | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-website-depoy.yml b/.github/workflows/test-website-depoy.yml index 7a626e28fd..ba8f2ef1dc 100644 --- a/.github/workflows/test-website-depoy.yml +++ b/.github/workflows/test-website-depoy.yml @@ -19,6 +19,6 @@ jobs: sudo chmod -R 777 . python3 -m pip install --upgrade pip --progress-bar off python3 -m pip install -e .[dev] --progress-bar off - python3 -m pip install beautifulsoup4 ipython nbconvert --progress-bar off + python3 -m pip install beautifulsoup4 ipython jinja==3.0.0 nbconvert==5.6.1 --progress-bar off ./scripts/build_docs.sh -b cd website diff --git a/.github/workflows/website-depoy.yml b/.github/workflows/website-depoy.yml index 02496001c5..af2f25b74f 100644 --- a/.github/workflows/website-depoy.yml +++ b/.github/workflows/website-depoy.yml @@ -1,6 +1,9 @@ name: Deploy to GitHub Pages on: + pull_request: + branches: + - master push: branches: - master @@ -22,7 +25,7 @@ jobs: sudo chmod -R 777 . python3 -m pip install --upgrade pip --progress-bar off python3 -m pip install -e .[dev] --progress-bar off - python3 -m pip install beautifulsoup4 ipython nbconvert --progress-bar off + python3 -m pip install beautifulsoup4 ipython jinja==3.0.0 nbconvert==5.6.1 --progress-bar off ./scripts/build_docs.sh -b cd website @@ -34,7 +37,7 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} # Build output to publish to the `gh-pages` branch: - publish_dir: ./build + publish_dir: ./website/build/captum/ # The following lines assign commit authorship to the official # GH-Actions bot for deploys to `gh-pages` branch: # https://github.com/actions/checkout/issues/13#issuecomment-724415212 From 0ba19ff3c55ada65ee2377b025e19fafaec4c582 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Fri, 20 Oct 2023 17:12:08 -0700 Subject: [PATCH 45/49] Fixes --- .github/workflows/test-website-depoy.yml | 2 +- .github/workflows/website-depoy.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-website-depoy.yml b/.github/workflows/test-website-depoy.yml index ba8f2ef1dc..7e6d88d8d9 100644 --- a/.github/workflows/test-website-depoy.yml +++ b/.github/workflows/test-website-depoy.yml @@ -19,6 +19,6 @@ jobs: sudo chmod -R 777 . python3 -m pip install --upgrade pip --progress-bar off python3 -m pip install -e .[dev] --progress-bar off - python3 -m pip install beautifulsoup4 ipython jinja==3.0.0 nbconvert==5.6.1 --progress-bar off + python3 -m pip install beautifulsoup4 ipython jinja2==3.0.0 nbconvert==5.6.1 --progress-bar off ./scripts/build_docs.sh -b cd website diff --git a/.github/workflows/website-depoy.yml b/.github/workflows/website-depoy.yml index af2f25b74f..9da0c9498a 100644 --- a/.github/workflows/website-depoy.yml +++ b/.github/workflows/website-depoy.yml @@ -25,7 +25,7 @@ jobs: sudo chmod -R 777 . python3 -m pip install --upgrade pip --progress-bar off python3 -m pip install -e .[dev] --progress-bar off - python3 -m pip install beautifulsoup4 ipython jinja==3.0.0 nbconvert==5.6.1 --progress-bar off + python3 -m pip install beautifulsoup4 ipython jinja2==3.0.0 nbconvert==5.6.1 --progress-bar off ./scripts/build_docs.sh -b cd website From 1269a4999c123a264e2e18ea3476071363aaa325 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Fri, 20 Oct 2023 17:20:43 -0700 Subject: [PATCH 46/49] Test write --- .github/workflows/test-website-depoy.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test-website-depoy.yml b/.github/workflows/test-website-depoy.yml index 7e6d88d8d9..5f99010e79 100644 --- a/.github/workflows/test-website-depoy.yml +++ b/.github/workflows/test-website-depoy.yml @@ -7,6 +7,9 @@ on: # Review gh actions docs if you want to further define triggers, paths, etc # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on +permissions: + contents: write + jobs: test-deploy: name: Test deployment From 55705f6a5ea71b0b5201b825d261a9f93d8df3b3 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Fri, 20 Oct 2023 18:44:15 -0700 Subject: [PATCH 47/49] Modify branch test --- .github/workflows/test-website-depoy.yml | 5 ----- .github/workflows/website-depoy.yml | 2 -- 2 files changed, 7 deletions(-) diff --git a/.github/workflows/test-website-depoy.yml b/.github/workflows/test-website-depoy.yml index 5f99010e79..9bb9e26ded 100644 --- a/.github/workflows/test-website-depoy.yml +++ b/.github/workflows/test-website-depoy.yml @@ -2,14 +2,9 @@ name: Test deployment on: pull_request: - branches: - - master # Review gh actions docs if you want to further define triggers, paths, etc # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on -permissions: - contents: write - jobs: test-deploy: name: Test deployment diff --git a/.github/workflows/website-depoy.yml b/.github/workflows/website-depoy.yml index 9da0c9498a..8a6cc4387b 100644 --- a/.github/workflows/website-depoy.yml +++ b/.github/workflows/website-depoy.yml @@ -2,8 +2,6 @@ name: Deploy to GitHub Pages on: pull_request: - branches: - - master push: branches: - master From 969352ef0813701ddf2f0f5d703d9bd749480f82 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Fri, 20 Oct 2023 21:37:18 -0700 Subject: [PATCH 48/49] Add permission --- .github/workflows/website-depoy.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/website-depoy.yml b/.github/workflows/website-depoy.yml index 8a6cc4387b..8babc03579 100644 --- a/.github/workflows/website-depoy.yml +++ b/.github/workflows/website-depoy.yml @@ -10,6 +10,7 @@ on: permissions: contents: write + pages: write jobs: deploy: @@ -36,10 +37,3 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} # Build output to publish to the `gh-pages` branch: publish_dir: ./website/build/captum/ - # The following lines assign commit authorship to the official - # GH-Actions bot for deploys to `gh-pages` branch: - # https://github.com/actions/checkout/issues/13#issuecomment-724415212 - # The GH actions bot is used by default if you didn't specify the two fields. - # You can swap them out with your own user credentials. - user_name: github-actions[bot] - user_email: 41898282+github-actions[bot]@users.noreply.github.com From 17a56d620b445820841cac462af0466f28b028c3 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Fri, 20 Oct 2023 22:08:43 -0700 Subject: [PATCH 49/49] Final cleanup --- .github/workflows/test-conda-cpu.yml | 9 --------- .github/workflows/test-pip-gpu.yml | 1 - .github/workflows/website-depoy.yml | 1 - 3 files changed, 11 deletions(-) diff --git a/.github/workflows/test-conda-cpu.yml b/.github/workflows/test-conda-cpu.yml index 45eda3ea2f..9ae71846d1 100644 --- a/.github/workflows/test-conda-cpu.yml +++ b/.github/workflows/test-conda-cpu.yml @@ -24,15 +24,6 @@ jobs: script: | # Set up Environment Variables export PYTHON_VERSION="${{ matrix.python_version }}" - export VERSION="cpu" - export CUDATOOLKIT="cpuonly" - - # Set CHANNEL - if [[ (${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then - export CHANNEL=test - else - export CHANNEL=nightly - fi # Create Conda Env conda create -yp ci_env python="${PYTHON_VERSION}" diff --git a/.github/workflows/test-pip-gpu.yml b/.github/workflows/test-pip-gpu.yml index 9f5c1dd1af..117f515f48 100644 --- a/.github/workflows/test-pip-gpu.yml +++ b/.github/workflows/test-pip-gpu.yml @@ -12,7 +12,6 @@ jobs: tests: strategy: matrix: - python_version: ["3.8"] cuda_arch_version: ["12.1"] fail-fast: false uses: pytorch/test-infra/.github/workflows/linux_job.yml@main diff --git a/.github/workflows/website-depoy.yml b/.github/workflows/website-depoy.yml index 8babc03579..960c5a2167 100644 --- a/.github/workflows/website-depoy.yml +++ b/.github/workflows/website-depoy.yml @@ -1,7 +1,6 @@ name: Deploy to GitHub Pages on: - pull_request: push: branches: - master