Skip to content

Commit

Permalink
Merge pull request #293 from rstudio/feature/workbench-job-detection
Browse files Browse the repository at this point in the history
workbench job detection
  • Loading branch information
kevinushey committed Jan 25, 2024
2 parents 7bcdf15 + 27cfb3e commit 9e3f80d
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions R/remote.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
12 changes: 12 additions & 0 deletions man/isJob.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/launcherAvailable.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/launcherConfig.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/launcherContainer.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/launcherControlJob.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/launcherGetInfo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/launcherHostMount.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/launcherNfsMount.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/launcherPlacementConstraint.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/launcherResourceLimit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/launcherSubmitJob.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/launcherSubmitR.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion man/setGhostText.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9e3f80d

Please sign in to comment.