laher/neorg-exec

Make cell execution aware of previous cells

Opened this issue · 3 comments

egolep commented

Maybe it is already possible or maybe it is not even planned or wanted, but I was wondering if there is a way to make different code cells aware of each other.
For example, if my first code cell is:

@code python
a = 3
@end

and the second is:

@code python
print(a)
@end

The second cell, when executed, actually prints a = 3 instead of returnin an error saying that a does not exist.

laher commented

Hi, great question.

I think the answer is 'yes, we should do that'. It sits nicely with 'literate programming'.

Orgmode has a concept of sessions. If you want code blocks to share an interpreter, you tag them with the same session name.

I think the pattern is a good one.

I'm not sure whether to offer it as a long-lived session or just to have 'execute these blocks' respect the session tags .. maybe as a first step, as I'm uncertain about leaving repls open indefinitely...

This request helps me to think more about design of the scheduler and workers, which I'm still working on. So, thanks!

It's early days but I'll let you know.

BTW there's an ongoing discussion about these topics on the neorg discord, if you're interested.

laher commented

This module already reuses an interpreter session, for jupyter notebooks. It's barebones but it's cool:
https://github.com/tamton-aquib/neorg-jupyter

egolep commented

This module already reuses an interpreter session, for jupyter notebooks. It's barebones but it's cool: https://github.com/tamton-aquib/neorg-jupyter

This looks promising, and it looks like it does what I need.
But I also understand the feeling of not wanting to leave a REPL constantly open all the time. Probably, the best thing would be to leave the choice to user (maybe using an entry in the document header): jupyter (or something like it) for iterative literate programming (like data science/machine learning stuff) and a more simple single cell environment for normal coding/projects. This way, users can access a uniform set of commands and UI, without having to configure and use two different plugins depending on the situation. But I don't know how hard it would be to develop something like this.

Thanks for pointing me to that other plugin. I'll be definitely joining neorg discord next week, at the moment I have a pretty strict working schedule.