Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Commit

Permalink
using enlighten progress-bar
Browse files Browse the repository at this point in the history
* upgrade pip
* drop opencv sys pkg
* typo OpenSlide #42
  • Loading branch information
Borda committed Oct 11, 2019
1 parent 0944b9b commit 44cf2f8
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .shippable.yml
Expand Up @@ -25,7 +25,7 @@ before_install:
- apt-get install freetype*
- apt-get install python-dev python-tk python3-dev python3-tk
- apt-get install pkg-config
- apt-get install python-opencv openslide-tools
- apt-get install openslide-tools
- pip install --upgrade pip

install:
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -31,15 +31,15 @@ matrix:
cache: pip

install:
- sudo apt-get install python-opencv openslide-tools
- sudo apt-get install openslide-tools
- pip install -r requirements.txt
- pip install -r ./tests/requirements.txt
- pip install tox
- pip --version ; pip list

script:
# integration
- tox --sitepackages
- tox -v --sitepackages
# sample run
- mkdir results && touch configs/sample_config.yaml
- python bm_experiments/bm_comp_perform.py -o ./results -n 1
Expand Down
13 changes: 8 additions & 5 deletions appveyor.yml
Expand Up @@ -55,10 +55,13 @@ install:
# The AppVeyor 'rollout builds' option is supposed to serve the same
# purpose but it is problematic because it tends to cancel builds pushed
# directly to master instead of just PR builds (or the converse).
- choco upgrade chocolatey
- choco install -y opencv
- SET PATH=%PYTHON%;%PYTHON%\\Scripts;%path%
- pip install -U --user pip
#- choco upgrade chocolatey
#- choco install -y opencv
# Prepend newly installed Python to the PATH of this build (this cannot be
# done from inside the powershell script as it would require to restart
# the parent CMD process).
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
- python -m pip install --upgrade pip
- pip install -r requirements.txt
- pip install -r ./tests/requirements.txt
- pip install tox
Expand All @@ -72,7 +75,7 @@ before_test:

# to run your custom scripts instead of automatic tests
test_script:
- tox --sitepackages --parallel auto
- tox -v --sitepackages --parallel auto
- mkdir results && touch configs/sample_config.yaml
- python bm_experiments/bm_comp_perform.py -o ./results -n 1
- python birl/bm_template.py -t ./data_images/pairs-imgs-lnds_mix.csv -o ./results --preprocessing matching-rgb gray --unique --visual -cfg configs/sample_config.yaml
Expand Down
14 changes: 8 additions & 6 deletions birl/utilities/experiments.py
Expand Up @@ -19,7 +19,7 @@
import multiprocessing as mproc
from functools import wraps

import tqdm
import enlighten
import numpy as np
from pathos.multiprocessing import ProcessPool

Expand Down Expand Up @@ -541,10 +541,12 @@ def iterate_mproc_map(wrap_func, iterate_vals, nb_workers=CPU_COUNT, desc=''):
nb_workers = 1 if not nb_workers else int(nb_workers)
nb_workers = CPU_COUNT if nb_workers < 0 else nb_workers

tqdm_bar = None
if desc is not None:
desc = '%r @%i-threads' % (desc, nb_workers)
tqdm_bar = tqdm.tqdm(total=len(iterate_vals), desc=desc)
pbar = enlighten.Counter(total=len(iterate_vals),
desc=str('%r @%i-threads' % (desc, nb_workers)),
stream=sys.stderr)
else:
pbar = None

if nb_workers > 1:
logging.debug('perform parallel in %i threads', nb_workers)
Expand All @@ -563,15 +565,15 @@ def iterate_mproc_map(wrap_func, iterate_vals, nb_workers=CPU_COUNT, desc=''):
mapping = map

for out in mapping(wrap_func, iterate_vals):
tqdm_bar.update() if tqdm_bar is not None else None
pbar.update() if pbar else None
yield out

if pool:
pool.close()
pool.join()
pool.clear()

tqdm_bar.close() if tqdm_bar is not None else None
pbar.close() if pbar else None


# from pathos.helpers import mp
Expand Down
4 changes: 2 additions & 2 deletions bm_dataset/convert_tiff2png.py
Expand Up @@ -34,8 +34,8 @@
try:
from openslide import OpenSlide
except Exception:
print('It seems that you do not have installed OpenSlides on your computer.'
' To do so, please follow instructions - https://openslides.org')
print('It seems that you do not have installed OpenSlide on your computer.'
' To do so, please follow instructions - https://openslide.org/')

sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from birl.utilities.experiments import iterate_mproc_map, nb_workers
Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Expand Up @@ -8,7 +8,7 @@ references:
command: |
sudo apt-get update
sudo apt-get install tk-dev pkg-config python-dev python-tk tree
sudo apt-get install python-opencv openslide-tools
sudo apt-get install openslide-tools
install_pips: &install_pips
run:
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Expand Up @@ -13,4 +13,5 @@ nibabel
SimpleITK
mock
psutil
pathos
pathos
enlighten>=1.3.3 # fix for Windows
9 changes: 8 additions & 1 deletion tox.ini
Expand Up @@ -11,6 +11,9 @@
#
# and also to help confirm pull requests to this project.

[build-system]
requires = [ "pip >= 18.0" ]

[tox]
envlist = py{27,35,36,37}

Expand All @@ -24,6 +27,9 @@ log_file_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(linen
log_file_date_format=%Y-%m-%d %H:%M:%S

[testenv]
# https://github.com/tox-dev/tox/issues/791
download = true
sitepackages = True
basepython =
py27: python2.7
py35: python3.5
Expand All @@ -34,7 +40,8 @@ deps =
-r ./tests/requirements.txt
commands =
check-manifest --ignore tox.ini
python setup.py check -m -s
python setup.py check --metadata --strict
python setup.py install --dry-run --user
coverage run --source birl -m py.test birl tests bm_dataset bm_experiments bm_ANHIR -v --doctest-modules
flake8 .

Expand Down

0 comments on commit 44cf2f8

Please sign in to comment.