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

expected str, bytes or os.PathLike object, not NoneType #614

Closed
yangtzech opened this issue Nov 7, 2022 · 3 comments
Closed

expected str, bytes or os.PathLike object, not NoneType #614

yangtzech opened this issue Nov 7, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@yangtzech
Copy link
Contributor

Hi, I'm trying to contribute to this project. But there is an error in the last cell:

#|eval: false
#|hide
nb_name = get_nb_name()
create_scripts(nb_name)
nbdev_clean(nb_name)

The log is:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_2438039/1984457786.py in <module>
      2 #|hide
      3 nb_name = get_nb_name()
----> 4 create_scripts(nb_name)
      5 nbdev_clean(nb_name)

~/yzc/repos/tsai/tsai/imports.py in create_scripts(nb_name, max_elapsed, wait)
    173     from nbdev.clean import nbdev_clean
    174     save_nb(nb_name, wait=wait)
--> 175     full_nb_name = str(Path.cwd()/nb_name)
    176     nb_export(full_nb_name)
    177     output = py_last_saved(nb_name, max_elapsed)

~/anaconda3/envs/tsai_dev/lib/python3.7/pathlib.py in __truediv__(self, key)
    923 
    924     def __truediv__(self, key):
--> 925         return self._make_child((key,))
    926 
    927     def __rtruediv__(self, key):

~/anaconda3/envs/tsai_dev/lib/python3.7/pathlib.py in _make_child(self, args)
    702 
    703     def _make_child(self, args):
...
--> 658                 a = os.fspath(a)
    659                 if isinstance(a, str):
    660                     # Force-cast str subclasses to str (issue #21127)

TypeError: expected str, bytes or os.PathLike object, not NoneType

It seems the ‘nb_name‘ is None

@yangtzech
Copy link
Contributor Author

yangtzech commented Nov 9, 2022

Switch from VSCode notebook to Jupyter notebook and after several times of *.ipynb couldn't be saved, finally it is saved and exported.

oguiza added a commit that referenced this issue Nov 9, 2022
@oguiza
Copy link
Contributor

oguiza commented Nov 9, 2022

Hi @yangtzech,
It's great to hear you want to contribute to tsai.
I've looked into the issue and have created a fix. I've updated (and simplified) the code to save the nb and convert the nb to a script. Now you only need to use:

#|eval: false
#|hide
from tsai.export import get_nb_name; nb_name = get_nb_name(locals())
from tsai.imports import create_scripts; create_scripts(nb_name)

I've tested the new approach both in Jupyter notebook and in VSCode and it worked well. It'd be good if you could test it as well.

@oguiza oguiza added the bug Something isn't working label Nov 9, 2022
@yangtzech
Copy link
Contributor Author

I have tested it both in VSCode and Jupyter Notebook. It works fine for me. Thanks!

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

No branches or pull requests

2 participants