Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Oct 14 10:53
    renkun-ken commented #348
  • Oct 14 09:30

    renkun-ken on master

    Remove diagnostics of closed fi… Merge pull request #349 from re… (compare)

  • Oct 14 09:30
    renkun-ken closed #349
  • Oct 14 09:30
    renkun-ken closed #348
  • Oct 14 06:56
    bersbersbers commented #348
  • Oct 14 06:36
    renkun-ken commented #348
  • Oct 14 06:36
    renkun-ken commented #348
  • Oct 14 06:17
    bersbersbers commented #348
  • Oct 14 06:16
    bersbersbers commented #348
  • Oct 14 06:16
    bersbersbers commented #348
  • Oct 14 06:16
    bersbersbers commented #348
  • Oct 14 02:31
    renkun-ken opened #349
  • Oct 14 02:20
    renkun-ken commented #348
  • Oct 13 14:56
    bersbersbers commented #348
  • Oct 13 12:28
    bersbersbers opened #348
  • Oct 11 03:20
    randy3k commented #339
  • Oct 11 03:08
    renkun-ken commented #339
  • Oct 11 03:08
    renkun-ken commented #339
  • Oct 11 02:34
    randy3k commented #339
  • Oct 11 02:32

    renkun-ken on master

    Implement renameProvider Add test cases for rename Implement prepareRenameProvider and 7 more (compare)

Kun Ren
@renkun-ken
Great to be here
Randy Lai
@randy3k
Hi Kun, I have an idea of porting the code in vscode session watcher as an R package so other editors would be able to use the same protocol to display graphics etc. It would be very similar to irkernel of jupyter, but more R specific and runs on interactive R sessions.
I guess you might be interested in working on it
nvim-r actually has a similar client https://github.com/jalvesaq/Nvim-R/tree/master/R/nvimcom but it doesn't handle graphics (AFAIK)
Randy Lai
@randy3k
@andycraig, not sure if you will also be interested.
Kun Ren
@renkun-ken
It would be great if other editors could benefit from it and provide similar features.
So we are talking about a general way to let third-party editors to interact with R session to provide graphics, environment info, viewer, and browser requests.
Randy Lai
@randy3k
Exactly, we also want to consider the case of running R over ssh
in that case, we might need some kind of socket server
Kun Ren
@renkun-ken
In VSCode, running R over ssh is automatically handled by Remote Development features so we directly benefit from it without any special consideration. It would be tricky without it.
Randy Lai
@randy3k
I guess it is not always possible to install vscode remote development package on the ssh remote
in those cases, a simple socket server via ssh port forward may resolve the issue.
Andrew Craig
@andycraig
Hi both! Pretty much all the session watcher code is by Kun, but I am happy to be involved.
I was looking into nvimcom a while ago, before the session watcher existed. It would be nice to have this kind of session-watching functionality available to all editors.
Michał Krassowski
@krassowski
Hi, nice that you are on gitter now!
Kun Ren
@renkun-ken
@randy3k just notice the new sess project as the R Session Manager. Is it the package we are talking about recently? I’m quite interested in the underlying protocol since there’s a too much bit of hacking in the vscode R session watcher script.
Randy Lai
@randy3k
Yes, it is. I am still working on it. But so far, you could use websocket to connect to an R session.
On the server
session <- sess::start("127.0.0.1", 5000, debug = TRUE)
A client could connect to it using websocket.

in R, it could be

ws <- websocket::WebSocket$new("ws://127.0.0.1:5000/")
ws$send(jsonlite::toJSON(list(jsonrpc = "2", id = 1, method = "initialize"),  auto_unbox = TRUE))

other languages could use their own websocket library too. For example, websocket-clientmodule of python

there is also session$broadcast method for the server to send messages to the clients
Randy Lai
@randy3k
Ideally, the broadcast function will be triggered by addTaskCallback
Andrew Craig
@andycraig

Hi, currently VS Code can only communicate with the session watcher by sending code directly to the terminal. I was thinking that it would be nice if this could happen in the background. But I like the way that when you use R in VS Code you're 'just using the terminal', because it makes it easy to use radian, tmux etc. It's different from RStudio, where RStudio hosts the session in its own special terminal.

Summarising, my desiderata are:

  1. Be able to communicate with the R session in the background, without going via the terminal;
  2. Also be able to communicate with the R session via the terminal as usual.

I was playing around just now with https://github.com/corynissen/r-socket-server . First I start a socketConnection session:

source("server.R")
server() # On localhost port 6011

Then, in a separate window, I can do

nc localhost 6011
hello

and I get the output 'HELLO' back from the server. So this sort of achieves my aim of having an R session on a server that you can also communicate with via the terminal. Although in this setup I don't know how you'd use radian.

So! My questions are:

  1. Is this what randy3k/sess does/will do (in a much more featureful way)?
  2. Any thoughts on how you'd work radian into this?
Kun Ren
@renkun-ken
I think randy3k/sess is to provide a standard interface to interacting with an R session like the session watcher? The usage should be an R session starts a sess server just like the language server and it runs another fresh R session in background and editor communicates with sess, and sess communicates with the real R session in background, to get all features like session watcher, so that all editor could benefit from similar mechanism. It looks like something of the LSP for R session.
For VSCode, if we implement the Notebook API as suggested at Ikuyadeu/vscode-R#378, it seems that we need to send all commands to an R session running in background to make it work.
Andrew Craig
@andycraig
Thanks for that, I think I understand now. I was imagining the main R session being run ‘inside’ sess. But it sounds like starting R would then start sess (presumably via .Rprofile). So radian wouldn’t be any more complicated than normal R.
Andrew Craig
@andycraig
I came across this R implementation of nREPL. It's for interacting with a Clojure REPL using R, rather than for interacting with an R REPL with R, but it might be useful as a reference. https://github.com/vspinu/R-nREPL
nREPL is a Clojure network REPL, and also defines a network REPL protocol. I think it's similar to sess, but for Clojure. Might also be useful as a reference. https://github.com/nrepl/nrepl
Kun Ren
@renkun-ken
Looks interesting