Finetune the performance of the unittests. (#26402)
parent
df7fe1fe23
commit
7c42f056e2
@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
unset https_proxy http_proxy
|
||||
export FLAGS_rpc_disable_reuse_port=1
|
||||
|
||||
name=${TEST_TARGET_NAME}
|
||||
UnitTests=${UnitTests}
|
||||
TEST_TIMEOUT=${TEST_TIMEOUT}
|
||||
|
||||
if [[ ${name}"x" == "x" ]]; then
|
||||
echo "can't find name, please set TEST_TARGET_NAME first"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ${UnitTests}"x" == "x" ]]; then
|
||||
echo "can't find UnitTests, please set TEST_TARGET_NAME first"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ${TEST_TIMEOUT}"x" == "x" ]]; then
|
||||
echo "can't find ${TEST_TIMEOUT}, please set ${TEST_TIMEOUT} first"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ${WITH_COVERAGE} == "ON" ]]; then
|
||||
PYTHON_EXEC="python -u -m coverage run --branch -p "
|
||||
else
|
||||
PYTHON_EXEC="python -u "
|
||||
fi
|
||||
|
||||
run_time=$(( $TEST_TIMEOUT - 10 ))
|
||||
echo "run_time: ${run_time}"
|
||||
for ut in ${UnitTests}; do
|
||||
echo "start ${ut}"
|
||||
timeout -s SIGKILL ${run_time} ${PYTHON_EXEC} ./${ut}.py > ${ut}_run.log 2>&1 &
|
||||
done
|
||||
|
||||
FAIL=0
|
||||
for job in `jobs -p`
|
||||
do
|
||||
echo "jobs -p result:" `jobs -p`
|
||||
echo $job
|
||||
wait $job || let FAIL=FAIL+1
|
||||
done
|
||||
|
||||
echo "fail_num:" $FAIL
|
||||
|
||||
if [ "$FAIL" == "0" ];
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
echo "FAIL! ($FAIL)"
|
||||
|
||||
for ut in ${UnitTests}; do
|
||||
log=${ut}_run.log
|
||||
echo "cat ${log}"
|
||||
cat $log
|
||||
done
|
||||
|
||||
exit 1
|
||||
fi
|
@ -0,0 +1,64 @@
|
||||
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import unittest
|
||||
import paddle
|
||||
import paddle.fluid as fluid
|
||||
import paddle.fluid.incubate.fleet.base.role_maker as role_maker
|
||||
from paddle.fluid.incubate.fleet.collective import CollectiveOptimizer, fleet
|
||||
import os
|
||||
import sys
|
||||
|
||||
from paddle.distributed.fleet.utils.fs import LocalFS, HDFSClient
|
||||
import paddle.fluid.incubate.checkpoint.auto_checkpoint as acp
|
||||
from paddle.fluid.incubate.checkpoint.checkpoint_saver import PaddleModel
|
||||
from paddle.fluid.framework import program_guard
|
||||
from paddle.fluid import unique_name
|
||||
|
||||
import numpy as np
|
||||
from paddle.io import Dataset, BatchSampler, DataLoader
|
||||
|
||||
from paddle.fluid.tests.unittests.auto_checkpoint_utils import AutoCheckpointBase, get_logger
|
||||
from paddle.fluid.tests.unittests.test_auto_checkpoint import AutoCheckPointACLBase
|
||||
|
||||
logger = get_logger()
|
||||
|
||||
|
||||
class AutoCheckpointTest1(AutoCheckPointACLBase):
|
||||
def setUp(self):
|
||||
get_logger()
|
||||
logger.info("enter tests")
|
||||
|
||||
self._old_environ = dict(os.environ)
|
||||
proc_env = {
|
||||
"PADDLE_RUNNING_ENV": "PADDLE_EDL_AUTO_CHECKPOINT",
|
||||
"PADDLE_TRAINER_ID": "0",
|
||||
"PADDLE_RUNNING_PLATFORM": "PADDLE_CLOUD",
|
||||
"PADDLE_JOB_ID": "test_job_auto_1",
|
||||
"PADDLE_EDL_HDFS_HOME": "/usr/local/hadoop-2.7.7",
|
||||
"PADDLE_EDL_HDFS_NAME": "",
|
||||
"PADDLE_EDL_HDFS_UGI": "",
|
||||
"PADDLE_EDL_HDFS_CHECKPOINT_PATH": "auto_checkpoint_1",
|
||||
"PADDLE_EDL_ONLY_FOR_CE_TEST": "1",
|
||||
"PADDLE_EDL_FS_CACHE": ".auto_checkpoint_test_1",
|
||||
"PADDLE_EDL_SAVE_CHECKPOINT_INTER": "0"
|
||||
}
|
||||
os.environ.update(proc_env)
|
||||
|
||||
def test_corner_epoch_no(self):
|
||||
self._test_corner_epoch_no(0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,64 @@
|
||||
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import unittest
|
||||
import paddle
|
||||
import paddle.fluid as fluid
|
||||
import paddle.fluid.incubate.fleet.base.role_maker as role_maker
|
||||
from paddle.fluid.incubate.fleet.collective import CollectiveOptimizer, fleet
|
||||
import os
|
||||
import sys
|
||||
|
||||
from paddle.distributed.fleet.utils.fs import LocalFS, HDFSClient
|
||||
import paddle.fluid.incubate.checkpoint.auto_checkpoint as acp
|
||||
from paddle.fluid.incubate.checkpoint.checkpoint_saver import PaddleModel
|
||||
from paddle.fluid.framework import program_guard
|
||||
from paddle.fluid import unique_name
|
||||
|
||||
import numpy as np
|
||||
from paddle.io import Dataset, BatchSampler, DataLoader
|
||||
|
||||
from paddle.fluid.tests.unittests.auto_checkpoint_utils import AutoCheckpointBase, get_logger
|
||||
from paddle.fluid.tests.unittests.test_auto_checkpoint import AutoCheckPointACLBase
|
||||
|
||||
logger = get_logger()
|
||||
|
||||
|
||||
class AutoCheckpointTest3(AutoCheckPointACLBase):
|
||||
def setUp(self):
|
||||
get_logger()
|
||||
logger.info("enter tests")
|
||||
|
||||
self._old_environ = dict(os.environ)
|
||||
proc_env = {
|
||||
"PADDLE_RUNNING_ENV": "PADDLE_EDL_AUTO_CHECKPOINT",
|
||||
"PADDLE_TRAINER_ID": "0",
|
||||
"PADDLE_RUNNING_PLATFORM": "PADDLE_CLOUD",
|
||||
"PADDLE_JOB_ID": "test_job_auto_3",
|
||||
"PADDLE_EDL_HDFS_HOME": "/usr/local/hadoop-2.7.7",
|
||||
"PADDLE_EDL_HDFS_NAME": "",
|
||||
"PADDLE_EDL_HDFS_UGI": "",
|
||||
"PADDLE_EDL_HDFS_CHECKPOINT_PATH": "auto_checkpoint_3",
|
||||
"PADDLE_EDL_ONLY_FOR_CE_TEST": "1",
|
||||
"PADDLE_EDL_FS_CACHE": ".auto_checkpoint_test_3",
|
||||
"PADDLE_EDL_SAVE_CHECKPOINT_INTER": "0"
|
||||
}
|
||||
os.environ.update(proc_env)
|
||||
|
||||
def test_corner_epoch_no(self):
|
||||
self._test_corner_epoch_no(2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,115 @@
|
||||
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import unittest
|
||||
import paddle
|
||||
import paddle.fluid as fluid
|
||||
import paddle.fluid.incubate.fleet.base.role_maker as role_maker
|
||||
from paddle.fluid.incubate.fleet.collective import CollectiveOptimizer, fleet
|
||||
import os
|
||||
import sys
|
||||
|
||||
from paddle.distributed.fleet.utils.fs import LocalFS, HDFSClient
|
||||
import paddle.fluid.incubate.checkpoint.auto_checkpoint as acp
|
||||
from paddle.fluid.incubate.checkpoint.checkpoint_saver import PaddleModel
|
||||
from paddle.fluid.framework import program_guard
|
||||
from paddle.fluid import unique_name
|
||||
|
||||
import numpy as np
|
||||
from paddle.io import Dataset, BatchSampler, DataLoader
|
||||
|
||||
from paddle.fluid.tests.unittests.auto_checkpoint_utils import AutoCheckpointBase, get_logger
|
||||
from paddle.fluid.tests.unittests.test_auto_checkpoint import AutoCheckPointACLBase
|
||||
|
||||
logger = get_logger()
|
||||
|
||||
|
||||
class AutoCheckpointTestDist(AutoCheckPointACLBase):
|
||||
def setUp(self):
|
||||
get_logger()
|
||||
logger.info("enter tests")
|
||||
|
||||
self._old_environ = dict(os.environ)
|
||||
proc_env = {
|
||||
"PADDLE_RUNNING_ENV": "PADDLE_EDL_AUTO_CHECKPOINT",
|
||||
"PADDLE_TRAINER_ID": "0",
|
||||
"PADDLE_RUNNING_PLATFORM": "PADDLE_CLOUD",
|
||||
"PADDLE_JOB_ID": "test_job_auto_dist_basic",
|
||||
"PADDLE_EDL_HDFS_HOME": "/usr/local/hadoop-2.7.7",
|
||||
"PADDLE_EDL_HDFS_NAME": "",
|
||||
"PADDLE_EDL_HDFS_UGI": "",
|
||||
"PADDLE_EDL_HDFS_CHECKPOINT_PATH": "auto_checkpoint_dist_basic",
|
||||
"PADDLE_EDL_ONLY_FOR_CE_TEST": "1",
|
||||
"PADDLE_EDL_FS_CACHE": ".auto_checkpoint_test_dist_basic",
|
||||
"PADDLE_EDL_SAVE_CHECKPOINT_INTER": "0"
|
||||
}
|
||||
os.environ.update(proc_env)
|
||||
|
||||
def test_distributed_basic(self):
|
||||
checker = acp._get_checker()
|
||||
fs = HDFSClient(checker.hdfs_home, None)
|
||||
fs.delete(checker.hdfs_checkpoint_path)
|
||||
self._reset_generator()
|
||||
|
||||
logger.info("begin test_distributed_basic")
|
||||
fs = LocalFS()
|
||||
save_dir = "./run_save_0"
|
||||
fs.delete(save_dir)
|
||||
|
||||
#basic
|
||||
exe, main_prog, startup_prog = self._generate()
|
||||
|
||||
compiled, data_loader, optimizer, loss, image, label = \
|
||||
self._init_env(exe, main_prog, startup_prog, minimize=False)
|
||||
|
||||
#fleet
|
||||
os.environ["TRAINING_ROLE"] = "TRAINER"
|
||||
os.environ["PADDLE_TRAINER_ID"] = "0"
|
||||
os.environ["PADDLE_TRAINER_ENDPOINTS"] = "127.0.0.1:6070"
|
||||
|
||||
role = role_maker.PaddleCloudRoleMaker(is_collective=True)
|
||||
fleet.init(role)
|
||||
|
||||
with fluid.program_guard(main_prog, startup_prog):
|
||||
dist_optimizer = fleet.distributed_optimizer(optimizer)
|
||||
dist_optimizer.minimize(loss)
|
||||
|
||||
exe.run(startup_prog)
|
||||
|
||||
o = None
|
||||
i = 0
|
||||
name = None
|
||||
for i in acp.train_epoch_range(3, 0):
|
||||
o = acp._get_train_epoch_range()
|
||||
name = o.name
|
||||
logger.info("_run_save_0 name:{} epoch_no:{}".format(o.name, i))
|
||||
|
||||
for data in data_loader():
|
||||
fetch = exe.run(fleet.main_program,
|
||||
feed=data,
|
||||
fetch_list=[loss])
|
||||
|
||||
self.assertEqual(len(o._exe_status), 1)
|
||||
|
||||
o = acp._get_train_epoch_range()
|
||||
assert o == None, "now train epoch must not exits now"
|
||||
self.assertEqual(i, 2)
|
||||
|
||||
fs.delete(save_dir)
|
||||
|
||||
logger.info("end test_distributed_basic")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,103 @@
|
||||
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import unittest
|
||||
import paddle
|
||||
import paddle.fluid as fluid
|
||||
import paddle.fluid.incubate.fleet.base.role_maker as role_maker
|
||||
from paddle.fluid.incubate.fleet.collective import CollectiveOptimizer, fleet
|
||||
import os
|
||||
import sys
|
||||
|
||||
from paddle.distributed.fleet.utils.fs import LocalFS, HDFSClient
|
||||
import paddle.fluid.incubate.checkpoint.auto_checkpoint as acp
|
||||
from paddle.fluid.incubate.checkpoint.checkpoint_saver import PaddleModel
|
||||
from paddle.fluid.framework import program_guard
|
||||
from paddle.fluid import unique_name
|
||||
|
||||
import numpy as np
|
||||
from paddle.io import Dataset, BatchSampler, DataLoader
|
||||
|
||||
from paddle.fluid.tests.unittests.auto_checkpoint_utils import AutoCheckpointBase, get_logger
|
||||
from paddle.fluid.tests.unittests.test_auto_checkpoint import AutoCheckPointACLBase
|
||||
|
||||
logger = get_logger()
|
||||
|
||||
|
||||
class AutoCheckpointTestMul(AutoCheckPointACLBase):
|
||||
def setUp(self):
|
||||
get_logger()
|
||||
logger.info("enter tests")
|
||||
|
||||
self._old_environ = dict(os.environ)
|
||||
proc_env = {
|
||||
"PADDLE_RUNNING_ENV": "PADDLE_EDL_AUTO_CHECKPOINT",
|
||||
"PADDLE_TRAINER_ID": "0",
|
||||
"PADDLE_RUNNING_PLATFORM": "PADDLE_CLOUD",
|
||||
"PADDLE_JOB_ID": "test_job_auto_dist_multiple",
|
||||
"PADDLE_EDL_HDFS_HOME": "/usr/local/hadoop-2.7.7",
|
||||
"PADDLE_EDL_HDFS_NAME": "",
|
||||
"PADDLE_EDL_HDFS_UGI": "",
|
||||
"PADDLE_EDL_HDFS_CHECKPOINT_PATH": "auto_checkpoint_dist_multiple",
|
||||
"PADDLE_EDL_ONLY_FOR_CE_TEST": "1",
|
||||
"PADDLE_EDL_FS_CACHE": ".auto_checkpoint_test_dist_multiple",
|
||||
"PADDLE_EDL_SAVE_CHECKPOINT_INTER": "0"
|
||||
}
|
||||
os.environ.update(proc_env)
|
||||
|
||||
def test_multiple(self):
|
||||
checker = acp._get_checker()
|
||||
fs = HDFSClient(checker.hdfs_home, None)
|
||||
fs.delete(checker.hdfs_checkpoint_path)
|
||||
self._reset_generator()
|
||||
|
||||
logger.info("begin test_multiple")
|
||||
fs = LocalFS()
|
||||
save_dir = "./run_save_0"
|
||||
fs.delete(save_dir)
|
||||
|
||||
exe, main_prog1, startup_prog1 = self._generate()
|
||||
_, main_prog2, startup_prog2 = self._generate()
|
||||
|
||||
compiled1, data_loader1, optimizer1, loss1, image1, label1 = \
|
||||
self._init_env(exe, main_prog1, startup_prog1)
|
||||
|
||||
compiled2, data_loader2, optimizer2, loss2, image2, label2 = \
|
||||
self._init_env(exe, main_prog2, startup_prog2)
|
||||
|
||||
o = None
|
||||
epochs = []
|
||||
for i in acp.train_epoch_range(3, 0):
|
||||
for data in data_loader1():
|
||||
fetch = exe.run(compiled1, feed=data, fetch_list=[loss1])
|
||||
|
||||
for data in data_loader2():
|
||||
fetch = exe.run(compiled2, feed=data, fetch_list=[loss2])
|
||||
|
||||
o = acp._get_train_epoch_range()
|
||||
self.assertEqual(len(o._exe_status), 2)
|
||||
print(o._exe_status)
|
||||
epochs.append(i)
|
||||
|
||||
o = acp._get_train_epoch_range()
|
||||
self.assertTrue(o == None, "now train epoch must not exits now")
|
||||
self.assertEqual(i, 2)
|
||||
self.assertEqual(epochs, [0, 1, 2])
|
||||
|
||||
fs.delete(save_dir)
|
||||
logger.info("end test_multiple")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,104 @@
|
||||
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import unittest
|
||||
import paddle.fluid as fluid
|
||||
import paddle.fluid.incubate.fleet.base.role_maker as role_maker
|
||||
from paddle.fluid.incubate.fleet.collective import CollectiveOptimizer, fleet
|
||||
import os
|
||||
import sys
|
||||
|
||||
from paddle.distributed.fleet.utils import LocalFS, HDFSClient, FSTimeOut, FSFileExistsError, FSFileNotExistsError
|
||||
|
||||
java_home = os.environ["JAVA_HOME"]
|
||||
|
||||
from paddle.fluid.tests.unittests.hdfs_test_utils import FSTestBase
|
||||
|
||||
|
||||
class FSTest1(FSTestBase):
|
||||
def test_timeout(self):
|
||||
fs = HDFSClient(
|
||||
"/usr/local/hadoop-2.7.7/",
|
||||
None,
|
||||
time_out=6 * 1000,
|
||||
sleep_inter=100)
|
||||
src = "hdfs_test_timeout"
|
||||
dst = "new_hdfs_test_timeout"
|
||||
fs.delete(dst)
|
||||
fs.mkdirs(src)
|
||||
fs.mkdirs(dst)
|
||||
fs.mkdirs(dst + "/" + src)
|
||||
output = ""
|
||||
try:
|
||||
fs.mv(src, dst, test_exists=False)
|
||||
self.assertFalse(1, "can't execute cmd:{} output:{}".format(cmd,
|
||||
output))
|
||||
except FSTimeOut as e:
|
||||
print("execute mv {} to {} timeout".format(src, dst))
|
||||
|
||||
cmd = "{} -mv {} {}".format(fs._base_cmd, src, dst)
|
||||
ret, output = fluid.core.shell_execute_cmd(cmd, 6 * 1000, 2 * 1000)
|
||||
self.assertNotEqual(ret, 0)
|
||||
print("second mv ret:{} output:{}".format(ret, output))
|
||||
|
||||
def test_is_dir(self):
|
||||
fs = HDFSClient(
|
||||
"/usr/local/hadoop-2.7.7/",
|
||||
None,
|
||||
time_out=6 * 1000,
|
||||
sleep_inter=100)
|
||||
self.assertFalse(fs.is_dir("./test_hdfs.py"))
|
||||
s = """
|
||||
java.io.IOException: Input/output error
|
||||
responseErrorMsg : failed to getFileStatus, errorCode: 3, path: /user/PUBLIC_KM_Data/wangxi16/data/serving_model, lparam: d868f6bb6822c621, errorMessage: inner error
|
||||
at org.apache.hadoop.util.FileSystemUtil.throwException(FileSystemUtil.java:164)
|
||||
at org.apache.hadoop.util.FileSystemUtil.dealWithResponse(FileSystemUtil.java:118)
|
||||
at org.apache.hadoop.lite.client.LiteClientImpl.getFileStatus(LiteClientImpl.java:696)
|
||||
at org.apache.hadoop.fs.LibDFileSystemImpl.getFileStatus(LibDFileSystemImpl.java:297)
|
||||
at org.apache.hadoop.fs.LiteFileSystem.getFileStatus(LiteFileSystem.java:514)
|
||||
at org.apache.hadoop.fs.FsShell.test(FsShell.java:1092)
|
||||
at org.apache.hadoop.fs.FsShell.run(FsShell.java:2285)
|
||||
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
|
||||
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79)
|
||||
at org.apache.hadoop.fs.FsShell.main(FsShell.java:2353)
|
||||
"""
|
||||
|
||||
print("split lines:", s.splitlines())
|
||||
self.assertTrue(fs._test_match(s.splitlines()) != None)
|
||||
|
||||
def test_config(self):
|
||||
config = {"fs.default.name": "hdfs://xxx", "hadoop.job.ugi": "ugi"}
|
||||
fs = HDFSClient(
|
||||
"/usr/local/hadoop-2.7.7/",
|
||||
config,
|
||||
time_out=6 * 1000,
|
||||
sleep_inter=100)
|
||||
|
||||
def test_exists(self):
|
||||
fs = HDFSClient(
|
||||
"/usr/local/hadoop-2.7.7/",
|
||||
None,
|
||||
time_out=6 * 1000,
|
||||
sleep_inter=100)
|
||||
self.assertFalse(fs.is_exist(os.path.abspath("./xxxx")))
|
||||
self.assertFalse(fs.is_dir(os.path.abspath("./xxxx")))
|
||||
self.assertTrue(fs.is_dir(os.path.abspath("./xxx/..")))
|
||||
dirs, files = fs.ls_dir(os.path.abspath("./test_hdfs1.py"))
|
||||
self.assertTrue(dirs == [])
|
||||
self.assertTrue(len(files) == 1)
|
||||
dirs, files = fs.ls_dir(os.path.abspath("./xxx/.."))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,50 @@
|
||||
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import unittest
|
||||
import paddle.fluid as fluid
|
||||
import paddle.fluid.incubate.fleet.base.role_maker as role_maker
|
||||
from paddle.fluid.incubate.fleet.collective import CollectiveOptimizer, fleet
|
||||
import os
|
||||
import sys
|
||||
|
||||
from paddle.distributed.fleet.utils import LocalFS, HDFSClient, FSTimeOut, FSFileExistsError, FSFileNotExistsError
|
||||
|
||||
java_home = os.environ["JAVA_HOME"]
|
||||
|
||||
from paddle.fluid.tests.unittests.hdfs_test_utils import FSTestBase
|
||||
|
||||
|
||||
class FSTest2(FSTestBase):
|
||||
def test_hdfs(self):
|
||||
fs = HDFSClient(
|
||||
"/usr/local/hadoop-2.7.7/",
|
||||
None,
|
||||
time_out=5 * 1000,
|
||||
sleep_inter=100)
|
||||
self._test_rm(fs)
|
||||
self._test_touch(fs)
|
||||
self._test_dirs(fs)
|
||||
|
||||
def test_local(self):
|
||||
fs = LocalFS()
|
||||
self._test_rm(fs)
|
||||
self._test_touch(fs)
|
||||
self._test_dirs(fs)
|
||||
|
||||
self._test_touch_file(fs)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,53 @@
|
||||
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import unittest
|
||||
import paddle.fluid as fluid
|
||||
import paddle.fluid.incubate.fleet.base.role_maker as role_maker
|
||||
from paddle.fluid.incubate.fleet.collective import CollectiveOptimizer, fleet
|
||||
import os
|
||||
import sys
|
||||
|
||||
from paddle.distributed.fleet.utils import LocalFS, HDFSClient, FSTimeOut, FSFileExistsError, FSFileNotExistsError
|
||||
|
||||
java_home = os.environ["JAVA_HOME"]
|
||||
|
||||
from paddle.fluid.tests.unittests.hdfs_test_utils import FSTestBase
|
||||
|
||||
|
||||
class FSTest3(FSTestBase):
|
||||
def test_hdfs(self):
|
||||
fs = HDFSClient(
|
||||
"/usr/local/hadoop-2.7.7/",
|
||||
None,
|
||||
time_out=5 * 1000,
|
||||
sleep_inter=100)
|
||||
self._test_mkdirs(fs)
|
||||
self._test_list_dir(fs)
|
||||
self._test_try_upload(fs)
|
||||
self._test_try_download(fs)
|
||||
|
||||
self._test_upload(fs)
|
||||
self._test_download(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)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Loading…
Reference in new issue