vscode-R icon indicating copy to clipboard operation
vscode-R copied to clipboard

Support VSCode Notebook API

Open renkun-ken opened this issue 5 years ago • 13 comments

We could explore the VSCode Notebook API and see if we could build something out from it.

renkun-ken avatar Jul 09 '20 22:07 renkun-ken

I would like to contribute to this extension and get r vscode working with the Jupyter extension notebook (ipynb). Basically, the Jupyter extension only deals with opening/saving ipynb files and r extension will be responsible for rich support, execution, language capabilities, etc.

Please advice if such a PR would be welcome and of there's any prior work that I can contribute to or pickup.

@Ikuyadeu @renkun-ken /cc

DonJayamanne avatar Mar 06 '21 04:03 DonJayamanne

@DonJayamanne Thank you for your suggestion. Of course, we welcome your PR.

Moving notebook functionality to the Jypyter extension helps simplify the role of this extension. As with Python extensions, we only need to add your plugin to the dependencies.

As an additional future, I hope we can also move the R markdown execution to that extension. (See # 465) https://code.visualstudio.com/docs/python/jupyter-support-py#_jupyter-code-cells

Ikuyadeu avatar Mar 07 '21 07:03 Ikuyadeu

Based on what I can tell, this extension doesn't really start any R kernel. It just sends R code to the terminal, is that correct. If that's the case, then I don't think we need to do anything special, as the existing Jupyter R kernel will work with the Jupyter extension in VS Code without any work.

I assumed this extension had its own R kernel (manually spinning up an R process & the like), however that doesn't seem to be the case.

DonJayamanne avatar Mar 09 '21 03:03 DonJayamanne

@DonJayamanne #394 is an experimental PR to implement the Notebook API. Only in this PR we implement a simple R kernel that evaluates code from notebook cells.

renkun-ken avatar Mar 09 '21 03:03 renkun-ken

Thanks.

I've had a look at the code & I'm struggling to see the need for spawning a kernel manually. Please coul dyou try the Jupyter extension and let me know whats missing. I'm suggesting this because I don't see the need to create a kernel & manually launch it as done in https://github.com/Ikuyadeu/vscode-R/pull/394. The only benefit is, a user doesn't need to install a kernel spec. I believe we can get around this by having the R extension register an R kernel in a known location (as done here https://github.com/DonJayamanne/typescript-notebook) & Jupyter extension will pick this and spawn the kernel & communicate with it using the Jupyter protocol.

Thanks. Please could you try using the Native Notebooks in Jupyter extension & let me know what is missing:

  • Install VSC Code Insiders (Not Stable)
  • Install Jupyter extension version 2021.4.xxxx
  • Ensure you have a R Jupyter kernel spec installed on your system
  • Open a Jupyter notebook and select an R kernel (bottom left we display the kernels)
  • Please try with different outputs

DonJayamanne avatar Mar 09 '21 06:03 DonJayamanne

Actually I take it back, I had a look at the extension and can see a lot of features that would not be available. I can start on some of the work, however I have zero R skills. Hopefully someone here can unblock me when i get stuck with anything. @renkun-ken I'll start working on #394 (creating a new branch from that).

DonJayamanne avatar Mar 13 '21 10:03 DonJayamanne

Should I submit changes to your branch, or should I submit changes to a whole new feature branch in this repo (e.g. notebook or feature/notebook)? I would like to make incremental changes as opposed to submitting a giant PR with 100 files changed. This way the changes can be reviewed incrementally and when everything is ready you can merge the notebook branch into the main branch. Happy to work anyway you suggest.

DonJayamanne avatar Mar 13 '21 10:03 DonJayamanne

@DonJayamanne I'm okay with either way, submitting to my branch or creating a new branch on your own, just go ahead with whatever you feel comfortable with.

I'm curious about one thing. If an extension uses the proposed API (e.g. notebook api), then does it require vscode-insider to use other stable features?

renkun-ken avatar Mar 14 '21 05:03 renkun-ken

hen does it require vscode-insider to use other stable features?

For now Proposed API can only be used when debugging or launching vscode with a special command. So, if the extension is released, then we cannot use proposed API, as it would cause the extension to fall over. The solution would be to put it behind a feature flag or the like & if someone did want to use it, they could launch VS Code with a special CLI arg.

my branch or creating a new branch on your own,

What ever i do will sit behind a feature flag, this way it can be tested in VS Code insiders and we can ship this if users wish to try it out. Let me first get something working, and we can discuss how and when you would like to ship this.

DonJayamanne avatar Mar 14 '21 10:03 DonJayamanne

@DonJayamanne This is very exciting! What is your ballpark plan for this sort of feature? Given the amazing progress you have done with the julia notebooks already, this would be the next big missing link for my university.

jlperla avatar Jul 05 '21 20:07 jlperla

I've been working on this for a while now, and hit a few issues. My plan is to get this done within the next week or two. But it will be very much in preview. Will try to merge back my changes into this PR sometime this week https://github.com/REditorSupport/vscode-R/pull/394

DonJayamanne avatar Jul 06 '21 21:07 DonJayamanne

Given that the notebook API has been in stable for some time now, are there any plans to add R support through this extension? The Python and Julia extensions seem to already support it (since I can select Python and Julia kernels), and it would be great if R was added to that list as well (after all, Jupyter means Julia, Python, and R 😄).

cbrnr avatar May 11 '22 11:05 cbrnr

Hi @DonJayamanne, sorry to bother, I was wondering how far you got into looking into this + if there was any help that I could provide or would be helpful? Last I remember was an issue with the portability of the R kernel

ElianHugh avatar Jun 18 '22 03:06 ElianHugh

This issue is stale because it has been open for 365 days with no activity.

github-actions[bot] avatar Jun 19 '23 01:06 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Jul 03 '23 02:07 github-actions[bot]

Unstale.

IRkernel should be adapted for this purpose, though. See https://github.com/IRkernel/IRkernel/issues/685.

benz0li avatar Sep 01 '23 05:09 benz0li