-
Notifications
You must be signed in to change notification settings - Fork 725
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
Add a cell from another cell. #4406
Comments
Note this is not unrelated to #42 - I'd actually tried %load and found it didn't work either, but it would have only been a half solution to what I want to do. I'm looking at using LLM code generation to read a description from a text box, and then insert the code required in the colab. It's not that dissimilar to the "AI" button, but would be more programmatically controllable. |
Thanks for the feedback, we'll take that into consideration. In the meantime, two options that may work for you:
from google.colab import _frontend
_frontend.create_scratch_cell('print("your code here")') |
Thanks Colab Team! I'll try the scratch cell approach - that might be enough for now, although I'd love to be able to alternate text and code programmatically! |
Hi, Just some feedback here - the create_scratch_cell approach is pretty much what I needed, but it'd be really nice to have it have the option to make it a regular cell, and to have it append to the end of the current cells. Having the user review the code before pasting it in seems redundant from a security point of view, as you still need to manually run the cell (and the code is easier to read in that cell anyway). Or at least have a one time pop up that says "trust code to be pasted into an executable cell" for this colab. One other "bug" that I've found is that if you approve the popup too soon, the cell hangs, and you can't execute the scratch cell. Maybe that's a feature, I don't know, but it feels like a bug. |
I can't get this to repro for myself - I use the above snippet, execute, immediately click authorize and the cell adds and executes no problem. Am I doing it wrong? |
I agree with this. Would be great to have both options. The scratch-cells GUI seems unintuitive to me. |
Is your feature request related to a problem? Please describe.
I wish to programmatically add another cell into the notebook.
It's possible (unsupportedly) to read the entire notebook.
There's also the ability to take this and add cells to it, and dump it as an ipynb file, and then, I assume (I haven't tried this), read it as a colab notebook. However, this isn't the same.
Describe the solution you'd like
I'd like to be able to run a cell, and then have this code append a new cell (or insert at a specified position) to the colab notebook, and have it be saved, executed etc.
Describe alternatives you've considered
See above. I do not see any way of doing this in Colab's version of Jupyter notebooks. There's some hint that it might work in Jupyter land. https://stackoverflow.com/questions/13614783/programmatically-add-cells-to-an-ipython-notebook-for-report-generation
Additional context
Add any other context, screenshots or notebooks about the feature request here.
The text was updated successfully, but these errors were encountered: