From 345c71e395ae030f394142dd3707a7b2bf4e309c Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Thu, 12 Oct 2023 12:43:43 -0700 Subject: [PATCH] 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