Using RStudio API for Nested jobs

Hi, a quick question about nesting one job inside another:

  • Using rstudioapi::jobRunScript, we can source a script as a job running at the background
  • The job starts a new session, with a new global environment (whether we copy the parent global environment or not to it is irrelevant for this question)
  • If I try to call rsutdio::jobRunScript from within that script ran as a job, I'm getting an error that the session is not an RStudio session.

My question: is there a way to do have nested jobs, or at least more generally to just spawn a new session from a parent one and have it run in parallel --- ideally by defining the session of the parent job as an RStudio session?

Thanks!

With the daily builds of RStudio, alongside the development version of the rstudioapi package, it will be possible to call rstudioapi functions from child sessions.

Daily builds (currently v1.3) are available at https://dailies.rstudio.com, and the development version of rstudioapi can be installed with:

remotes::install_github("rstudio/rstudioapi")
2 Likes

Thanks much, I’ll give it a shot. I believe that the daily builds can live together with the official stable releases , right? My project strongly depends on R and RStudio so always want to keep a stable release version, while experimenting with the latest and greatest features of most recent builds.

Thanks again,
Will definitely give it a shot. The job support is really awesome, so much more convenient than opening another session and monitoring it separately...

That should be true on Windows + macOS. (Installing multiple copies of RStudio side-by-side on Linux is a bit more challenging, due to how applications are normally laid out on the filesystem after install)

Thank you. I installed the daily build and it seems to work fine (it's great that there is finally a real time spell checking by the way! was looking forward to it for a very long time).
I will check the nested job feature when I have a chance, but at the moment I am marking the response as "solution", hence closing the post/ticket. I don't think I can re-open it but I'll reference it any further communication on this topic.

Thanks again for your help and providing this awesome feature!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.