fastai / nbdev

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

nbdev_test_nbs --fname broke in 1.1.7 #388

Closed igorbrigadir closed 3 years ago

igorbrigadir commented 3 years ago

You used to be able to use a wildcard / glob in --fname parameter in nbdev_test_nbs but this seems to be broken in 1.1.7

In 1.1.6:

nbdev_test_nbs --fname "test_*"

this works.

With 1.1.7

nbdev_test_nbs --fname "test_*"

Traceback (most recent call last):
  File "/home/user/.pyenv/versions/myenv/bin/nbdev_test_nbs", line 8, in <module>
    sys.exit(nbdev_test_nbs())
  File "/home/user/.pyenv/versions/3.7.5/envs/myenv/lib/python3.7/site-packages/fastcore/script.py", line 103, in _f
    tfunc(**merge(args, args_from_prog(func, xtra)))
  File "/home/user/.pyenv/versions/3.7.5/envs/myenv/lib/python3.7/site-packages/nbdev/test.py", line 109, in nbdev_test_nbs
    files = nbglob(fname)
  File "/home/user/.pyenv/versions/3.7.5/envs/myenv/lib/python3.7/site-packages/nbdev/export.py", line 410, in nbglob
    if fname is not None and fname.is_file(): return L([fname])
AttributeError: 'str' object has no attribute 'is_file'

with a later version on pypi: 1.1.8:

Traceback (most recent call last):
  File "/home/user/.pyenv/versions/myenv/bin/nbdev_test_nbs", line 8, in <module>
    sys.exit(nbdev_test_nbs())
  File "/home/user/.pyenv/versions/3.7.5/envs/myenv/lib/python3.7/site-packages/fastcore/script.py", line 103, in _f
    tfunc(**merge(args, args_from_prog(func, xtra)))
  File "/home/user/.pyenv/versions/3.7.5/envs/myenv/lib/python3.7/site-packages/nbdev/test.py", line 109, in nbdev_test_nbs
    files = nbglob(fname)
  File "/home/user/.pyenv/versions/3.7.5/envs/myenv/lib/python3.7/site-packages/nbdev/export.py", line 413, in nbglob
    else: fls = fname.glob(f'*{extension}')
AttributeError: 'str' object has no attribute 'glob'

With the latest pypi version, 1.1.11:

All tests are passing!

But this is wrong, because it doesn't even attempt to run the notebooks.

igorbrigadir commented 3 years ago

Unfortunately the fix in #391 does not solve it in 1.1.12 either.

When using a glob like "*_test.ipynb" it does not execute the notebooks, just skips to "All tests are passing!"

hamelsmu commented 3 years ago

I'm not sure what you are doing wrong, is it because you aren't passing in the proper directory? from the root of this repo:

nbdev_test_nbs --fname nbs/*_test.ipynb                                  
testing /Users/hamelsmu/github/nbdev/nbs/04_test.ipynb
All tests are passing!
hamelsmu commented 3 years ago

@igorbrigadir I also tested your repo and it works just fine

gh repo clone igorbrigadir/nbdev-api-template
cd nbdev-api-template

Followed by

nbdev_test_nbs --fname test_*                                                    
testing /Users/hamelsmu/github/nbdev-api-template/test_nbdev.ipynb
...

Closing this issue. However, happy to repoen if you can provide a reproduceable example, with a link to a repo with files. Thanks!

My only guess is you aren't using the latest version of nbdev. You must clone this repo and do pip install -e . from the root. There might have not been a release yet with yesterday's PR.

igorbrigadir commented 3 years ago

Thanks so much for checking!

My only guess is you aren't using the latest version of nbdev. You must clone this repo and do pip install -e . from the root. There might have not been a release yet with yesterday's PR.

Yes, that was exactly my mistake - i used pip install --upgrade git+https://github.com/fastai/nbdev.git but that didn't actually replace the existing one i had, installing the latest master version resolves this issue.

It all works now! Thanks!