提交 f6d414d2 编写于 作者: K Kaipeng Deng 提交者: GitHub

enable data unittest (#216)

* enable data unittest
上级 ae3e9a8b
# add python requirements for unittests here, note install Cython # add python requirements for unittests here, note install pycocotools
# and pycocotools directly is not supported in travis ci. # directly is not supported in travis ci, it is installed by compiling
# from source files in unittest.sh
tqdm tqdm
cython
...@@ -12,7 +12,7 @@ unittest(){ ...@@ -12,7 +12,7 @@ unittest(){
if [ $? != 0 ]; then if [ $? != 0 ]; then
exit 1 exit 1
fi fi
find "./ppdet/modeling" -name 'tests' -type d -print0 | \ find "./ppdet" -name 'tests' -type d -print0 | \
xargs -0 -I{} -n1 bash -c \ xargs -0 -I{} -n1 bash -c \
'python -m unittest discover -v -s {}' 'python -m unittest discover -v -s {}'
} }
...@@ -20,11 +20,26 @@ unittest(){ ...@@ -20,11 +20,26 @@ unittest(){
trap 'abort' 0 trap 'abort' 0
set -e set -e
# install travis python dependencies # install travis python dependencies exclude pycocotools
if [ -f ".travis/requirements.txt" ]; then if [ -f ".travis/requirements.txt" ]; then
pip install -r .travis/requirements.txt pip install -r .travis/requirements.txt
fi fi
# install pycocotools
if [ `pip list | grep pycocotools | wc -l` -eq 0 ]; then
# install git if needed
if [ -n `which git` ]; then
apt-get update
apt-get install -y git
fi;
git clone https://github.com/cocodataset/cocoapi.git
cd cocoapi/PythonAPI
make install
python setup.py install --user
cd ../..
rm -rf cocoapi
fi
export PYTHONPATH=`pwd`:$PYTHONPATH export PYTHONPATH=`pwd`:$PYTHONPATH
unittest . unittest .
......
...@@ -70,10 +70,11 @@ class ParallelMap(object): ...@@ -70,10 +70,11 @@ class ParallelMap(object):
"multi-process reader on Windows.") "multi-process reader on Windows.")
self._use_process = False self._use_process = False
if self._use_process and type(memsize) is str: if self._use_process and type(memsize) is str:
assert memsize[-1].lower() == 'g', \ assert memsize[-1].lower() in ['g', 'm'], \
"invalid param for memsize[%s], should be ended with 'G' or 'g'" % (memsize) "invalid param for memsize[%s], should be " \
gb = memsize[:-1] "ended with 'G' or 'g' or 'M' or 'm'" % (memsize)
self._memsize = int(gb) * 1024**3 power = 3 if memsize[-1].lower() == 'g' else 2
self._memsize = int(memsize[:-1]) * (1024**power)
self._started = False self._started = False
self._source = source self._source = source
self._worker = worker self._worker = worker
......
...@@ -109,7 +109,7 @@ class TestDataset(unittest.TestCase): ...@@ -109,7 +109,7 @@ class TestDataset(unittest.TestCase):
return 2 * sample return 2 * sample
test_worker = ParallelMap( test_worker = ParallelMap(
mem_sc, _worker, worker_num=2, use_process=True) mem_sc, _worker, worker_num=2, use_process=True, memsize='2M')
ct = 0 ct = 0
for i, d in enumerate(test_worker): for i, d in enumerate(test_worker):
...@@ -131,7 +131,7 @@ class TestDataset(unittest.TestCase): ...@@ -131,7 +131,7 @@ class TestDataset(unittest.TestCase):
return 2 * sample return 2 * sample
test_worker = ParallelMap( test_worker = ParallelMap(
mem_sc, _worker, worker_num=2, use_process=True) mem_sc, _worker, worker_num=2, use_process=True, memsize='2M')
ct = 0 ct = 0
for i, d in enumerate(test_worker): for i, d in enumerate(test_worker):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册