From 0a98e158328ecffaf4b10a4540d582e4d514fd78 Mon Sep 17 00:00:00 2001 From: zhouzaida Date: Sat, 21 Aug 2021 16:07:09 +0800 Subject: [PATCH] modify according to comment --- .github/workflows/build.yml | 42 +++++++++++++++++++++++++++++--- mmcv/runner/hooks/logger/pavi.py | 4 +++ tests/test_runner/test_hooks.py | 9 +++++-- tests/test_utils/test_config.py | 2 -- 4 files changed, 50 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0ab4cd52ae..c0192bfed7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -279,22 +279,58 @@ jobs: name: codecov-umbrella fail_ci_if_error: false + build_windows_without_ops: + runs-on: windows-latest + env: + MMCV_WITH_OPS: 0 + strategy: + matrix: + torch: [1.7.1, 1.8.0, 1.9.0] + include: + - torch: 1.7.1 + torchvision: 0.8.2 + - torch: 1.8.0 + torchvision: 0.9.0 + - torch: 1.9.0 + torchvision: 0.10.0 + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Install Pillow + run: pip install Pillow==6.2.2 + if: ${{matrix.torchvision == '0.4.2'}} + - name: Install PyTorch + run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu --no-cache-dir -f https://download.pytorch.org/whl/torch_stable.html + - name: Build and install + run: pip install -e . + - name: Validate the installation + run: python -c "import mmcv" + - name: Run unittests + run: | + pip install -r requirements/test.txt + pytest tests/ --ignore=tests/test_ops --ignore tests/test_utils/test_progressbar.py --ignore tests/test_utils/test_timer.py --ignore tests/test_image/test_io.py + build_windows: runs-on: windows-latest strategy: matrix: - torch: [1.7.1] + torch: [1.7.1, 1.8.0, 1.9.0] include: - torch: 1.7.1 torchvision: 0.8.2 + - torch: 1.8.0 + torchvision: 0.9.0 + - torch: 1.9.0 + torchvision: 0.10.0 steps: - uses: actions/checkout@v2 - name: Set up Python 3.7 uses: actions/setup-python@v2 with: python-version: 3.7 - # - name: Install system dependencies - # run: brew install ffmpeg jpeg-turbo - name: Install Pillow run: pip install Pillow==6.2.2 if: ${{matrix.torchvision == '0.4.2'}} diff --git a/mmcv/runner/hooks/logger/pavi.py b/mmcv/runner/hooks/logger/pavi.py index f3f5ccdb3e..31b88c7eef 100644 --- a/mmcv/runner/hooks/logger/pavi.py +++ b/mmcv/runner/hooks/logger/pavi.py @@ -1,5 +1,6 @@ # Copyright (c) Open-MMLab. All rights reserved. import json +import os import os.path as osp import torch @@ -88,6 +89,9 @@ def log(self, runner): def after_run(self, runner): if self.add_last_ckpt: ckpt_path = osp.join(runner.work_dir, 'latest.pth') + if osp.islink(ckpt_path): + ckpt_path = osp.join(runner.work_dir, os.readlink(ckpt_path)) + if osp.isfile(ckpt_path): # runner.epoch += 1 has been done before `after_run`. iteration = runner.epoch if self.by_epoch else runner.iter diff --git a/tests/test_runner/test_hooks.py b/tests/test_runner/test_hooks.py index 6573e8ed98..0e42f8a620 100644 --- a/tests/test_runner/test_hooks.py +++ b/tests/test_runner/test_hooks.py @@ -6,6 +6,7 @@ """ import logging import os.path as osp +import platform import random import re import shutil @@ -207,10 +208,14 @@ def test_pavi_hook(): 'learning_rate': 0.02, 'momentum': 0.95 }, 1) - + # in windows environment, the latest checkpoint is copied from epoch_1.pth + if platform.system() == 'Windows': + snapshot_file_path = osp.join(runner.work_dir, 'latest.pth') + else: + snapshot_file_path = osp.join(runner.work_dir, 'epoch_1.pth') hook.writer.add_snapshot_file.assert_called_with( tag=runner.work_dir.split('/')[-1], - snapshot_file_path=osp.join(runner.work_dir, 'latest.pth'), + snapshot_file_path=snapshot_file_path, iteration=1) diff --git a/tests/test_utils/test_config.py b/tests/test_utils/test_config.py index 44b94c46aa..9871978689 100644 --- a/tests/test_utils/test_config.py +++ b/tests/test_utils/test_config.py @@ -500,8 +500,6 @@ def test_syntax_error(): # more details can be found at https://github.com/open-mmlab/mmcv/pull/1077 temp_cfg_file = tempfile.NamedTemporaryFile(suffix='.py', delete=False) temp_cfg_path = temp_cfg_file.name - # convert a string representation of the path with forward slashes (/) - temp_cfg_path = Path(temp_cfg_path).as_posix() # write a file with syntax error with open(temp_cfg_path, 'w') as f: f.write('a=0b=dict(c=1)')