From 730d8f152e2b57495a04ed53588aab22e5b76028 Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang Date: Thu, 4 Nov 2021 18:53:33 +0800 Subject: [PATCH] Enable pip cache dependencies in GH Actions (#226) * Rename to ci-test.yml * Fix the cache directory * Add Python - pip cache to ci-test Actions * Update to the new badges * Adjust the badges * Adopt the urls in pages * Consistent naming --- .../workflows/{ci_test.yml => ci-test.yml} | 55 +++++++++++++------ .github/workflows/gh-pages.yml | 24 ++++---- README.md | 11 ++-- 3 files changed, 58 insertions(+), 32 deletions(-) rename .github/workflows/{ci_test.yml => ci-test.yml} (71%) diff --git a/.github/workflows/ci_test.yml b/.github/workflows/ci-test.yml similarity index 71% rename from .github/workflows/ci_test.yml rename to .github/workflows/ci-test.yml index 864b8f20..a0317b57 100644 --- a/.github/workflows/ci_test.yml +++ b/.github/workflows/ci-test.yml @@ -10,19 +10,18 @@ on: branches: [ main ] jobs: - UnitTest: + Unittest: runs-on: ${{ matrix.image }} strategy: matrix: - python-version: [ 3.7 ] image: [ 'ubuntu-latest' ] - torch: [ '1.9.1+cpu', '1.10.0+cpu' ] + torch: [ 'torch 1.9.1+cpu', 'torch 1.10.0+cpu' ] include: - - torch: '1.9.1+cpu' + - torch: 'torch 1.9.1+cpu' torch_address: torch==1.9.1+cpu torchvision==0.10.1+cpu -f https://download.pytorch.org/whl/torch_stable.html unittest_type: --cov=test --cov-report=xml torchvision: release/0.10 - - torch: '1.10.0+cpu' + - torch: 'torch 1.10.0+cpu' torch_address: install torch==1.10.0+cpu torchvision==0.11.1+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html unittest_type: --cov=test --cov-report=xml torchvision: release/0.11 @@ -30,36 +29,57 @@ jobs: steps: - name: Clone repository uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: - python-version: ${{ matrix.python-version }} - architecture: 'x64' + python-version: '3.8' + + - name: Upgrade pip + run: | + # install pip=>20.1 to use "pip cache dir" + python -m pip install --progress-bar off --upgrade pip + + - name: Get pip cache dir + id: pip-cache + run: echo "::set-output name=dir::$(pip cache dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install PyTorch ${{ matrix.torch }} Version run: | - python -m pip install --upgrade pip # requirements for PyTorch and torchvision - pip install numpy pillow scipy - pip install ${{ matrix.torch_address }} + pip install --progress-bar off numpy pillow scipy + pip install --progress-bar off ${{ matrix.torch_address }} + - name: Install dependencies run: | # requirements for unittest - pip install flake8 pytest - pip install pytest-cov + pip install --progress-bar off flake8 pytest + pip install --progress-bar off pytest-cov # Install other dependencies - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - pip install opencv-python - pip install pycocotools>=2.0.2 - pip install onnxruntime + if [ -f requirements.txt ]; then pip install --progress-bar off -r requirements.txt; fi + pip install --progress-bar off opencv-python + pip install --progress-bar off pycocotools>=2.0.2 + pip install --progress-bar off onnxruntime + - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=18 --max-line-length=120 --statistics + - name: Test and Generate coverage report run: | PYTORCH_TEST_WITH_SLOW=1 pytest ${{ matrix.unittest_type }} + - name: Upload coverage to Codecov uses: codecov/codecov-action@v2.1.0 with: @@ -70,6 +90,7 @@ jobs: name: codecov-umbrella fail_ci_if_error: true verbose: true + - name: Build TorchVision Cpp ${{ matrix.torch }} run: | export TORCH_PATH=$(dirname $(python -c "import torch; print(torch.__file__)")) @@ -81,9 +102,11 @@ jobs: cmake .. -DTorch_DIR=$TORCH_PATH/share/cmake/Torch make -j4 sudo make install + - name: Export torchscript model run: | python -m test.tracing.trace_model + - name: Test libtorch tracing run: | export TORCH_PATH=$(dirname $(python -c "import torch; print(torch.__file__)")) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 5882fd73..c6932f3b 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -1,4 +1,4 @@ -name: Build & deploy documentation +name: Build & deploy docs on: push: @@ -28,15 +28,7 @@ jobs: - name: Upgrade pip run: | # install pip=>20.1 to use "pip cache dir" - python3 -m pip install --upgrade pip - - - name: Install pip dependencies - run: | - # requirements for unittest - pip install numpy - pip install torch torchvision - pip install opencv-python pycocotools>=2.0.2 onnxruntime - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + python -m pip install --upgrade pip - name: Get pip cache dir id: pip-cache @@ -45,11 +37,19 @@ jobs: - name: Cache dependencies uses: actions/cache@v2 with: - path: ${{ steps.pip-cache.outputs.dir }} + path: ~/Library/Caches/pip key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} restore-keys: | ${{ runner.os }}-pip- + - name: Install pip dependencies + run: | + # requirements for unittest + pip install --progress-bar off numpy + pip install --progress-bar off torch torchvision + pip install --progress-bar off opencv-python pycocotools>=2.0.2 onnxruntime + if [ -f requirements.txt ]; then pip install --progress-bar off -r requirements.txt; fi + - name: Build docs run: | cd docs @@ -57,7 +57,7 @@ jobs: make help make html - - name: Deploy + - name: Deploy to GH pages uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 0fc7c330..cc812019 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ ______________________________________________________________________ -[Documentation](#hammer_and_wrench-usage) • -[Installation Instructions](#installation-and-inference-examples) • +[Documentation](https://zhiqwang.com/yolov5-rt-stack/) • +[Installation Instructions](https://zhiqwang.com/yolov5-rt-stack/installation.html) • [Deployment](#rocket-deployment) • [Contributing](CONTRIBUTING.md) • [Reporting Issues](https://github.com/zhiqwang/yolov5-rt-stack/issues/new?assignees=&labels=&template=bug-report.yml) @@ -18,12 +18,15 @@ ______________________________________________________________________ [![PyPI version](https://badge.fury.io/py/yolort.svg)](https://badge.fury.io/py/yolort) [![PyPI downloads](https://static.pepy.tech/personalized-badge/yolort?period=total&units=international_system&left_color=grey&right_color=blue&left_text=pypi%20downloads)](https://pepy.tech/project/yolort) [![Github downloads](https://img.shields.io/github/downloads/zhiqwang/yolov5-rt-stack/total?color=blue&label=downloads&logo=github&logoColor=lightgrey)](https://img.shields.io/github/downloads/zhiqwang/yolov5-rt-stack/total?color=blue&label=Downloads&logo=github&logoColor=lightgrey) -[![license](https://img.shields.io/github/license/zhiqwang/yolov5-rt-stack?color=brightgreen)](LICENSE) -[![CI testing](https://github.com/zhiqwang/yolov5-rt-stack/workflows/CI%20testing/badge.svg)](https://github.com/zhiqwang/yolov5-rt-stack/actions?query=workflow%3A%22CI+testing%22) +[![CI testing](https://github.com/zhiqwang/yolov5-rt-stack/actions/workflows/ci-test.yml/badge.svg)](https://github.com/zhiqwang/yolov5-rt-stack/actions/workflows/ci-test.yml) +[![Build & deploy docs](https://github.com/zhiqwang/yolov5-rt-stack/actions/workflows/gh-pages.yml/badge.svg)](https://github.com/zhiqwang/yolov5-rt-stack/actions/workflows/gh-pages.yml) [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/zhiqwang/yolov5-rt-stack/main.svg)](https://results.pre-commit.ci/latest/github/zhiqwang/yolov5-rt-stack/main) + [![codecov](https://codecov.io/gh/zhiqwang/yolov5-rt-stack/branch/main/graph/badge.svg?token=1GX96EA72Y)](https://codecov.io/gh/zhiqwang/yolov5-rt-stack) +[![license](https://img.shields.io/github/license/zhiqwang/yolov5-rt-stack?color=brightgreen)](LICENSE) [![Slack](https://img.shields.io/badge/slack-chat-green.svg?logo=slack)](https://join.slack.com/t/yolort/shared_invite/zt-mqwc7235-940aAh8IaKYeWclrJx10SA) +[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/zhiqwang/yolov5-rt-stack/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) ______________________________________________________________________