Skip to content

Commit

Permalink
Enable pip cache dependencies in GH Actions (#226)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
zhiqwang authored Nov 4, 2021
1 parent 284e3e2 commit 730d8f1
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 32 deletions.
55 changes: 39 additions & 16 deletions .github/workflows/ci_test.yml → .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,56 +10,76 @@ 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

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/[email protected]
with:
Expand All @@ -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__)"))
Expand All @@ -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__)"))
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build & deploy documentation
name: Build & deploy docs

on:
push:
Expand Down Expand Up @@ -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
Expand All @@ -45,19 +37,27 @@ 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
pip install --progress-bar off -r requirements.txt
make help
make html
- name: Deploy
- name: Deploy to GH pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

______________________________________________________________________

Expand Down

0 comments on commit 730d8f1

Please sign in to comment.