papermill icon indicating copy to clipboard operation
papermill copied to clipboard

How to run code blocks with particular tags only via papermill?

Open aayush-jain18 opened this issue 5 years ago • 3 comments

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

aayush-jain18 avatar Jul 16 '19 18:07 aayush-jain18

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.

MSeal avatar Jul 16 '19 20:07 MSeal

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.

casperdcl avatar Jul 16 '19 22:07 casperdcl

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.

willingc avatar Aug 15 '19 19:08 willingc