diff --git a/README.md b/README.md index be51054..3566afd 100644 --- a/README.md +++ b/README.md @@ -15,26 +15,27 @@ It also makes parallelization relatively easy by allowing you to define each tar - [A UA HPC account](https://uarizona.atlassian.net/wiki/spaces/UAHPC/pages/75990889/Account+Creation) - Some familiarity with R, RStudio, the [`renv` pacakge](https://rstudio.github.io/renv/articles/renv.html), and the [`targets` package](https://books.ropensci.org/targets/) - A GitHub account +- Some familiarity with creating new RStudio projects from git— is a great place to get started ## To set-up: -To get this bare-bones pipeline running on the HPC: +### Overview -1. Click the “Use this template” button to create a repo under your own GitHub user name. -2. Modify the HPC group name in `_targets.R` and in `run.sh` to be your PI group. -3. [SSH into the UA HPC](https://uarizona.atlassian.net/wiki/spaces/UAHPC/pages/75990560/System+Access). -4. Clone this repo on the HPC, e.g. with `git clone https://github.com/your-user-name/targets-uahpc.git`. -5. Start an interactive session on the HPC, e.g. with `interactive -a ` . -6. Load R with `module load R`. -7. Launch R from within the `targets-uahpc/` directory with the `R` command -8. The [`renv` package](https://rstudio.github.io/renv/) should install itself. After it is done, you can install all necessary R packages by running `renv::restore()`. +Below are some step-by-step instructions to create a GitHub repo from this template, clone your repo to the HPC, install necessary R packages, and modify some user-specific configuration. +The set-up instructions take advantage of the RStudio GUI you can get with Open OnDemand, but you can use the command line if you're familiar with it. + +1. On this page, click the “Use this template” button to create a repo under your own GitHub user name. +2. Start a new Open OnDemand RStudio session [here](https://ood.hpc.arizona.edu/pun/sys/dashboard/batch_connect/sys/UAz_rstudio/session_contexts/new) (you likely only need 1 or 2 cores for this) +3. Once RStudio launches in your browser, create a new project from your GitHub repository (E.g. using the [RStudio new project wizard](https://happygitwithr.com/existing-github-first#rstudio-ide-1)). +4. The [`renv` package](https://rstudio.github.io/renv/) should install itself and prompt you to run `renv::restore()` to install all needed packages. +5. Modify the HPC group name in `_targets.R` and in `run.sh` to be your PI group. To modify the pipeline to run *your* code, you'll need to edit the list of targets in `_targets.R` as well as functions in the `R/` folder. See the [targets manual](https://books.ropensci.org/targets/) for more information. Note that use of the `renv` package for tracking dependencies isn't strictly necessary, but it does simplify package installation on the HPC. As you add R packages dependencies, you can use `targets::tar_renv()` to update the `_targets_packages.R` file and then `renv::snapshot()` to add them to `renv.lock`. -On the HPC, running `renv::restore()` not only installs any missing R packages, it also automatically detects system dependencies and lets you know if they aren't installed. +On the HPC, running `renv::restore()` not only installs any missing R packages, it also automatically detects system dependencies and lets you know if they aren't installed or loaded. ## Running the pipeline @@ -54,6 +55,9 @@ menu and navigate to the .Rproj file for this project. Then, from the console, run `targets::tar_make()` optionally with the `as_job = TRUE` argument to run it as a background process. You can occasionally check the progress of the pipeline in a variety of ways including `targets::tar_visnetwork()`. +> [!NOTE] +> Open OnDemand doesn't support loading modules, so if your pipeline uses any R packages with system dependencies, you may not be able to use this method. + ### From R SSH into the HPC, navigate to this project, and request an interactive session with `interactive -a -t ` where you replace the groupname with your group name, and the time stamp with how ever long you think the pipeline will take to run. diff --git a/_targets_packages.R b/_targets_packages.R index cb2b0d4..1ee6bf6 100644 --- a/_targets_packages.R +++ b/_targets_packages.R @@ -1,5 +1,5 @@ # Generated by targets::tar_renv(): do not edit by hand -library(bs4Dash) +library(bslib) library(crew) library(gt) library(markdown) diff --git a/renv.lock b/renv.lock index bd053df..15c4f35 100644 --- a/renv.lock +++ b/renv.lock @@ -9,13 +9,6 @@ ] }, "Packages": { - "BH": { - "Package": "BH", - "Version": "1.84.0-0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "a8235afbcd6316e6e91433ea47661013" - }, "Matrix": { "Package": "Matrix", "Version": "1.6-5", @@ -66,7 +59,7 @@ }, "V8": { "Package": "V8", - "Version": "4.4.2", + "Version": "5.0.1", "Source": "Repository", "Repository": "CRAN", "Requirements": [ @@ -75,29 +68,7 @@ "jsonlite", "utils" ], - "Hash": "ca98390ad1cef2a5a609597b49d3d042" - }, - "anytime": { - "Package": "anytime", - "Version": "0.3.9", - "Source": "Repository", - "Repository": "RSPM", - "Requirements": [ - "BH", - "R", - "Rcpp" - ], - "Hash": "74a64813f17b492da9c6afda6b128e3d" - }, - "askpass": { - "Package": "askpass", - "Version": "1.2.0", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "sys" - ], - "Hash": "cad6cf7f1d5f6e906700b9d3e718c796" + "Hash": "7f3867df00a91c63089beb85b9ef0208" }, "backports": { "Package": "backports", @@ -141,32 +112,14 @@ }, "bitops": { "Package": "bitops", - "Version": "1.0-7", + "Version": "1.0-8", "Source": "Repository", "Repository": "CRAN", - "Hash": "b7d8d8ee39869c18d8846a184dd8a1af" - }, - "bs4Dash": { - "Package": "bs4Dash", - "Version": "2.3.3", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "bslib", - "fresh", - "htmltools", - "httpuv", - "httr", - "jsonlite", - "lifecycle", - "shiny", - "waiter" - ], - "Hash": "9d3c4c0f9022322dbad0b3a68b86e81b" + "Hash": "da69e6b6f8feebec0827205aad3fdbd8" }, "bslib": { "Package": "bslib", - "Version": "0.7.0", + "Version": "0.8.0", "Source": "Repository", "Repository": "CRAN", "Requirements": [ @@ -184,18 +137,18 @@ "rlang", "sass" ], - "Hash": "8644cc53f43828f19133548195d7e59e" + "Hash": "b299c6741ca9746fb227debcb0f9fb6c" }, "cachem": { "Package": "cachem", - "Version": "1.0.8", + "Version": "1.1.0", "Source": "Repository", "Repository": "CRAN", "Requirements": [ "fastmap", "rlang" ], - "Hash": "c35768291560ce302c0a6589f92e837d" + "Hash": "cd9a672193789068eb5a2aad65a0dedf" }, "callr": { "Package": "callr", @@ -233,7 +186,7 @@ }, "colorspace": { "Package": "colorspace", - "Version": "2.1-0", + "Version": "2.1-1", "Source": "Repository", "Repository": "CRAN", "Requirements": [ @@ -243,7 +196,7 @@ "methods", "stats" ], - "Hash": "f20c47fd52fae58b4e377c37bb8c335b" + "Hash": "d954cb1c57e8d8b756165d7ba18aa55a" }, "commonmark": { "Package": "commonmark", @@ -264,7 +217,7 @@ }, "crayon": { "Package": "crayon", - "Version": "1.5.2", + "Version": "1.5.3", "Source": "Repository", "Repository": "CRAN", "Requirements": [ @@ -272,7 +225,7 @@ "methods", "utils" ], - "Hash": "e8a1e41acf02548751f45c718d55aa6a" + "Hash": "859d96e65ef198fd43e82b9628d593ef" }, "crew": { "Package": "crew", @@ -321,13 +274,13 @@ }, "curl": { "Package": "curl", - "Version": "5.2.1", + "Version": "5.2.3", "Source": "Repository", "Repository": "CRAN", "Requirements": [ "R" ], - "Hash": "411ca2c03b1ce5f548345d2fc2685f7a" + "Hash": "d91263322a58af798f6cf3b13fd56dde" }, "data.table": { "Package": "data.table", @@ -342,14 +295,14 @@ }, "digest": { "Package": "digest", - "Version": "0.6.35", + "Version": "0.6.37", "Source": "Repository", "Repository": "CRAN", "Requirements": [ "R", "utils" ], - "Hash": "698ece7ba5a4fa4559e3d537e7ec3d31" + "Hash": "33698c4b3127fc9f506654607fb73676" }, "dplyr": { "Package": "dplyr", @@ -374,27 +327,15 @@ ], "Hash": "fedd9d00c2944ff00a0e2696ccf048ec" }, - "ellipsis": { - "Package": "ellipsis", - "Version": "0.3.2", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "R", - "rlang" - ], - "Hash": "bb0eec2fe32e88d9e2836c2f73ea2077" - }, "evaluate": { "Package": "evaluate", - "Version": "0.24.0", + "Version": "1.0.0", "Source": "Repository", "Repository": "CRAN", "Requirements": [ - "R", - "methods" + "R" ], - "Hash": "a1066cbc05caee9a4bf6d90f194ff4da" + "Hash": "6b567375113ceb7d9f800de4dd42218e" }, "fansi": { "Package": "fansi", @@ -410,10 +351,10 @@ }, "farver": { "Package": "farver", - "Version": "2.1.1", + "Version": "2.1.2", "Source": "Repository", "Repository": "CRAN", - "Hash": "8106d78941f34855c440ddb946b8f7a5" + "Hash": "680887028577f3fa2a81e410ed0d6e42" }, "fastmap": { "Package": "fastmap", @@ -434,19 +375,6 @@ ], "Hash": "c2efdd5f0bcd1ea861c2d4e2a883a67d" }, - "fresh": { - "Package": "fresh", - "Version": "0.2.0", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "htmltools", - "rstudioapi", - "sass", - "shiny" - ], - "Hash": "fa54367040deb4537da49b7ac0ee5770" - }, "fs": { "Package": "fs", "Version": "1.6.4", @@ -481,18 +409,18 @@ }, "glue": { "Package": "glue", - "Version": "1.7.0", + "Version": "1.8.0", "Source": "Repository", "Repository": "CRAN", "Requirements": [ "R", "methods" ], - "Hash": "e0b3a53876554bd45879e596cdb10a52" + "Hash": "5899f1eaa825580172bb56c08266f37c" }, "gt": { "Package": "gt", - "Version": "0.10.1", + "Version": "0.11.0", "Source": "Repository", "Repository": "CRAN", "Requirements": [ @@ -518,7 +446,7 @@ "vctrs", "xml2" ], - "Hash": "03009c105dfae79460b8eb9d8cf791e4" + "Hash": "3470c2eb1123db6a2c54ec812de38284" }, "highr": { "Package": "highr", @@ -577,21 +505,6 @@ ], "Hash": "d55aa087c47a63ead0f6fc10f8fa1ee0" }, - "httr": { - "Package": "httr", - "Version": "1.4.7", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "R", - "R6", - "curl", - "jsonlite", - "mime", - "openssl" - ], - "Hash": "ac107251d9d9fd72f0ca8049988f1d7f" - }, "igraph": { "Package": "igraph", "Version": "2.0.3", @@ -627,13 +540,13 @@ }, "jsonlite": { "Package": "jsonlite", - "Version": "1.8.8", + "Version": "1.8.9", "Source": "Repository", "Repository": "CRAN", "Requirements": [ "methods" ], - "Hash": "e1b9c55281c5adc4dd113652d9e26768" + "Hash": "4e993b65c2c3ffbffce7bb3e2c6f832b" }, "juicyjuice": { "Package": "juicyjuice", @@ -723,7 +636,7 @@ }, "markdown": { "Package": "markdown", - "Version": "1.12", + "Version": "1.13", "Source": "Repository", "Repository": "CRAN", "Requirements": [ @@ -732,7 +645,7 @@ "utils", "xfun" ], - "Hash": "765cf53992401b3b6c297b69e1edb8bd" + "Hash": "074efab766a9d6360865ad39512f2a7e" }, "memoise": { "Package": "memoise", @@ -787,16 +700,6 @@ ], "Hash": "c601dd0bd16c37df416cab6c47512815" }, - "openssl": { - "Package": "openssl", - "Version": "2.2.0", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "askpass" - ], - "Hash": "2bcca3848e4734eb3b16103bc9aa4b8e" - }, "pillar": { "Package": "pillar", "Version": "1.9.0", @@ -867,14 +770,14 @@ }, "ps": { "Package": "ps", - "Version": "1.7.7", + "Version": "1.8.0", "Source": "Repository", "Repository": "CRAN", "Requirements": [ "R", "utils" ], - "Hash": "878b467580097e9c383acbb16adab57a" + "Hash": "4b9c8485b0c7eecdf0a9ba5132a45576" }, "rappdirs": { "Package": "rappdirs", @@ -888,13 +791,13 @@ }, "reactR": { "Package": "reactR", - "Version": "0.5.0", + "Version": "0.6.1", "Source": "Repository", "Repository": "CRAN", "Requirements": [ "htmltools" ], - "Hash": "c9014fd1a435b2d790dd506589cb24e5" + "Hash": "b8e3d93f508045812f47136c7c44c251" }, "reactable": { "Package": "reactable", @@ -913,13 +816,13 @@ }, "renv": { "Package": "renv", - "Version": "1.0.7", + "Version": "1.0.9", "Source": "Repository", "Repository": "CRAN", "Requirements": [ "utils" ], - "Hash": "397b7b2a265bc5a7a06852524dabae20" + "Hash": "ef233f0e9064fc88c898b340c9add5c2" }, "rlang": { "Package": "rlang", @@ -934,7 +837,7 @@ }, "rmarkdown": { "Package": "rmarkdown", - "Version": "2.26", + "Version": "2.28", "Source": "Repository", "Repository": "CRAN", "Requirements": [ @@ -953,14 +856,14 @@ "xfun", "yaml" ], - "Hash": "9b148e7f95d33aac01f31282d49e4f44" + "Hash": "062470668513dcda416927085ee9bdc7" }, "rstudioapi": { "Package": "rstudioapi", - "Version": "0.15.0", + "Version": "0.16.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "5564500e25cffad9e22244ced1379887" + "Hash": "96710351d642b70e8f02ddeb237c46a7" }, "sass": { "Package": "sass", @@ -1008,7 +911,7 @@ }, "shiny": { "Package": "shiny", - "Version": "1.8.0", + "Version": "1.9.1", "Source": "Repository", "Repository": "CRAN", "Requirements": [ @@ -1018,7 +921,6 @@ "cachem", "commonmark", "crayon", - "ellipsis", "fastmap", "fontawesome", "glue", @@ -1038,16 +940,15 @@ "withr", "xtable" ], - "Hash": "3a1f41807d648a908e3c7f0334bf85e6" + "Hash": "6a293995a66e12c48d13aa1f957d09c7" }, "shinyWidgets": { "Package": "shinyWidgets", - "Version": "0.8.1", + "Version": "0.8.7", "Source": "Repository", "Repository": "CRAN", "Requirements": [ "R", - "anytime", "bslib", "grDevices", "htmltools", @@ -1056,7 +957,7 @@ "sass", "shiny" ], - "Hash": "96bb249d21b7473dbeb0311702ef5288" + "Hash": "fd8239886f70daa85c36596214958451" }, "shinybusy": { "Package": "shinybusy", @@ -1081,16 +982,9 @@ ], "Hash": "5f5a7629f956619d519205ec475fe647" }, - "sys": { - "Package": "sys", - "Version": "3.4.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "3a1be13d68d47a8cd0bfd74739ca1555" - }, "tarchetypes": { "Package": "tarchetypes", - "Version": "0.9.0", + "Version": "0.10.0", "Source": "Repository", "Repository": "CRAN", "Requirements": [ @@ -1107,7 +1001,7 @@ "vctrs", "withr" ], - "Hash": "094a74cdaa048b727d52aebf4c80ed7a" + "Hash": "554afb784cbe615ae628dfed026cf77f" }, "targets": { "Package": "targets", @@ -1174,13 +1068,13 @@ }, "tinytex": { "Package": "tinytex", - "Version": "0.50", + "Version": "0.53", "Source": "Repository", "Repository": "CRAN", "Requirements": [ "xfun" ], - "Hash": "be7a76845222ad20adb761f462eed3ea" + "Hash": "9db859e8aabbb474293dde3097839420" }, "utf8": { "Package": "utf8", @@ -1234,18 +1128,6 @@ ], "Hash": "3e48b097e8d9a91ecced2ed4817a678d" }, - "waiter": { - "Package": "waiter", - "Version": "0.2.5", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "R6", - "htmltools", - "shiny" - ], - "Hash": "93e6b6c8ae3f81d4be77a0dc74e5cf5e" - }, "withr": { "Package": "withr", "Version": "3.0.1", diff --git a/renv/activate.R b/renv/activate.R index d13f993..c360bf2 100644 --- a/renv/activate.R +++ b/renv/activate.R @@ -2,7 +2,7 @@ local({ # the requested version of renv - version <- "1.0.7" + version <- "1.0.9" attr(version, "sha") <- NULL # the project directory @@ -98,6 +98,66 @@ local({ unloadNamespace("renv") # load bootstrap tools + ansify <- function(text) { + if (renv_ansify_enabled()) + renv_ansify_enhanced(text) + else + renv_ansify_default(text) + } + + renv_ansify_enabled <- function() { + + override <- Sys.getenv("RENV_ANSIFY_ENABLED", unset = NA) + if (!is.na(override)) + return(as.logical(override)) + + pane <- Sys.getenv("RSTUDIO_CHILD_PROCESS_PANE", unset = NA) + if (identical(pane, "build")) + return(FALSE) + + testthat <- Sys.getenv("TESTTHAT", unset = "false") + if (tolower(testthat) %in% "true") + return(FALSE) + + iderun <- Sys.getenv("R_CLI_HAS_HYPERLINK_IDE_RUN", unset = "false") + if (tolower(iderun) %in% "false") + return(FALSE) + + TRUE + + } + + renv_ansify_default <- function(text) { + text + } + + renv_ansify_enhanced <- function(text) { + + # R help links + pattern <- "`\\?(renv::(?:[^`])+)`" + replacement <- "`\033]8;;ide:help:\\1\a?\\1\033]8;;\a`" + text <- gsub(pattern, replacement, text, perl = TRUE) + + # runnable code + pattern <- "`(renv::(?:[^`])+)`" + replacement <- "`\033]8;;ide:run:\\1\a\\1\033]8;;\a`" + text <- gsub(pattern, replacement, text, perl = TRUE) + + # return ansified text + text + + } + + renv_ansify_init <- function() { + + envir <- renv_envir_self() + if (renv_ansify_enabled()) + assign("ansify", renv_ansify_enhanced, envir = envir) + else + assign("ansify", renv_ansify_default, envir = envir) + + } + `%||%` <- function(x, y) { if (is.null(x)) y else x } @@ -142,7 +202,10 @@ local({ # compute common indent indent <- regexpr("[^[:space:]]", lines) common <- min(setdiff(indent, -1L)) - leave - paste(substring(lines, common), collapse = "\n") + text <- paste(substring(lines, common), collapse = "\n") + + # substitute in ANSI links for executable renv code + ansify(text) } @@ -306,7 +369,11 @@ local({ ) if ("headers" %in% names(formals(utils::download.file))) - args$headers <- renv_bootstrap_download_custom_headers(url) + { + headers <- renv_bootstrap_download_custom_headers(url) + if (length(headers) && is.character(headers)) + args$headers <- headers + } do.call(utils::download.file, args) @@ -385,10 +452,22 @@ local({ for (type in types) { for (repos in renv_bootstrap_repos()) { + # build arguments for utils::available.packages() call + args <- list(type = type, repos = repos) + + # add custom headers if available -- note that + # utils::available.packages() will pass this to download.file() + if ("headers" %in% names(formals(utils::download.file))) + { + headers <- renv_bootstrap_download_custom_headers(url) + if (length(headers) && is.character(headers)) + args$headers <- headers + } + # retrieve package database db <- tryCatch( as.data.frame( - utils::available.packages(type = type, repos = repos), + do.call(utils::available.packages, args), stringsAsFactors = FALSE ), error = identity @@ -470,6 +549,14 @@ local({ } + renv_bootstrap_github_token <- function() { + for (envvar in c("GITHUB_TOKEN", "GITHUB_PAT", "GH_TOKEN")) { + envval <- Sys.getenv(envvar, unset = NA) + if (!is.na(envval)) + return(envval) + } + } + renv_bootstrap_download_github <- function(version) { enabled <- Sys.getenv("RENV_BOOTSTRAP_FROM_GITHUB", unset = "TRUE") @@ -477,16 +564,16 @@ local({ return(FALSE) # prepare download options - pat <- Sys.getenv("GITHUB_PAT") - if (nzchar(Sys.which("curl")) && nzchar(pat)) { + token <- renv_bootstrap_github_token() + if (nzchar(Sys.which("curl")) && nzchar(token)) { fmt <- "--location --fail --header \"Authorization: token %s\"" - extra <- sprintf(fmt, pat) + extra <- sprintf(fmt, token) saved <- options("download.file.method", "download.file.extra") options(download.file.method = "curl", download.file.extra = extra) on.exit(do.call(base::options, saved), add = TRUE) - } else if (nzchar(Sys.which("wget")) && nzchar(pat)) { + } else if (nzchar(Sys.which("wget")) && nzchar(token)) { fmt <- "--header=\"Authorization: token %s\"" - extra <- sprintf(fmt, pat) + extra <- sprintf(fmt, token) saved <- options("download.file.method", "download.file.extra") options(download.file.method = "wget", download.file.extra = extra) on.exit(do.call(base::options, saved), add = TRUE)