Open rleyvasal opened 3 years ago
Thank you very much for the feedback!
The one line of code execution thing also does not work for me in Python chunk with my RStudio 1.39, but works for Python chunk when I upgrade to RStudio 1.41. So I guess this is also an RStudio thing.
I also notice that when I evaluate the Python chunk in RStudio 1.41, there is a reticulate::repl_python()
evaluated in the RStudio console. So I guess the functionality is provided by the repl_python
function in the package reticulate, which is also an R package authored by RStudio.
JuliaCall actually also provide function to mimic the julia repl, which is called julia_console()
, and it seems that the functionality and behavior of the two functions are quite in parallel.
So the only question that remains is to see how does this reticulate function hooks into RStudio notebook functionality.
This is the result when I search the repl_python
thing in the RStudio GitHub folder: https://github.com/rstudio/rstudio/search?q=repl_python,
and from the result, I notice that there is a file with Notebook in the name, which seems like what we are looking for: src/cpp/session/modules/rmarkdown/NotebookQueue.cpp,
If we see the History of the file: https://github.com/rstudio/rstudio/commits/ddcd7191ec89c4da00e77afae7e9f27e61e87c36/src/cpp/session/modules/rmarkdown/NotebookQueue.cpp, we notice that there is a commit especially for line by line execution of Python chunks: https://github.com/rstudio/rstudio/commit/fb9528de7cf8eb24b1a5da2f67ecf5d6dccc3c2e#diff-61a9196f91baf8a0235c650c7d7a1f870fb64c7e5db12c30d0181e4aaa3e9494, which corresponds to this pull request: https://github.com/rstudio/rstudio/pull/7813
Skim through the commit file linked above, it seems that the Python chunk mechanism is special cased and hard coded in RStudio's codebase.
So I'm not sure we can hook the JuliaCall console function into this. I can try to dig into this when I have more time.
I also see that the Python chunk pull request actually points to this issue: https://github.com/rstudio/rstudio/issues/6256. So maybe one way to get this done is to open an issue in the RStudio repo. If RStudio's people are interested, they can come up with some API for this. And I will try to hook the JuliaCall console function into the API.
Is there a way to execute one line of code at a time with Ctrl+Enter inside a chunk in an R notebook?
Every time I press Ctrl+Enter, all the code chunk executes at once.