Skip to content

Commit

Permalink
Disabling progress bars for sphinx-gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
bloomdt-uw committed Oct 3, 2020
1 parent d778f8a commit 9ccb90d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
37 changes: 37 additions & 0 deletions docs/source/_progressbars.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
def _no_tqdm(iterable, *args, **kwargs):
"""
replacement for tqdm that just passes back the iterable to silence `tqdm`
"""
return iterable


def _no_progressbar(progress, total_length):
"""
no-op calls to update the `fetcher` progress bar
"""
return


def reset_progressbars(gallery_conf, fname):
"""
monkey patch to disable various progress bar output for examples. the
progress bar updates pollutes sphinx gallery output. using this monkey
patch from the spinx-build will leave the progress bars in place for other
uses.
"""

# disable tqdm
import AFQ.data as afd
import AFQ._fixes as fixes
import AFQ.segmentation as seg
import AFQ.viz.utils as utils

afd.tqdm = _no_tqdm
fixes.tqdm = _no_tqdm
seg.tqdm = _no_tqdm
utils.tqdm = _no_tqdm

# disable update_progressbar
from dipy.data import fetcher

fetcher.update_progressbar = _no_progressbar
5 changes: 4 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.

import sys, os

sys.path.insert(0, os.path.abspath('.'))
sys.path.append(os.path.abspath('sphinxext'))
# sys.path.insert(0, os.path.abspath('.'))


# -- Project information -----------------------------------------------------
Expand Down Expand Up @@ -181,13 +182,15 @@
from plotly.io._sg_scraper import plotly_sg_scraper
image_scrapers = ('matplotlib', plotly_sg_scraper,)

from _progressbars import reset_progressbars

sphinx_gallery_conf = {
# path to your examples scripts
'examples_dirs': '../../examples',
# path where to save gallery generated examples
'gallery_dirs': 'auto_examples',
'image_scrapers': image_scrapers,
'reset_modules': (reset_progressbars),
}

# Auto API
Expand Down

0 comments on commit 9ccb90d

Please sign in to comment.