fastai / nbdev

Create delightful software with Jupyter Notebooks
https://nbdev.fast.ai/
Apache License 2.0
4.93k stars 488 forks source link

nbdev_prepare TypeError exception when parsing pycaret import #1150

Closed castorfou closed 2 years ago

castorfou commented 2 years ago

not 100% sure this is due to nbdev.

With this simple cell:

#| export
from pycaret.regression import RegressionExperiment

nbdev_prepare or nbdev_docs fails with the folowwing stacktrace:

(pycaret_nbdev) explore@explore-ThinkPad-P53:~/git/guillaume/pycaret_nbdev$ nbdev_prepare 
TypeError in /home/explore/git/guillaume/pycaret_nbdev/nbs/index.ipynb:
===========================================================================

While Executing Cell #2:
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [1], in <cell line: 1>()
----> 1 from pycaret_nbdev.core import *

File ~/git/guillaume/pycaret_nbdev/pycaret_nbdev/core.py:7, in <module>
      4 __all__ = ['foo']
      6 # %% ../nbs/00_core.ipynb 3
----> 7 from pycaret.regression import RegressionExperiment
      9 # %% ../nbs/00_core.ipynb 4
     10 def foo(): pass

[....]

File ~/miniconda3/envs/pycaret_nbdev/lib/python3.9/site-packages/IPython/core/magics/pylab.py:99, in PylabMagics.matplotlib(self, line)
     97     print("Available matplotlib backends: %s" % backends_list)
     98 else:
---> 99     gui, backend = self.shell.enable_matplotlib(args.gui.lower() if isinstance(args.gui, str) else args.gui)
    100     self._show_matplotlib_backend(args.gui, backend)

TypeError: enable_matplotlib() takes 1 positional argument but 2 were given

nbdev Tests Failed On The Following Notebooks:
==================================================
        00_core.ipynb
        index.ipynb

it looks like this call gui, backend = self.shell.enable_matplotlib(args.gui.lower() if isinstance(args.gui, str) else args.gui) is analysed as providing 2 arguments (due to ','?)

I have setup a minimalist repo to illustrate: https://github.com/castorfou/pycaret_nbdev

Just a plain new repo with nbdev_new and just added this pycaret import into 00_core.ipynb

As a workaround, I have tried with skip_exec: true in frontmatter. It works locally but not in CI/D (using gitlab not gh)

seeM commented 2 years ago

I think this is caused by an upstream issue tracked in https://github.com/fastai/execnb/issues/42. That should be fixed by https://github.com/fastai/execnb/pull/43.

seeM commented 2 years ago

I'll close this in the meantime and reopen if needed.

castorfou commented 1 year ago

do you know when release 0.1.5 will be created?

seeM commented 1 year ago

@jph00 could we please get an execnb release for https://github.com/fastai/execnb/pull/43?

jph00 commented 1 year ago

@jph00 could we please get an execnb release for fastai/execnb#43?

Absolutely! :)