Skip to content

Commit

Permalink
[Fix] Update CI (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
linyq17 committed Nov 25, 2021
1 parent 486c8c2 commit 0bd4fa7
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 29 deletions.
125 changes: 96 additions & 29 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,33 @@ jobs:
pre-commit install
- name: Linting
run: pre-commit run --all-files
# - name: Check docstring coverage
# run: |
# pip install interrogate
# interrogate -v --ignore-init-method --ignore-module --ignore-nested-functions --ignore-regex "__repr__" --fail-under 80 mmfewshot
- name: Check docstring coverage
run: |
pip install interrogate
interrogate -v --ignore-init-method --ignore-module --ignore-nested-functions --ignore-regex "__repr__" --fail-under 80 mmfewshot
build_cpu:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7]
torch: [1.3.1, 1.5.1, 1.6.0]
torch: [1.5.1, 1.6.0, 1.7.0, 1.8.0, 1.9.0]
include:
- torch: 1.3.1
torchvision: 0.4.2
mmcv: "latest+torch1.3.0+cpu"
- torch: 1.5.1
torchvision: 0.6.1
mmcv: "latest+torch1.5.0+cpu"
mmcv: 1.5.0
- torch: 1.6.0
torchvision: 0.7.0
mmcv: "latest+torch1.6.0+cpu"
mmcv: 1.6.0
- torch: 1.7.0
torchvision: 0.8.1
mmcv: "latest+torch1.7.0+cpu"
mmcv: 1.7.0
- torch: 1.8.0
torchvision: 0.9.0
mmcv: "latest+torch1.8.0+cpu"
mmcv: 1.8.0
- torch: 1.9.0
torchvision: 0.10.0
mmcv: 1.9.0
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -57,7 +57,7 @@ jobs:
run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html
- name: Install MMCV
run: |
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cpu/torch${{matrix.torch}}/index.html
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cpu/torch${{matrix.mmcv}}/index.html
python -c 'import mmcv; print(mmcv.__version__)'
- name: Install MMCLS and MMDET
run: pip install mmcls mmdet
Expand All @@ -81,33 +81,29 @@ jobs:
strategy:
matrix:
python-version: [3.7]
torch: [1.3.1, 1.5.1+cu101, 1.6.0+cu101, 1.7.0+cu101, 1.8.0+cu101]
torch: [
1.5.1+cu101,
1.6.0+cu101,
1.7.0+cu101,
1.8.0+cu101
]
include:
- torch: 1.3.1
torch_version: torch1.3.1
torchvision: 0.4.2
mmcv: "latest+torch1.3.0+cu101"
- torch: 1.5.1+cu101
torch_version: torch1.5.1
torchvision: 0.6.1+cu101
mmcv: "latest+torch1.5.0+cu101"
- torch: 1.6.0+cu101
torch_version: torch1.6.0
torchvision: 0.7.0+cu101
mmcv: "latest+torch1.6.0+cu101"
mmcv: 1.5.0
- torch: 1.6.0+cu101
torch_version: torch1.6.0
torchvision: 0.7.0+cu101
mmcv: "latest+torch1.6.0+cu101"
python-version: 3.8
mmcv: 1.6.0
- torch: 1.7.0+cu101
torch_version: torch1.7.0
torchvision: 0.8.1+cu101
mmcv: "latest+torch1.7.0+cu101"
mmcv: 1.7.0
- torch: 1.8.0+cu101
torch_version: torch1.8.0
torchvision: 0.9.0+cu101
mmcv: "latest+torch1.8.0+cu101"
mmcv: 1.8.0

steps:
- uses: actions/checkout@v2
Expand All @@ -133,9 +129,9 @@ jobs:
if: ${{matrix.torchvision < 0.5}}
- name: Install PyTorch
run: pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html
- name: Install mmfewshot dependencies
- name: Install MMCV
run: |
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/${{matrix.torch_version}}/index.html
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/torch${{matrix.mmcv}}/index.html
pip install -r requirements.txt
python -c 'import mmcv; print(mmcv.__version__)'
- name: Install MMCLS and MMDET
Expand All @@ -158,3 +154,74 @@ jobs:
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: false

build_cuda102:
runs-on: ubuntu-18.04
container:
image: pytorch/pytorch:1.9.0-cuda10.2-cudnn7-devel

strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
torch: [1.9.0+cu102]
include:
- torch: 1.9.0+cu102
torch_version: torch1.9.0
torchvision: 0.10.0+cu102
mmcv: 1.9.0

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
# Add ppa source repo for python3.9.
- name: Add python3.9 source
run: |
apt-get update && apt-get install -y software-properties-common
add-apt-repository -y ppa:deadsnakes/ppa
if: ${{matrix.python-version == '3.9'}}
# Install python-dev for some packages which require libpython3.Xm.
# Github's setup-python cannot install python3.9-dev, so we have to use apt install.
# Set DEBIAN_FRONTEND=noninteractive to avoid some interactions.
- name: Install python-dev
run: apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends python${{matrix.python-version}}-dev
- name: Install system dependencies
run: |
apt-get update && apt-get install -y ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6
apt-get clean
rm -rf /var/lib/apt/lists/*
- name: Install Pillow
run: python -m pip install Pillow==6.2.2
if: ${{matrix.torchvision < 0.5}}
- name: Install PyTorch
run: python -m pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html
- name: Install dependencies for compiling onnx when python=3.9
run: python -m pip install protobuf && apt-get update && apt-get -y install libprotobuf-dev protobuf-compiler cmake
if: ${{matrix.python-version == '3.9'}}
- name: Install mmfewshot dependencies
run: |
python -V
python -m pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu102/torch${{matrix.mmcv}}/index.html
python -m pip install -r requirements.txt
python -c 'import mmcv; print(mmcv.__version__)'
python -m pip install mmcls mmdet
- name: Build and install
run: |
rm -rf .eggs
python setup.py check -m -s
TORCH_CUDA_ARCH_LIST=7.0 pip install .
- name: Run unittests and generate coverage report
run: |
coverage run --branch --source mmdet -m pytest tests/
coverage xml
coverage report -m
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
files: ./coverage.xml
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: false
1 change: 1 addition & 0 deletions mmfewshot/classification/datasets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def sample_shots_by_class_id(self, class_id: int,
all_shot_ids, num_shots, replace=False).tolist()

def __len__(self) -> int:
"""Return length of the dataset."""
return len(self.data_infos)

def __getitem__(self, idx: int) -> Dict:
Expand Down
4 changes: 4 additions & 0 deletions mmfewshot/classification/datasets/dataset_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(self,
self.generate_episodic_idxes()

def generate_episodic_idxes(self) -> Tuple[List[Mapping], List[List[int]]]:
"""Generate batch indices for each episodic."""
episode_idxes, episode_class_ids = [], []
class_ids = [i for i in range(len(self.CLASSES))]
# using same episodes seed can generate same episodes for same dataset
Expand Down Expand Up @@ -95,12 +96,15 @@ def __getitem__(self, idx: int) -> Dict:
}

def __len__(self) -> int:
"""The length of the dataset is the number of generated episodes."""
return self.num_episodes

def evaluate(self, *args, **kwargs) -> List:
"""Evaluate prediction."""
return self.dataset.evaluate(*args, **kwargs)

def get_episode_class_ids(self, idx: int) -> List[int]:
"""Return class ids in one episode."""
return self.episode_class_ids[idx]


Expand Down

0 comments on commit 0bd4fa7

Please sign in to comment.