From cf90d07f891f3e8670d3aac661d0ca8b32b90840 Mon Sep 17 00:00:00 2001 From: Kevin Ushey Date: Tue, 23 Jan 2024 14:45:29 -0800 Subject: [PATCH 1/2] add helpers for detecting Workbench jobs --- DESCRIPTION | 2 +- NAMESPACE | 2 ++ R/remote.R | 18 ++++++++++++++++++ man/isJob.Rd | 12 ++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 52f16c0..8a08d52 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -16,7 +16,7 @@ URL: https://rstudio.github.io/rstudioapi/, https://github.com/rstudio/rstudioapi BugReports: https://github.com/rstudio/rstudioapi/issues Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Suggests: testthat, knitr, diff --git a/NAMESPACE b/NAMESPACE index ac5263a..8322171 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -56,7 +56,9 @@ export(insertText) export(is.document_position) export(is.document_range) export(isAvailable) +export(isBackgroundJob) export(isJob) +export(isWorkbenchJob) export(jobAdd) export(jobAddOutput) export(jobAddProgress) diff --git a/R/remote.R b/R/remote.R index 3439064..f0d8f64 100644 --- a/R/remote.R +++ b/R/remote.R @@ -5,6 +5,12 @@ #' These jobs are normally used for actions taken in the Jobs tab, as well #' as within the \R build pane. #' +#' `isWorkbenchJob()` is used to detect scripts which have been launched as +#' Workbench jobs, and is only available in RStudio Workbench 2024.04 or newer. +#' These jobs use the RStudio Launcher to run \R scripts on remote clusters, as +#' opposed to `isBackgroundJob()`, which is used to detect background jobs +#' which are run on the local machine. +#' #' This function is primarily intended to be used by package authors, who #' need to customize the behavior of their methods when run within an #' RStudio job. @@ -13,9 +19,21 @@ #' #' @export isJob <- function() { + isBackgroundJob() || isWorkbenchJob() +} + +#' @name isJob +#' @export +isBackgroundJob <- function() { !is.na(Sys.getenv("RSTUDIOAPI_IPC_REQUESTS_FILE", unset = NA)) } +#' @name isJob +#' @export +isWorkbenchJob <- function() { + identical(Sys.getenv("RSTUDIO_WORKBENCH_JOB"), "1") +} + callRemote <- function(call, frame) { # check for active request / response diff --git a/man/isJob.Rd b/man/isJob.Rd index 59eaf8c..f3d0b77 100644 --- a/man/isJob.Rd +++ b/man/isJob.Rd @@ -2,9 +2,15 @@ % Please edit documentation in R/remote.R \name{isJob} \alias{isJob} +\alias{isBackgroundJob} +\alias{isWorkbenchJob} \title{Detect RStudio Jobs} \usage{ isJob() + +isBackgroundJob() + +isWorkbenchJob() } \value{ Boolean; \code{TRUE} if this is an RStudio job. @@ -15,6 +21,12 @@ These jobs are normally used for actions taken in the Jobs tab, as well as within the \R build pane. } \details{ +\code{isWorkbenchJob()} is used to detect scripts which have been launched as +Workbench jobs, and is only available in RStudio Workbench 2024.04 or newer. +These jobs use the RStudio Launcher to run \R scripts on remote clusters, as +opposed to \code{isBackgroundJob()}, which is used to detect background jobs +which are run on the local machine. + This function is primarily intended to be used by package authors, who need to customize the behavior of their methods when run within an RStudio job. From 27cfb3e32811bc59704cac674f4ed78758f9c12b Mon Sep 17 00:00:00 2001 From: Kevin Ushey Date: Tue, 23 Jan 2024 14:45:38 -0800 Subject: [PATCH 2/2] rebuild docs --- man/launcherAvailable.Rd | 2 +- man/launcherConfig.Rd | 2 +- man/launcherContainer.Rd | 2 +- man/launcherControlJob.Rd | 2 +- man/launcherGetInfo.Rd | 2 +- man/launcherHostMount.Rd | 2 +- man/launcherNfsMount.Rd | 2 +- man/launcherPlacementConstraint.Rd | 2 +- man/launcherResourceLimit.Rd | 2 +- man/launcherSubmitJob.Rd | 2 +- man/launcherSubmitR.Rd | 2 +- man/setGhostText.Rd | 5 ++++- 12 files changed, 15 insertions(+), 12 deletions(-) diff --git a/man/launcherAvailable.Rd b/man/launcherAvailable.Rd index a69fe3c..83bfc9b 100644 --- a/man/launcherAvailable.Rd +++ b/man/launcherAvailable.Rd @@ -17,8 +17,8 @@ Other job-launcher functionality: \code{\link{launcherContainer}()}, \code{\link{launcherControlJob}()}, \code{\link{launcherGetInfo}()}, -\code{\link{launcherGetJobs}()}, \code{\link{launcherGetJob}()}, +\code{\link{launcherGetJobs}()}, \code{\link{launcherHostMount}()}, \code{\link{launcherNfsMount}()}, \code{\link{launcherPlacementConstraint}()}, diff --git a/man/launcherConfig.Rd b/man/launcherConfig.Rd index 2e08277..562361d 100644 --- a/man/launcherConfig.Rd +++ b/man/launcherConfig.Rd @@ -22,8 +22,8 @@ Other job-launcher functionality: \code{\link{launcherContainer}()}, \code{\link{launcherControlJob}()}, \code{\link{launcherGetInfo}()}, -\code{\link{launcherGetJobs}()}, \code{\link{launcherGetJob}()}, +\code{\link{launcherGetJobs}()}, \code{\link{launcherHostMount}()}, \code{\link{launcherNfsMount}()}, \code{\link{launcherPlacementConstraint}()}, diff --git a/man/launcherContainer.Rd b/man/launcherContainer.Rd index 83a9939..2d9f1c5 100644 --- a/man/launcherContainer.Rd +++ b/man/launcherContainer.Rd @@ -25,8 +25,8 @@ Other job-launcher functionality: \code{\link{launcherConfig}()}, \code{\link{launcherControlJob}()}, \code{\link{launcherGetInfo}()}, -\code{\link{launcherGetJobs}()}, \code{\link{launcherGetJob}()}, +\code{\link{launcherGetJobs}()}, \code{\link{launcherHostMount}()}, \code{\link{launcherNfsMount}()}, \code{\link{launcherPlacementConstraint}()}, diff --git a/man/launcherControlJob.Rd b/man/launcherControlJob.Rd index 08a9f71..2298775 100644 --- a/man/launcherControlJob.Rd +++ b/man/launcherControlJob.Rd @@ -26,8 +26,8 @@ Other job-launcher functionality: \code{\link{launcherConfig}()}, \code{\link{launcherContainer}()}, \code{\link{launcherGetInfo}()}, -\code{\link{launcherGetJobs}()}, \code{\link{launcherGetJob}()}, +\code{\link{launcherGetJobs}()}, \code{\link{launcherHostMount}()}, \code{\link{launcherNfsMount}()}, \code{\link{launcherPlacementConstraint}()}, diff --git a/man/launcherGetInfo.Rd b/man/launcherGetInfo.Rd index 326c15a..21289d5 100644 --- a/man/launcherGetInfo.Rd +++ b/man/launcherGetInfo.Rd @@ -16,8 +16,8 @@ Other job-launcher functionality: \code{\link{launcherConfig}()}, \code{\link{launcherContainer}()}, \code{\link{launcherControlJob}()}, -\code{\link{launcherGetJobs}()}, \code{\link{launcherGetJob}()}, +\code{\link{launcherGetJobs}()}, \code{\link{launcherHostMount}()}, \code{\link{launcherNfsMount}()}, \code{\link{launcherPlacementConstraint}()}, diff --git a/man/launcherHostMount.Rd b/man/launcherHostMount.Rd index eeaf797..91a04bf 100644 --- a/man/launcherHostMount.Rd +++ b/man/launcherHostMount.Rd @@ -25,8 +25,8 @@ Other job-launcher functionality: \code{\link{launcherContainer}()}, \code{\link{launcherControlJob}()}, \code{\link{launcherGetInfo}()}, -\code{\link{launcherGetJobs}()}, \code{\link{launcherGetJob}()}, +\code{\link{launcherGetJobs}()}, \code{\link{launcherNfsMount}()}, \code{\link{launcherPlacementConstraint}()}, \code{\link{launcherResourceLimit}()}, diff --git a/man/launcherNfsMount.Rd b/man/launcherNfsMount.Rd index 2ed8300..60d107a 100644 --- a/man/launcherNfsMount.Rd +++ b/man/launcherNfsMount.Rd @@ -28,8 +28,8 @@ Other job-launcher functionality: \code{\link{launcherContainer}()}, \code{\link{launcherControlJob}()}, \code{\link{launcherGetInfo}()}, -\code{\link{launcherGetJobs}()}, \code{\link{launcherGetJob}()}, +\code{\link{launcherGetJobs}()}, \code{\link{launcherHostMount}()}, \code{\link{launcherPlacementConstraint}()}, \code{\link{launcherResourceLimit}()}, diff --git a/man/launcherPlacementConstraint.Rd b/man/launcherPlacementConstraint.Rd index a51f386..5b5c5a7 100644 --- a/man/launcherPlacementConstraint.Rd +++ b/man/launcherPlacementConstraint.Rd @@ -24,8 +24,8 @@ Other job-launcher functionality: \code{\link{launcherContainer}()}, \code{\link{launcherControlJob}()}, \code{\link{launcherGetInfo}()}, -\code{\link{launcherGetJobs}()}, \code{\link{launcherGetJob}()}, +\code{\link{launcherGetJobs}()}, \code{\link{launcherHostMount}()}, \code{\link{launcherNfsMount}()}, \code{\link{launcherResourceLimit}()}, diff --git a/man/launcherResourceLimit.Rd b/man/launcherResourceLimit.Rd index 228fd19..93a80f8 100644 --- a/man/launcherResourceLimit.Rd +++ b/man/launcherResourceLimit.Rd @@ -26,8 +26,8 @@ Other job-launcher functionality: \code{\link{launcherContainer}()}, \code{\link{launcherControlJob}()}, \code{\link{launcherGetInfo}()}, -\code{\link{launcherGetJobs}()}, \code{\link{launcherGetJob}()}, +\code{\link{launcherGetJobs}()}, \code{\link{launcherHostMount}()}, \code{\link{launcherNfsMount}()}, \code{\link{launcherPlacementConstraint}()}, diff --git a/man/launcherSubmitJob.Rd b/man/launcherSubmitJob.Rd index d4f22bf..e346e38 100644 --- a/man/launcherSubmitJob.Rd +++ b/man/launcherSubmitJob.Rd @@ -101,8 +101,8 @@ Other job-launcher functionality: \code{\link{launcherContainer}()}, \code{\link{launcherControlJob}()}, \code{\link{launcherGetInfo}()}, -\code{\link{launcherGetJobs}()}, \code{\link{launcherGetJob}()}, +\code{\link{launcherGetJobs}()}, \code{\link{launcherHostMount}()}, \code{\link{launcherNfsMount}()}, \code{\link{launcherPlacementConstraint}()}, diff --git a/man/launcherSubmitR.Rd b/man/launcherSubmitR.Rd index 93e87ad..d1214c0 100644 --- a/man/launcherSubmitR.Rd +++ b/man/launcherSubmitR.Rd @@ -30,8 +30,8 @@ Other job-launcher functionality: \code{\link{launcherContainer}()}, \code{\link{launcherControlJob}()}, \code{\link{launcherGetInfo}()}, -\code{\link{launcherGetJobs}()}, \code{\link{launcherGetJob}()}, +\code{\link{launcherGetJobs}()}, \code{\link{launcherHostMount}()}, \code{\link{launcherNfsMount}()}, \code{\link{launcherPlacementConstraint}()}, diff --git a/man/setGhostText.Rd b/man/setGhostText.Rd index 5109271..9040193 100644 --- a/man/setGhostText.Rd +++ b/man/setGhostText.Rd @@ -10,5 +10,8 @@ setGhostText(text) \item{text}{The ghost text to set.} } \description{ -Set ghost text in the current document. +Set ghost text in the current document. The ghost text will be inserted at +the current cursor position. Ghost text can be inserted into the document +by pressing Tab, and will be automatically dismissed if the user navigates +the cursor away. }