papermill
papermill copied to clipboard
How to run code blocks with particular tags only via papermill?
Is there a way to run a notebook with papermill, where we only want to execute code blocks with particular tags only.
For example: execute all code blocks via cli that have a tag "Data_Preprocessing" in input notebook and skip the rest of the code blocks
There isn't a built-in way. Generally it was considered a little too complex of an operation to manage in the open source space. You could implement a custom engine which picks which cells to execute, though I would argue your notebook might be trying to do too much if this is really required. Another way we approach this is to pass a flag into the parameter that the code respects, like dry-run
or debug-mode
. I use that pattern in a few places.
I agree this would be complicated and probably best avoided; but also incredibly useful and powerful if used appropriately. I have a case where I don't want to keep indenting all of my cells within an if some_condition:
block.
Updating the issue labels since using tags as decorators for a notebook cell to control execution is currently out of scope of papermill's core implementation. It would be an interesting extension to papermill to decorate a cell with a tag and control execution based on the decorator tag instead of the value parameterized within a cell.