Unverified Commit 7ef3a5e9 authored by Kai Chen's avatar Kai Chen Committed by GitHub
Browse files

Use copy instead of symlink on windows (#557)

* use copy instead of symlink on windows

* use platform.system() instead of sys.platform
parent 9ecd6b0d
# Copyright (c) Open-MMLab. All rights reserved. # Copyright (c) Open-MMLab. All rights reserved.
import os.path as osp import os.path as osp
import platform
import shutil
import time import time
import warnings import warnings
...@@ -163,7 +165,11 @@ class EpochBasedRunner(BaseRunner): ...@@ -163,7 +165,11 @@ class EpochBasedRunner(BaseRunner):
# in some environments, `os.symlink` is not supported, you may need to # in some environments, `os.symlink` is not supported, you may need to
# set `create_symlink` to False # set `create_symlink` to False
if create_symlink: if create_symlink:
mmcv.symlink(filename, osp.join(out_dir, 'latest.pth')) dst_file = osp.join(out_dir, 'latest.pth')
if platform.system() != 'Windows':
mmcv.symlink(filename, dst_file)
else:
shutil.copy(filename, dst_file)
class Runner(EpochBasedRunner): class Runner(EpochBasedRunner):
......
# Copyright (c) Open-MMLab. All rights reserved. # Copyright (c) Open-MMLab. All rights reserved.
import os.path as osp import os.path as osp
import platform
import shutil
import time import time
import torch import torch
...@@ -193,7 +195,11 @@ class IterBasedRunner(BaseRunner): ...@@ -193,7 +195,11 @@ class IterBasedRunner(BaseRunner):
# in some environments, `os.symlink` is not supported, you may need to # in some environments, `os.symlink` is not supported, you may need to
# set `create_symlink` to False # set `create_symlink` to False
if create_symlink: if create_symlink:
mmcv.symlink(filename, osp.join(out_dir, 'latest.pth')) dst_file = osp.join(out_dir, 'latest.pth')
if platform.system() != 'Windows':
mmcv.symlink(filename, dst_file)
else:
shutil.copy(filename, dst_file)
def register_training_hooks(self, def register_training_hooks(self,
lr_config, lr_config,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment