ThomasDelteil commented on a change in pull request #10495: [MXNET-307] Add tutorials to the CI + Fix them URL: https://github.com/apache/incubator-mxnet/pull/10495#discussion_r180914065
########## File path: tests/nightly/test_tutorial.py ########## @@ -25,87 +25,116 @@ import os import warnings import imp - +import shutil +import time +import argparse import traceback import nbformat from nbconvert.preprocessors import ExecutePreprocessor +import sys fail_dict = {} +TIME_OUT = 1800 -def test_tutorial(file_path): - """Run tutorial python script and save any error or warning. - If no error or warning occurs, run notebook. - - Parameters - ---------- - file_path : str - path of tutorial markdown file - """ - with warnings.catch_warnings(record=True) as w: - tutorial_name = os.path.basename(file_path) - print file_path + '.py' - try: - imp.load_source('tutorial', file_path + '.py') - if len(w) > 0: - err_msg = "%s.py has %d warnings.\n" % (tutorial_name, len(w)) - fail_dict[tutorial_name] = err_msg - else: - test_tutorial_nb(file_path) - except Exception: - err_msg = "%s.py has error:\n%s" % (tutorial_name, traceback.format_exc()) - fail_dict[tutorial_name] = err_msg - -def test_tutorial_nb(file_path): +def test_tutorial_nb(file_path, workingdir, kernel=None): """Run tutorial jupyter notebook to catch any execution error. Parameters ---------- file_path : str - path of tutorial markdown file + path of tutorial .ipynb file + workingdir: str + path of the directory to run the tutorial in + kernel: str + Default None + name of the kernel to use, if none, will use first kernel + in the list """ tutorial_name = os.path.basename(file_path) + sys.stdout.write('Testing {}...'.format(file_path)) + sys.stdout.flush() + tick = time.time() notebook = nbformat.read(file_path + '.ipynb', as_version=4) - eprocessor = ExecutePreprocessor(timeout=1800) + if kernel: + eprocessor = ExecutePreprocessor(timeout=TIME_OUT, kernel_name=kernel) + else: + eprocessor = ExecutePreprocessor(timeout=TIME_OUT) + success = True try: - eprocessor.preprocess(notebook, {'metadata': {}}) + os.environ['MXNET_STORAGE_FALLBACK_LOG_VERBOSE'] = '0' + os.environ['MXNET_CUDNN_AUTOTUNE_DEFAULT'] = '0' Review comment: That is very true and was the plan, leftover from trying to remove as much stdout output as possible. I will remove them from this script. However I think autotune=0 is fine since it is actually improving the speed (all these models are very fast to train, and auto-tune is actually slowing them down by heading a fixed over-head), and if there is something wrong with auto-tune, it is going to be picked up in a different test anyway. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services