fastai / nbdev

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

mark all cells in a nb with a certain flag #1321

Open deven-gqc opened 1 year ago

deven-gqc commented 1 year ago

hello, is there a way to mark all cells with a flag so that conditional testing can be used?

In nbdev1, we had # all_slow, for v2, I'm aware of skip_exec and skip_showdoc. A follow up question in that case would be can the values for these flags be changed when we use nbdev_test?

For now, I am manually adding test flags to each and every cell. Is there an alternative to this? @seeM @hamelsmu ?

hamelsmu commented 1 year ago

Deven, it should work the same you need to supply the flags you want to use to tst_flags in settings.ini like this.

Now those flags will be skipped. If you look at nbdev_test -h it will describe how you can run those flags. HTH.

If that works for you please close the issue!

hamelsmu commented 1 year ago

I am a bit confused by this -

For now, I am manually adding test flags to each and every cell. Is there an alternative to this?

Are you saying you want to apply the test flag to an entire notebook?

deven-gqc commented 1 year ago

Are you saying you want to apply the test flag to an entire notebook?

Yes

For instance, I have a nb which I only want to run in colab.

hamelsmu commented 1 year ago

There seems to be multiple ways from the docs

Can you use the skip_file_glob argument?

deven-gqc commented 1 year ago

Ah, that's a clever hack. In that case, I'll just have to rename my nbs accordingly.

My previous workflow was something like this,

nbdev_test --flags colab # to test nbs in developed and executed in colab
nbdev_test --flags local # to test nbs in developed and executed locally on my system

The reason why I liked this workflow was the addition of a single cell was enough to have conditional testing.

deven-gqc commented 1 year ago

@hamelsmu can we reopen this issue? I realized why having this feature was handy. Marking all cells with a certain flag still runs showdoc, without the all_slow flag, I would need to manually add the slow flag to all the cells.