Astrid
Astrid

Reputation: 1936

Execute specific cells in jupyter notebook before main one

Say I have a main cell in my notebook, lets call in main. I don't want to run a whole bunch of cells each time I use main, but I have to because main depends on the functions in them.

Hence, if main depends on say cells c1 and c2 is there a special magic command or something one can place in c1 and c2, that tells the notebook to run these before I run main. My notebooks typically contain hundreds of cells, so loading them all from the start is not really an option.

Thanks

PS. I am fully aware that I can take all of this out of notebooks and just import the whole lot. I specifically do not want to do that.

Upvotes: 4

Views: 4405

Answers (1)

Eugene Loy
Eugene Loy

Reputation: 12416

I don't think you can do this without extensions.

Have a look on init_cell extension. It allows you to mark some cells and run them on load\demand.

Here is the installation instructions.

Upvotes: 5

Related Questions