nbdev icon indicating copy to clipboard operation
nbdev copied to clipboard

Document how to Ignore files/folder when running nbdev_test

Open ADubinA opened this issue 2 years ago • 10 comments

I have a folder of experiments that don't want to be tested when I run nbdev_test. Is there a way to ignore these files? I could add #|eval false to each line, in each notebook in that folder, but that's a lot of hassle. Having a Directive to set this default at the beginning of the file will also work.

ADubinA avatar Oct 25 '22 09:10 ADubinA

Hi @ADubinA !

There are several ways to skip entire notebooks, so they are not run with nbdev_test:

Directory Level

Name your directory should have a leading underscore. for example, a notebook located at /_notest/foo.ipnyb will not be tested

Notebook Level

You can use the front matter (raw cell) in a notebook like this:

---
skip_exec: true
---

You can also set this option in a markdown cell like this

# Your notebook title
> Your notebook description
- skip_exec: true

hamelsmu avatar Oct 25 '22 23:10 hamelsmu

By having the /_notest/ directory, it will also not be documented. Is there a way to have the directory documented, but not tested?

ADubinA avatar Oct 27 '22 11:10 ADubinA

@ADubinA you can add an empty .nodoc or .notest file to directories that you want to disable documentation or tests. For example using touch /your/dir/.notest.

seeM avatar Nov 08 '22 12:11 seeM

@seeM That's perfect! Thanks.

ADubinA avatar Nov 10 '22 08:11 ADubinA

The documentation also talks about using flags... but it is not documented how one can add tag to a cell (in nbdev1 it was # flag).

It looks like you can use nbdev_test --flags "slow fastai" to specify list of test flags (space separated) to run that are normally ignored; it is not explained if only those tests are run, or if it runs all tests that it would normally run in addition to tests with specified flags.

jnareb avatar May 07 '23 09:05 jnareb

@jnareb I just found you can use the #|eval: false directive to have nbdev_test skip cells.

aaronsgithub avatar Jun 09 '23 12:06 aaronsgithub

@jnareb I just found you can use the #|eval: false directive to have nbdev_test skip cells.

But #| eval: false also affects what is included in the documentation. And it doesn't allow to split tests into categories, like slow tests, or tests requiring some additional package to be installed.

jnareb avatar Jun 09 '23 13:06 jnareb

I see the code block and output in my documentation still with #|eval: false Would be nice to have test flag for cells though. I did notice that regardless of #|eval: false or not, %time ... lines are ignored in nbdev_preview.

evanlesmez avatar Jun 12 '23 17:06 evanlesmez

Is there a similar way of ignoring notebooks when generating docs?

pankaj-kvhld avatar Sep 07 '23 10:09 pankaj-kvhld

The documentation also talks about using flags... but it is not documented how one can add tag to a cell (in nbdev1 it was # flag).

I had the same question - looks like from the tests example that this is just an arbitrary directive, not sure why they picked a new name for it in this context! https://github.com/fastai/nbdev/blob/cad0ffcafd46a482dbe96617bba5102653c1eafa/tests/directives.ipynb

tmchartrand avatar Aug 06 '24 18:08 tmchartrand