Skip to content

Commit 8dc2d25

Browse files
authored
exclude img subdir from travis due to slow dlib download (#677)
* exclude img subdir from travis due to slow dlib download * disable image tests * add ignore_subpackages option to make_api.py * add ignore_subpackages option to make_api.py * add ignore_subpackages option to make_api.py * add ignore_subpackages option to make_api.py * add ignore_subpackages option to make_api.py * add ignore_subpackages option to make_api.py
1 parent 18fdace commit 8dc2d25

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ matrix:
2020
- os: linux
2121
sudo: required
2222
python: 3.8
23-
env: LATEST="false" IMAGE="true" COVERAGE="false" NUMPY_VERSION="1.18.1" SCIPY_VERSION="1.4.1" SKLEARN_VERSION="0.22.0" JOBLIB_VERSION=0.13.2 PANDAS_VERSION="1.0.1" IMAGEIO_VERSION="2.5.0" SKIMAGE_VERSION="0.15.0" DLIB_VERSION="19.17.0" MINICONDA_PYTHON_VERSION=3.7
23+
env: LATEST="false" IMAGE="false" COVERAGE="false" NUMPY_VERSION="1.18.1" SCIPY_VERSION="1.4.1" SKLEARN_VERSION="0.22.0" JOBLIB_VERSION=0.13.2 PANDAS_VERSION="1.0.1" IMAGEIO_VERSION="2.5.0" SKIMAGE_VERSION="0.15.0" DLIB_VERSION="19.17.0" MINICONDA_PYTHON_VERSION=3.7
2424
- os: linux
2525
python: 3.8
26-
env: LATEST="true" IMAGE="true" COVERAGE="true" NOTEBOOKS="true" MINICONDA_PYTHON_VERSION=3.7
26+
env: LATEST="true" IMAGE="false" COVERAGE="true" NOTEBOOKS="true" MINICONDA_PYTHON_VERSION=3.7
2727
- os: linux
2828
sudo: required
2929
python: 3.8

ci/.travis_test.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ fi
3535

3636
if [[ "$NOTEBOOKS" == "true" ]]; then
3737
cd docs
38-
python make_api.py
39-
find sources -name "*.ipynb" -exec jupyter nbconvert --to notebook --execute {} \;
38+
39+
if [[ "$IMAGE" == "true" ]]; then
40+
python make_api.py
41+
find sources -name "*.ipynb" -exec jupyter nbconvert --to notebook --execute {} \;
42+
else
43+
python make_api.py --ignore_packages "mlxtend.image"
44+
find sources -name "*.ipynb" -not -path "sources/user_guide/image/*" -exec jupyter nbconvert --to notebook --execute {} \;
45+
46+
fi
4047
fi

docs/make_api.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ def get_functions_and_classes(package):
235235
return classes, functions
236236

237237

238-
def generate_api_docs(package, api_dir, clean=False, printlog=True):
238+
def generate_api_docs(package, api_dir, clean=False,
239+
printlog=True, ignore_packages=None):
239240
"""Generate a module level API documentation of a python package.
240241
241242
Description
@@ -253,6 +254,11 @@ def generate_api_docs(package, api_dir, clean=False, printlog=True):
253254
Removes previously existing API directory if True.
254255
printlog : bool (default: True)
255256
Prints a progress log to the standard output screen if True.
257+
ignore_packages : iterable or None (default: None)
258+
Iterable (list, set, tuple) that contains the names of packages
259+
and subpackages to ignore or skip. For instance, if the
260+
images subpackage in mlxtend is supposed to be split, provide the
261+
argument `{mlxtend.image}`.
256262
257263
"""
258264
if printlog:
@@ -269,6 +275,11 @@ def generate_api_docs(package, api_dir, clean=False, printlog=True):
269275
api_docs = {}
270276
for importer, pkg_name, is_pkg in pkgutil.iter_modules(
271277
package.__path__, prefix):
278+
279+
if ignore_packages is not None and pkg_name in ignore_packages:
280+
if printlog:
281+
print('ignored %s' % pkg_name)
282+
continue
272283
if is_pkg:
273284
subpackage = __import__(pkg_name, fromlist="dummy")
274285
prefix = subpackage.__name__ + "."
@@ -418,7 +429,7 @@ def summarize_methdods_and_functions(api_modules, out_dir,
418429
parser.add_argument('-o2', '--output_subpackage_api',
419430
default='../docs/sources/api_subpackages',
420431
help=('Target directory for the'
421-
'subpackage-level API Markdown files'))
432+
' subpackage-level API Markdown files'))
422433
parser.add_argument('-c', '--clean',
423434
action='store_true',
424435
help='Remove previous API files')
@@ -428,13 +439,24 @@ def summarize_methdods_and_functions(api_modules, out_dir,
428439
parser.add_argument('-v', '--version',
429440
action='version',
430441
version='v. 0.1')
442+
parser.add_argument('--ignore_packages',
443+
default='',
444+
help='Ignores subpackages listed via this option.'
445+
' For example, to ignore mlxtend.image,'
446+
' type "mlxtend.image".'
447+
' For multiple subpackages, separate them via,'
448+
' commas. For example,'
449+
' "mlxtend.image,mlxtend.plotting".')
431450

432451
args = parser.parse_args()
433452

453+
ignore_packages_set = set(args.ignore_packages.split(","))
454+
434455
package = import_package(args.package_dir, args.package_name)
435456
generate_api_docs(package=package,
436457
api_dir=args.output_module_api,
437458
clean=args.clean,
459+
ignore_packages=ignore_packages_set,
438460
printlog=not(args.silent))
439461
summarize_methdods_and_functions(api_modules=args.output_module_api,
440462
out_dir=args.output_subpackage_api,

0 commit comments

Comments
 (0)