From 8d6bf1d332df527a389b620eb42e9375e98e453d Mon Sep 17 00:00:00 2001 From: Linyiqi Date: Fri, 11 Mar 2022 13:43:30 +0800 Subject: [PATCH] Add CI for windows (#47) * [Docs] update batch size * add windows ci * add windows ci * update windows ci * update windows ci * update win ci * update test file * update win ci to cu102 --- .github/workflows/build.yml | 38 +++++++++++++++++++ .../test_few_shot_coco_dataset.py | 5 ++- .../test_few_shot_voc_dataset.py | 5 ++- .../test_datasets/test_nway_kshot_dataset.py | 3 +- .../test_datasets/test_query_aware_dataset.py | 3 +- .../test_datasets/test_two_branch_dataset.py | 3 +- 6 files changed, 50 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2694d56..f5df595 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -223,3 +223,41 @@ jobs: env_vars: OS,PYTHON name: codecov-umbrella fail_ci_if_error: false + + test_windows: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-2022] + python: [3.8] + platform: [cpu, cu102] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + - name: Upgrade pip + run: pip install pip --upgrade --user + - name: Install OpenCV + run: pip install opencv-python>=3 + - name: Install PyTorch + # As a complement to Linux CI, we test on PyTorch LTS version + run: pip install torch==1.8.2+${{ matrix.platform }} torchvision==0.9.2+${{ matrix.platform }} -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html + - name: Install MMCV + run: | + pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cpu/torch1.8/index.html --only-binary mmcv-full + - name: Install MMCLS and MMDET + run: pip install mmcls mmdet + - name: Install unittest dependencies + run: pip install -r requirements/tests.txt -r requirements/optional.txt + - name: Build and install + run: pip install -e . + - name: Run unittests + run: | + python -m pip install timm + coverage run --branch --source mmfewshot -m pytest tests/ + - name: Generate coverage report + run: | + coverage xml + coverage report -m diff --git a/tests/test_detection_data/test_datasets/test_few_shot_coco_dataset.py b/tests/test_detection_data/test_datasets/test_few_shot_coco_dataset.py index 0711cc8..ecc8da8 100644 --- a/tests/test_detection_data/test_datasets/test_few_shot_coco_dataset.py +++ b/tests/test_detection_data/test_datasets/test_few_shot_coco_dataset.py @@ -1,5 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. import copy +import os import tempfile import numpy as np @@ -144,10 +145,10 @@ def test_few_shot_coco_dataset(): # test save and load dataset with tempfile.TemporaryDirectory() as tmpdir: - dataset.save_data_infos(tmpdir + 'ann.json') + dataset.save_data_infos(tmpdir + f'{os.sep}ann.json') data_config['ann_cfg'] = [{ 'type': 'saved_dataset', - 'ann_file': tmpdir + 'ann.json' + 'ann_file': tmpdir + f'{os.sep}ann.json' }] dataset = FewShotCocoDataset(**data_config) count = 0 diff --git a/tests/test_detection_data/test_datasets/test_few_shot_voc_dataset.py b/tests/test_detection_data/test_datasets/test_few_shot_voc_dataset.py index ccf955a..6ca11d8 100644 --- a/tests/test_detection_data/test_datasets/test_few_shot_voc_dataset.py +++ b/tests/test_detection_data/test_datasets/test_few_shot_voc_dataset.py @@ -1,5 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. import copy +import os import tempfile import numpy as np @@ -108,10 +109,10 @@ def test_few_shot_voc_dataset(): dataset.data_infos[1]['ann']['bboxes_ignore'] = np.array( [[11, 11, 100, 100]]) dataset.data_infos[1]['ann']['labels_ignore'] = np.array([0]) - dataset.save_data_infos(tmpdir + 'ann.json') + dataset.save_data_infos(tmpdir + f'{os.sep}ann.json') data_config['ann_cfg'] = [{ 'type': 'saved_dataset', - 'ann_file': tmpdir + 'ann.json' + 'ann_file': tmpdir + f'{os.sep}ann.json' }] dataset = FewShotVOCDataset(**data_config) count = 0 diff --git a/tests/test_detection_data/test_datasets/test_nway_kshot_dataset.py b/tests/test_detection_data/test_datasets/test_nway_kshot_dataset.py index ae663cd..eaf6762 100644 --- a/tests/test_detection_data/test_datasets/test_nway_kshot_dataset.py +++ b/tests/test_detection_data/test_datasets/test_nway_kshot_dataset.py @@ -1,4 +1,5 @@ # Copyright (c) OpenMMLab. All rights reserved. +import os import tempfile import numpy as np @@ -85,4 +86,4 @@ def test_nway_kshot_dataset(): assert count <= 1 # test save dataset with tempfile.TemporaryDirectory() as tmpdir: - nway_kshot_dataset.save_data_infos(tmpdir + 'ann.json') + nway_kshot_dataset.save_data_infos(tmpdir + f'{os.sep}ann.json') diff --git a/tests/test_detection_data/test_datasets/test_query_aware_dataset.py b/tests/test_detection_data/test_datasets/test_query_aware_dataset.py index 798f795..816bd33 100644 --- a/tests/test_detection_data/test_datasets/test_query_aware_dataset.py +++ b/tests/test_detection_data/test_datasets/test_query_aware_dataset.py @@ -1,4 +1,5 @@ # Copyright (c) OpenMMLab. All rights reserved. +import os import tempfile import numpy as np @@ -115,4 +116,4 @@ def test_query_aware_dataset(): # test save dataset with tempfile.TemporaryDirectory() as tmpdir: - query_aware_dataset.save_data_infos(tmpdir + 'ann.json') + query_aware_dataset.save_data_infos(tmpdir + f'{os.sep}ann.json') diff --git a/tests/test_detection_data/test_datasets/test_two_branch_dataset.py b/tests/test_detection_data/test_datasets/test_two_branch_dataset.py index 5bf24e4..8632ced 100644 --- a/tests/test_detection_data/test_datasets/test_two_branch_dataset.py +++ b/tests/test_detection_data/test_datasets/test_two_branch_dataset.py @@ -1,4 +1,5 @@ # Copyright (c) OpenMMLab. All rights reserved. +import os import tempfile from mmdet.apis import set_random_seed @@ -45,4 +46,4 @@ def test_two_branch_dataset(): assert len(two_branch_dataset) == 25 # test save dataset with tempfile.TemporaryDirectory() as tmpdir: - two_branch_dataset.save_data_infos(tmpdir + 'ann.json') + two_branch_dataset.save_data_infos(tmpdir + f'{os.sep}ann.json')