Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include notebook title in nbdev_preview error message #802

Closed
michaelaye opened this issue Aug 8, 2022 · 4 comments · Fixed by #828
Closed

Include notebook title in nbdev_preview error message #802

michaelaye opened this issue Aug 8, 2022 · 4 comments · Fixed by #828
Labels
enhancement New feature or request

Comments

@michaelaye
Copy link
Contributor

I just launched nbdev_preview and it fails with an import error, but doesn't tell which notebook it is from:

This is all I got from nbdev_preview:

…/nbplanetary ❯ nbdev_preview
Preparing to preview
Traceback (most recent call last):
  File "/home/ayek72/mambaforge/envs/py310/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3398, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-1-04f883e015f1>", line 9, in <cell line: 9>
ImportError: cannot import name 'test_fail' from 'fastcore.utils' (/home/ayek72/mambaforge/envs/py310/lib/python3.10/site-packages/fastcore/utils.py)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ayek72/mambaforge/envs/py310/bin/nbdev_filter", line 8, in <module>
    sys.exit(nbdev_filter())
  File "/home/ayek72/mambaforge/envs/py310/lib/python3.10/site-packages/fastcore/script.py", line 116, in _f
    return tfunc(**merge(args, args_from_prog(func, xtra)))
  File "/home/ayek72/mambaforge/envs/py310/lib/python3.10/site-packages/nbdev/cli.py", line 127, in nbdev_filter
    with redirect_stdout(dn): filt.nb_proc(nb).process()
  File "/home/ayek72/mambaforge/envs/py310/lib/python3.10/site-packages/nbdev/process.py", line 130, in process
    for cell in self.nb.cells: self._process_cell(cell)
  File "/home/ayek72/mambaforge/envs/py310/lib/python3.10/site-packages/nbdev/process.py", line 111, in _process_cell
    cell = opt_set(cell, proc(cell))
  File "/home/ayek72/mambaforge/envs/py310/lib/python3.10/site-packages/nbdev/processors.py", line 298, in __call__
    if self.k.exc: raise Exception(f'Error: cell {cell.idx_}:\n{cell.source}') from self.k.exc[1]
Exception: Error: cell 5:
import zipfile
from datetime import timedelta
from io import BytesIO
from pathlib import Path

import requests
from astropy.time import Time
from dask.distributed import Client
from fastcore.utils import store_attr, test_fail
from tqdm.auto import tqdm
from yarl import URL

import pandas as pd
from planetarypy.config import config
from planetarypy.utils import nasa_time_to_iso, url_retrieve

Now, question is of course, if that is within the purview of nbdev_preview, as nbdev_test will of course show the failing notebook?

Version: 2.1.3

@benoit-cty
Copy link
Contributor

👍 it will be nice to have this information.

@hamelsmu
Copy link
Member

This is indeed the function of nbdev_test -> that will show you which notebook fails. You should use that for testing

@benoit-cty
Copy link
Contributor

Hello @hamelsmu nbdev_test will execute all cells of all notebooks, here we only ask for name of notebook than makes nbdev_preview to fail.

In one of my project, I have 50 notebooks. Some of them requires special context (secret data and/or special librairies) to be run so nbdev_test will always failed. But I still want documentation for them.

I was able to fix all nbdev_preview errors by searching for strings... Having the name will have saved my time.

@hamelsmu hamelsmu reopened this Aug 11, 2022
@hamelsmu
Copy link
Member

Ok, we will think about a way to handle this. Thank you

@hamelsmu hamelsmu added the enhancement New feature or request label Aug 11, 2022
@seeM seeM changed the title nbdev_preview does not say which notebook failed Include notebook title in nbdev_preview error message Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants