From 02e7e134a1e1c1a2eb4ea5913f2c9479a5baf913 Mon Sep 17 00:00:00 2001 From: jajupmochi Date: Mon, 2 Mar 2020 17:10:42 +0100 Subject: [PATCH] allow pytest-cov to consider codes in Python pool. --- .travis.yml | 5 ++++- gklearn/tests/requirements.txt | 14 +++++++------- gklearn/utils/ipython_log.py | 7 ------- gklearn/utils/parallel.py | 5 ++++- 4 files changed, 15 insertions(+), 16 deletions(-) delete mode 100644 gklearn/utils/ipython_log.py diff --git a/.travis.yml b/.travis.yml index f8f21e0..4603f2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,10 @@ before_install: - pip install pytest-cov install: -- pip install -r requirements.txt +- if [ $TRAVIS_PYTHON_VERSION == 3.8 ]; + then pip install -r gklearn/tests/requirements.txt; + else pip install -r requirements.txt; + fi - pip install wheel script: diff --git a/gklearn/tests/requirements.txt b/gklearn/tests/requirements.txt index a48620b..d0aa596 100644 --- a/gklearn/tests/requirements.txt +++ b/gklearn/tests/requirements.txt @@ -1,7 +1,7 @@ -numpy==1.15.2 -scipy==1.1.0 -matplotlib==3.0.0 -networkx==2.2 -scikit-learn==0.20.0 -tabulate==0.8.2 -tqdm==4.26.0 +numpy +scipy +matplotlib +networkx +scikit-learn +tabulate +tqdm diff --git a/gklearn/utils/ipython_log.py b/gklearn/utils/ipython_log.py deleted file mode 100644 index 9574d84..0000000 --- a/gklearn/utils/ipython_log.py +++ /dev/null @@ -1,7 +0,0 @@ -# IPython log file - -runfile('/media/ljia/DATA/research-repo/codes/Linlin/py-graph/preimage/test_iam.py', wdir='/media/ljia/DATA/research-repo/codes/Linlin/py-graph/preimage') -runfile('/media/ljia/DATA/research-repo/codes/Linlin/py-graph/preimage/test_iam.py', wdir='/media/ljia/DATA/research-repo/codes/Linlin/py-graph/preimage') -runfile('/media/ljia/DATA/research-repo/codes/Linlin/py-graph/preimage/test_iam.py', wdir='/media/ljia/DATA/research-repo/codes/Linlin/py-graph/preimage') -runfile('/media/ljia/DATA/research-repo/codes/Linlin/py-graph/preimage/test_iam.py', wdir='/media/ljia/DATA/research-repo/codes/Linlin/py-graph/preimage') -runfile('/media/ljia/DATA/research-repo/codes/Linlin/py-graph/preimage/test_iam.py', wdir='/media/ljia/DATA/research-repo/codes/Linlin/py-graph/preimage') diff --git a/gklearn/utils/parallel.py b/gklearn/utils/parallel.py index 603164a..46e9217 100644 --- a/gklearn/utils/parallel.py +++ b/gklearn/utils/parallel.py @@ -33,6 +33,8 @@ def parallel_me(func, func_assign, var_to_assign, itr, len_itr=None, init_worker desc=itr_desc, file=sys.stdout) if verbose else pool.imap_unordered(func, itr, chunksize)): func_assign(result, var_to_assign) + pool.close() + pool.join() else: if n_jobs == None: n_jobs = multiprocessing.cpu_count() @@ -46,7 +48,8 @@ def parallel_me(func, func_assign, var_to_assign, itr, len_itr=None, init_worker desc=itr_desc, file=sys.stdout) if verbose else pool.imap_unordered(func, itr, chunksize)): func_assign(result, var_to_assign) - + pool.close() + pool.join() def parallel_gm(func, Kmatrix, Gn, init_worker=None, glbv=None,