You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I followed the nbdev_cards tutorial, but setting recursive=True in settings.ini. I was able to successfully complete all the steps except for the last one, which is previewing the docs. When I run nbdev_preview --port 3012, it throws the following error:
Preparing to preview
Traceback (most recent call last):
File "/anaconda/envs/nbdevv2_master/lib/python3.10/site-packages/IPython/core/formatters.py", line 222, in catch_format_error
r = method(self, *args, **kwargs)
File "/anaconda/envs/nbdevv2_master/lib/python3.10/site-packages/IPython/core/formatters.py", line 343, in __call__
return method()
File "/home/jcidatascience/jaume/workspace/other/nbdevv2/nbdev/nbdev/showdoc.py", line 166, in _repr_markdown_
src = NbdevLookup().code(self.fn)
File "/home/jcidatascience/jaume/workspace/other/nbdevv2/nbdev/nbdev/doclinks.py", line 204, in code
line = _lineno(sym, py)
File "/workspace/nbdev/nbdev/doclinks.py", line 149, in _lineno
def _lineno(sym, fname): return _get_exps(fname).get(sym.rpartition('.')[2], None) if fname else None
File "/workspace/nbdev/nbdev/doclinks.py", line 140, in _get_exps
mf = _find_mod(mod)
File "/workspace/nbdev/nbdev/doclinks.py", line 135, in _find_mod
loc = Path(importlib.util.find_spec(mp).origin).parent
AttributeError: 'NoneType' object has no attribute 'origin'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/anaconda/envs/nbdevv2_master/bin/nbdev_filter", line 33, in <module>
sys.exit(load_entry_point('nbdev', 'console_scripts', 'nbdev_filter')())
File "/anaconda/envs/nbdevv2_master/lib/python3.10/site-packages/fastcore/script.py", line 117, in _f
return tfunc(**merge(args, args_from_prog(func, xtra)))
File "/workspace/nbdev/nbdev/cli.py", line 64, in nbdev_filter
with redirect_stdout(dn): filt.nb_proc(nb).process()
File "/workspace/nbdev/nbdev/process.py", line 122, in process
for proc in self.procs: self._proc(proc)
File "/workspace/nbdev/nbdev/process.py", line 115, in _proc
for cell in self.nb.cells: self._process_cell(proc, cell)
File "/workspace/nbdev/nbdev/process.py", line 106, in _process_cell
if callable(proc) and not _is_direc(proc): cell = opt_set(cell, proc(cell))
File "/workspace/nbdev/nbdev/processors.py", line 290, in __call__
if self.k.exc: raise Exception(f"Error{' in notebook: '+title if title else ''} in cell {cell.idx_} :\n{cell.source}") from self.k.exc[1]
Exception: Error in notebook: Additions in cell 6 :
#|output: asis
#| echo: false
show_doc(Other)
I was able to provide a fix (not easy, since ipdb doesn't seem to work well with nbdev_preview). The fix is as follows:
Right before line 135 of nbdev/doclinks.py in _find_mod, we need to do:
mp=str(mp).replace ('/', '.')
before the original line
loc = Path(importlib.util.find_spec(mp).origin).parent
By doing so, importlib.util.find_spec is able to successfully find the module mp. Originally it was returning None.
However, after this fix, I run nbdev_preview and quarto throws the following error:
ERROR: SyntaxError: Unexpected token l in JSON at position 0
I wasn't able to debug this error, unfortunately.
A separate issue I found is that, when running nbdev_new, I need to indicate --recursive True --nbs_path nbs:
nbdev_new --recursive True --nbs_path nbs
Otherwise, if I just run nbdev_new and then edit settings.ini and change recursive in there, it doesn't work. I didn't find this in the tutorial when it talks about using nbdev_new. But this is minor thing, might not be important at all.
Thank you!
Jaume
The text was updated successfully, but these errors were encountered:
Thanks for the clear issue. Your fix in _find_mod was very close - but the actual fix was to use partition() instead of rpartition().
Please try installing from master, and if you're still having any problems, please open a new issue letting us know how we can repro it (ideally with a link to a github repo showing the problem).
I followed the nbdev_cards tutorial, but setting
recursive=True
insettings.ini
. I was able to successfully complete all the steps except for the last one, which is previewing the docs. When I runnbdev_preview --port 3012
, it throws the following error:I was able to provide a fix (not easy, since ipdb doesn't seem to work well with nbdev_preview). The fix is as follows:
Right before line 135 of
nbdev/doclinks.py
in_find_mod
, we need to do:before the original line
By doing so, importlib.util.find_spec is able to successfully find the module
mp
. Originally it was returning None.However, after this fix, I run nbdev_preview and quarto throws the following error:
I wasn't able to debug this error, unfortunately.
A separate issue I found is that, when running nbdev_new, I need to indicate --recursive True --nbs_path nbs:
Otherwise, if I just run
nbdev_new
and then editsettings.ini
and change recursive in there, it doesn't work. I didn't find this in the tutorial when it talks about usingnbdev_new
. But this is minor thing, might not be important at all.Thank you!
Jaume
The text was updated successfully, but these errors were encountered: