question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow for nested Jupyter code cells

See original GitHub issue

It would be very useful to be able to nest Jupyter code calls based on indentation. This would make it possible to run for example just a part of a loop. For example:

# %% < -- top-level cell
j = 0
for i in range(10):
    # %% < -- sub cell 1
    print(i)
    # %% < -- sub cell 2
    for k in range(10):
        # %% < -- sub sub cell 1
        print(i * i)
    # %% < -- sub cell 3
    j += i
# %%  < -- another top-level cell
print(j)

in this scenario triggering the outer cell would run the entire loop, while the inner cell would only run the code inside the loop. This would be especially useful during data cleaning, where the processing step needs to be fine-tuned before being run on the whole dataset. If it makes the implementation more convenient, the inner cells could also be designated by adding additional percent characters for each nesting level, i.e.: # %% - top-level cell, # %%% - subcell, # %%%% - subsubcell etc.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
PALuczakcommented, Mar 12, 2021

While there is some slight overlap with #1471, the approach proposed here is significantly more flexible as it would allow for more incremental splits. Oftentimes, either the first or the last step in the loop is costly (i.e. getting/saving data) so being able to split it from the other steps would be quite useful.

Additionally, as mentioned in my previous comment, being able to specify blocks manually would be very useful in education as it would allow for creating step-by-step tutorials for students.

0reactions
amungercommented, Dec 7, 2022

thanks for the suggestion, unfortunately I don’t think there is enough interest for us to prioritize this feature

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can I nest cells in jupyter notebooks? - Stack Overflow
Is it possible to nest cells in a jupyter notebook? I would like to be able to collapse and expand sections of a...
Read more >
Nest code-cells inside of admonitions and block-level syntax ...
Can I nest a code-cell under a dropdown cell? i.e. ... WARNING: Found an unexpected `code-cell` directive. Either this file was not converted...
Read more >
Jupyter Notebook | Markdown | How to Add Nested List
In this tutorial we will learn how to add nested list for contents in Jupyter Notebook Markdown cell. Support If you find my...
Read more >
Markdown Cells — Jupyter Notebook 6.5.2 documentation
Markdown basics . You can make text italic or bold by surrounding a block of text with a single or double *...
Read more >
Markdown for Jupyter notebooks cheatsheet - IBM
You can use Markdown to format documentation you add to Markdown cells in your Jupyter notebook.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found