Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialization/Automatic Cells #7262

Open
Feuermurmel opened this issue Feb 15, 2024 · 2 comments
Open

Initialization/Automatic Cells #7262

Feuermurmel opened this issue Feb 15, 2024 · 2 comments

Comments

@Feuermurmel
Copy link

I'm a bit surprised that this feature hasn't been requested in this form already. Forgive me if I'm mistaken and there's already an open issue requesting the same feature.

I would find the following feature useful: One or more cells of a notebook can be marked as initialization cells or automatic cells. I'll call them automatic cells in the rest of this issue because the use case I have in mind goes beyond "initialization".

Whenever a cell in a notebook is run, all pending automatic cells before the cell to be run are also run. A pending cell is a cell has not been run after it has been modified. When the kernel restarts, all cells are considered pending.

The use case I have in mind is as follows: I can mostly group the cells in my notebooks into 3 categories:

  • Global initialization: These are imports and method calls to configure the libraries I'm using.
  • Definitions: These are assignments to global variables and method definitions.
  • The rest: The cells where I call methods to produce graphs and other output or where I write output to the file system.

I would mark the cells in the first two categories as automatic cells. This would solve the problem of editing definitions without running each modified cell. When editing function definitions and adding imports, I often jump between cells and make modifications in multiple places. Rememberig to run each modified cells at the end is hard to impossible for me.

@Feuermurmel Feuermurmel added enhancement status:Needs Triage Applied to issues that need triage labels Feb 15, 2024
@RRosio
Copy link
Collaborator

RRosio commented Feb 20, 2024

Hi @Feuermurmel thank you for opening this issue! There has been some discussion in the following JupyterLab issue:

@Feuermurmel
Copy link
Author

Thanks for the reply, @RRosio!

I think I stumbled on that issue before opening this issue. Initialization cells (like Mathematica implements them) and the jupyterlab_scenes plugin are mentioned. I think neither fulfill my use-case. What I call "Automatic Cells" are different in these regards:

  • They should be executed whenever they have been modified ("Initialization Cells" in Mathematica are only executed once).
  • They should only be executed when another cell is executed explicitly (so no automatic execution of cells when a notebook is opened, like some have suggested).
  • They should be executed automatically when a later cell is executed (in contrast to jupyterlab_scenes, which requires manually selecting a scene an executing it, IIUC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants