Open ryanlovett opened 6 years ago
Also related to: https://github.com/jupyter/repo2docker/issues/24
Sounds like there's no concrete action point here.
I don't know whether this is the right place to ask this - but it really is a significant problem that, at the moment, there is no way to point an RStudio instance at a particular notebook. This means that the user ends up with an RStudio instance running in the root directory of the repository, and they have to manually navigate to find a notebook of interest, and then open it. Where should we ask to see how we can contribute to solving this for repo2docker / RStudio? Ping @stefanv because we're writing a book that needs this ...
I think the challenge is that the BinderHub developer community doesn't have a ton of experience with R workflows, particularly RStudio. I think that it would be most-welcome if somebody wants to figure out how to make this happen, I'm sure folks would be happy to review a PR.
I do think this one was closed a bit pre-maturely though. I agree w/ @manics that there wasn't a concrete action point here, but I think the answer to the question "Do we want BinderHub to launch an RStudio session that points to a specific notebook" is "yes", right? If that's the case, I'd be a fan of re-opening and then updating the top comment to reflect the current state of things, in case others are able to help
I don't think anything has changed since the initial report. There is rstudioapi::navigateToFile but I think you can only invoke rstudioapi functions from within RStudio itself. There is a remote function which looks like one can manually specify an IPC communication channel but I don't see where that is documented.
Thanks for this. I am thinking of seeing if we can get some help for this from the RStudio developers. Can you say any more what about what we need, and how we can test? I guess there needs to be some way of passing a message to the running RStudio server process to trigger the file open / display in RStudio. Let us say there is such an interface in RStudio server - from where would it be run, within the Binder infrastructure? Please forgive my ignorance.
I've reopened this since closing it seems to have encouraged people to take a look 😃.
The main change will have to be in https://github.com/jupyter/repo2docker. All BinderHub does is launch the container built by repo2docker in JupyterHub, and direct the user to a particular URL within that singleuser server.
In other words, can you build a Docker container (you can ignore repo2docker if you want for the purposes of investigation), run it, and open a URL http://<container-ip>:8888/prefix/rstudio/whatever/url/to/redirect
that opens your notebook in rstudio? Once you've done that we can look at adding that code/customisations to repo2docker.
The BinderHub change is just a UI change to automatically set the redirect URL, it won't interact with the container.
@matthew-brett jupyter notebook lets you specify a URL of the form /notebooks/filename.ipynb which tells it to open that notebook for you. jupyter lab lets you visit /lab/tree/filename.ipynb. This means that anyone can make a binder URL which just opens a given file at server start. RStudio's web service doesn't seem to have an API like either of these. It does have some sort of per-user or per-project session state but that isn't configurable by the URL or query string arguments.
Binder installs jupyter-rsession-proxy which is the handler for the /rstudio path. This means that if RStudio had an API to tell it to open up specific file, we could invoke that API from jupyter-rsession-proxy, and people could get at it through a jupyter-rsession-proxy API. rstudioapi has a function to open a file, however it seems to only work from inside RStudio itself. The rstudioapi::remote code suggests that if one knew how to seed the environment variables RSTUDIOAPI_IPC_REQUESTS_FILE
, RSTUDIOAPI_IPC_RESPONSE_FILE
, and RSTUDIOAPI_IPC_SHARED_SECRET
, then jupyter-rsession-proxy could invoke R outside of RStudio after having just launched it. So maybe the question for RStudio would be along the lines of, "is this true," and "what are these files and secret".
Maybe someone more familiar with R or RStudio's internals would have better insight.
@ryanlovett - would you consider posting that question about env vars and the rstudioapi::remote
code over at the linked RStudio thrread: https://github.com/rstudio/rstudio/issues/9925 , just for greater visibility? If not, I'm happy to do it.
@matthew-brett I just asked.
Thanks!
@paciorek mentioned in person that it'd be nice to be able to specify the path to R notebook files and have them open with RStudio.
To my knowledge, there's no rsession API call to open files. I'm creating this issue anyways just in case someone can find another way.
Long term this would be a function of #258. Short term, nbrsessionproxy would need to be altered.