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

nbdev_test_nbs --fname broke in 1.1.7 #388

Closed
igorbrigadir opened this issue Jan 18, 2021 · 4 comments · Fixed by #391
Closed

nbdev_test_nbs --fname broke in 1.1.7 #388

igorbrigadir opened this issue Jan 18, 2021 · 4 comments · Fixed by #391
Labels
bug Something isn't working

Comments

@igorbrigadir
Copy link

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
Copy link
Author

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!"

@jph00 jph00 reopened this Jan 20, 2021
@hamelsmu
Copy link
Member

hamelsmu commented Jan 20, 2021

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
Copy link
Member

@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
Copy link
Author

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!

@hamelsmu hamelsmu added the bug Something isn't working label Jan 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants