nbdev icon indicating copy to clipboard operation
nbdev copied to clipboard

mark all cells in a nb with a certain flag

Open deven-gqc opened this issue 2 years ago • 6 comments

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 ?

deven-gqc avatar Mar 27 '23 14:03 deven-gqc

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 avatar Mar 27 '23 15:03 hamelsmu

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?

hamelsmu avatar Mar 27 '23 15:03 hamelsmu

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.

deven-gqc avatar Mar 27 '23 15:03 deven-gqc

There seems to be multiple ways from the docs

Can you use the skip_file_glob argument?

hamelsmu avatar Mar 27 '23 15:03 hamelsmu

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 avatar Mar 27 '23 15:03 deven-gqc

@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.

deven-gqc avatar Jun 21 '23 14:06 deven-gqc