nbdev
nbdev copied to clipboard
Document how to Ignore files/folder when running nbdev_test
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.
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
By having the /_notest/ directory, it will also not be documented. Is there a way to have the directory documented, but not tested?
@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 That's perfect! Thanks.
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 I just found you can use the #|eval: false
directive to have nbdev_test
skip cells.
@jnareb I just found you can use the
#|eval: false
directive to havenbdev_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.
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
.
Is there a similar way of ignoring notebooks when generating docs?
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