diff --git a/.github/workflows/merge_stage_test.yml b/.github/workflows/merge_stage_test.yml index 46ced35075dd6f393a69be7fb8ded73620b32f5a..b465218ba1aa3bcb0ee6d96216974183eb6a52ff 100644 --- a/.github/workflows/merge_stage_test.yml +++ b/.github/workflows/merge_stage_test.yml @@ -73,6 +73,8 @@ jobs: torchvision: 0.12.0 - torch: 1.12.0 torchvision: 0.13.0 + - torch: 1.13.0 + torchvision: 0.14.0 steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} @@ -92,9 +94,11 @@ jobs: mim install 'mmcv>=2.0.0rc1' - name: Run unittests and generate coverage report run: | - coverage run --branch --source mmengine -m pytest tests/ - coverage xml - coverage report -m + if [[ ${{ matrix.torch }} == "1.13.0" ]]; then + coverage run --branch --source mmengine -m pytest tests/ --ignore tests/test_dist + else + coverage run --branch --source mmengine -m pytest tests/ + fi # Only upload coverage report for python3.7 && pytorch1.8.1 cpu - name: Upload coverage to Codecov if: ${{matrix.torch == '1.8.1' && matrix.python-version == '3.7'}} @@ -125,7 +129,7 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Upgrade pip - run: python -m pip install pip --upgrade + run: pip install pip --upgrade - name: Fetch GPG keys run: | apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub @@ -159,7 +163,7 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Upgrade pip - run: python -m pip install pip --upgrade + run: pip install pip --upgrade - name: Fetch GPG keys run: | apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub @@ -173,9 +177,10 @@ jobs: pip install -r requirements/tests.txt pip install openmim mim install 'mmcv>=2.0.0rc1' + # Distributed related unit test may randomly error in PyTorch 1.13.0 - name: Run unittests and generate coverage report run: | - coverage run --branch --source mmengine -m pytest tests/ + coverage run --branch --source mmengine -m pytest tests/ --ignore tests/test_dist/ coverage xml coverage report -m @@ -192,6 +197,30 @@ jobs: torchvision: 0.9.1 - torch: 1.13.0 torchvision: 0.14.0 + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Upgrade pip + run: pip install pip --upgrade + - name: Install PyTorch + run: pip install torch==${{ matrix.torch }} torchvision==${{ matrix.torchvision }} + - name: Build MMEngine from source + run: pip install -e . -v + - name: Install unit tests dependencies + run: | + pip install -r requirements/tests.txt + pip install openmim + mim install 'mmcv>=2.0.0rc1' + # Distributed-related unit tests may fail in macOS + # Skip testing setup_env since it does not work in the current CI environment # TODO + - name: Run unittests and generate coverage report + run: | + coverage run --branch --source mmengine -m pytest tests/ --ignore tests/test_dist/ --ignore tests/test_utils/test_dl_utils/test_setup_env.py + coverage xml + coverage report -m build_windows: runs-on: ${{ matrix.os }} diff --git a/tests/test_utils/test_progressbar.py b/tests/test_utils/test_progressbar.py index 04e7cb8457885afe2abae7693da08615e6703c78..701e23eeb36cc2f0f480a7a2017437a932b85c42 100644 --- a/tests/test_utils/test_progressbar.py +++ b/tests/test_utils/test_progressbar.py @@ -1,7 +1,9 @@ # Copyright (c) OpenMMLab. All rights reserved. import os +import platform import time from io import StringIO +from unittest import skipIf from unittest.mock import patch import mmengine @@ -39,6 +41,9 @@ class TestProgressBar: prog_bar.start() assert out.getvalue() == f'[{" " * bar_width}] 0/10, elapsed: 0s, ETA:' + @skipIf( + platform.system() != 'Linux', + reason='Only test `TestProgressBar.test_update` in Linux') def test_update(self): out = StringIO() bar_width = 20 @@ -57,6 +62,9 @@ class TestProgressBar: assert out.getvalue() == f'\r[{">" * 2 + " " * 18}] 1/10, 1.0 ' \ 'task/s, elapsed: 1s, ETA: 9s' + @skipIf( + platform.system() != 'Linux', + reason='Only test `TestProgressBar.test_adaptive_length` in Linux') def test_adaptive_length(self): with patch.dict('os.environ', {'COLUMNS': '80'}): out = StringIO() @@ -83,6 +91,9 @@ def sleep_1s(num): return num +@skipIf( + platform.system() != 'Linux', + reason='Only test `test_track_progress_list` in Linux') def test_track_progress_list(): out = StringIO() ret = mmengine.track_progress(sleep_1s, [1, 2, 3], bar_width=3, file=out) @@ -94,6 +105,9 @@ def test_track_progress_list(): assert ret == [1, 2, 3] +@skipIf( + platform.system() != 'Linux', + reason='Only test `test_track_progress_iterator` in Linux') def test_track_progress_iterator(): out = StringIO() ret = mmengine.track_progress( @@ -106,6 +120,9 @@ def test_track_progress_iterator(): assert ret == [1, 2, 3] +@skipIf( + platform.system() != 'Linux', + reason='Only test `test_track_iter_progress` in Linux') def test_track_iter_progress(): out = StringIO() ret = [] @@ -119,6 +136,9 @@ def test_track_iter_progress(): assert ret == [1, 2, 3] +@skipIf( + platform.system() != 'Linux', + reason='Only test `test_track_enum_progress` in Linux') def test_track_enum_progress(): out = StringIO() ret = [] @@ -136,6 +156,9 @@ def test_track_enum_progress(): assert count == [0, 1, 2] +@skipIf( + platform.system() != 'Linux', + reason='Only test `test_track_parallel_progress_list` in Linux') def test_track_parallel_progress_list(): out = StringIO() results = mmengine.track_parallel_progress( @@ -150,6 +173,9 @@ def test_track_parallel_progress_list(): assert results == [1, 2, 3, 4] +@skipIf( + platform.system() != 'Linux', + reason='Only test `test_track_parallel_progress_iterator` in Linux') def test_track_parallel_progress_iterator(): out = StringIO() results = mmengine.track_parallel_progress(