fastai / nbdev

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

nbdev_install_hooks issue #1319

Closed radekosmulski closed 1 year ago

radekosmulski commented 1 year ago

I installed nbdev (but maybe I did it in some funky way? I might have created a minimum repo on github, committed to it and pulled -- otherwise I think nbdev wouldn't pick up on some info, thought this was the right way to go)

But the hooks were not installed? Maybe I need to install them manually?

So I installed them manually but still nothing happens! NBs are not getting cleaned, and my lib is not getting generated from notebooks. Not sure when that should happen -- upon commit, right?

Well, just wanted to report the issue as @hamelsmu advised me to do 🙂 And tagging @seeM as per his request.

seeM commented 1 year ago

Are you using VSCode? We don't have a way to automatically run hooks there. But as of yesterday they introduced a possible way to do this. You can try out pre-commit hooks: https://nbdev.fast.ai/tutorials/pre_commit.html, or run nbdev_clean manually.

Your lib gets generated when you run nbdev_export.

radekosmulski commented 1 year ago

I edit the notebooks in vscode but I do everything else (committing) from terminal in Ubuntu. I guess I am missing some hooks.

On Sat, 25 Mar 2023, 1:23 pm Wasim Lorgat, @.***> wrote:

Are you using VSCode? We don't have a way to automatically run hooks there. But as of yesterday they introduced a possible way to do this. You can try out pre-commit hooks: https://nbdev.fast.ai/tutorials/pre_commit.html, or run nbdev_clean manually.

Your lib gets generated when you run nbdev_export.

— Reply to this email directly, view it on GitHub https://github.com/fastai/nbdev/issues/1319#issuecomment-1483703405, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASU47TT44GGWVRTJGY52RLW5ZQLHANCNFSM6AAAAAAWHHW4D4 . You are receiving this because you authored the thread.Message ID: @.***>

radekosmulski commented 1 year ago

Mhmm so there is no hook that generates the lib for me? Makes sense I guess, so will need to do nbdev_export before I commit. Though I vaguely remember nbdev would complain in the past if NBs/code were out of sync.

On Sat, 25 Mar 2023, 2:01 pm Radek Osmulski, @.***> wrote:

I edit the notebooks in vscode but I do everything else (committing) from terminal in Ubuntu. I guess I am missing some hooks.

On Sat, 25 Mar 2023, 1:23 pm Wasim Lorgat, @.***> wrote:

Are you using VSCode? We don't have a way to automatically run hooks there. But as of yesterday they introduced a possible way to do this. You can try out pre-commit hooks: https://nbdev.fast.ai/tutorials/pre_commit.html, or run nbdev_clean manually.

Your lib gets generated when you run nbdev_export.

— Reply to this email directly, view it on GitHub https://github.com/fastai/nbdev/issues/1319#issuecomment-1483703405, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASU47TT44GGWVRTJGY52RLW5ZQLHANCNFSM6AAAAAAWHHW4D4 . You are receiving this because you authored the thread.Message ID: @.***>

seeM commented 1 year ago

Yep. My usual workflow is to manually run nbdev_prepare from the terminal before each commit. This is a shortcut which internally runs nbdev_export, nbdev_test, and nbdev_clean-- in that order.

I personally use the pre-commit hooks linked earlier so I don't need to remember to do anything, but it can take a bit of getting used to.

I realise that this isn't an obvious/seamless workflow though. Suggestions are always appreciated!

cocoaaa commented 1 year ago

Are you using VSCode? We don't have a way to automatically run hooks there. But as of yesterday they introduced a possible way to do this. You can try out pre-commit hooks: nbdev.fast.ai/tutorials/pre_commit.html, or run nbdev_clean manually.

Your lib gets generated when you run nbdev_export.

Hi @seeM , I'm following the steps in that link and have created a pre-commit config file, but upon running pre-commit install (at the root of my project) and testing on a file by running pre-commit run --files nbs/<my-filename>.ipynb I get the following errors : image

It seems like the hook-ids (nbdev_clean and nbdev_export ) are not valid anymore, as they do not come up in the supported hooks here either: https://pre-commit.com/hooks.html

Could you help how to resolve this error to install the two hooks properly? Thank you!

radekosmulski commented 1 year ago

No, I was doing commits and pushes from terminal.