def _test_upload(self, fs): src_file = os.path.abspath("./test_upload.src") dst_file = os.path.abspath("./test_uolpad.dst") try: fs.upload(src_file, dst_file) self.assertFalse(True) except FSFileNotExistsError as e: pass local = LocalFS() local.touch(src_file) fs.delete(dst_file) assert fs.need_upload_download() fs.upload(src_file, dst_file) try: fs.upload(src_file, dst_file) self.assertFalse(True) except FSFileExistsError as e: pass self.assertTrue(fs.is_exist(dst_file)) fs.delete(dst_file) fs.delete(src_file)
def test_fs(self): from paddle.distributed.fleet.utils import LocalFS fs = LocalFS() dirs, files = fs.ls_dir("test_tmp") dirs, files = fs.ls_dir("./") self.assertFalse(fs.need_upload_download()) fleet_util.set_file_system(fs)
def test_local(self): fs = LocalFS() self._test_rm(fs) self._test_touch(fs) self._test_dirs(fs) self._test_touch_file(fs)
def test_local(self): fs = LocalFS() self._test_mkdirs(fs) self._test_list_dir(fs) self._test_try_upload(fs) self._test_try_download(fs)
/*************************************************************************** * * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved * @file dist_fleet_utils_localfs.py * @author [email protected] * @date 2021-01-20 19:22 * @brief * **************************************************************************/ """ import os import sys from paddle.distributed.fleet.utils import LocalFS from utils import run_priority client = LocalFS() @run_priority(level='P1') def test_is_dir(): """test_is_dir""" subdirs, files = client.ls_dir("./") print(subdirs, files) print("{} ... ok".format(sys._getframe().f_code.co_name)) @run_priority(level='P1') def test_mkdirs(): """test_mkdirs""" client.mkdirs("test_mkdirs") assert os.path.exists("test_mkdirs") == True