Skip to content

Commit eb41c45

Browse files
committed
update hpc desc
1 parent cb661bc commit eb41c45

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

R/hpc.R

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ sbatch <- function(file) {
1414

1515
#' Prepare the R script and sh file to submit to HPC managed with SLURM
1616
#'
17-
#' adjust SLURM and conda configuration to your case
17+
#' The workflow is: you're working on a R script, and every lines from the
18+
#' top of the file (or from `first_line` parameter) to the current line (or the last
19+
# `last.line` parameter) is working fine. Now you want to
20+
#' run a full-blown model on the HPC. Then adjust the r script and run this
21+
#' function after the last line you want to send to the cluster (or outside the
22+
#' range from `first.line` to `last.line`.).
23+
#'
24+
#' Adjust SLURM and conda configuration to your case.
1825
#'
1926
#' @export
2027
slurm <- function(
@@ -31,12 +38,20 @@ slurm <- function(
3138
submit = FALSE,
3239
monitor = FALSE,
3340
user = "knguyen",
34-
iteration = 1) {
41+
iteration = 1,
42+
first.line = 1,
43+
last.line = Inf,
44+
shift.line = 2
45+
) {
46+
context <- rstudioapi::getSourceEditorContext()
3547
r.file <- paste0(working.dir, "/", r.file)
3648
sh.file <- paste0(working.dir, "/", sh.file)
37-
context <- rstudioapi::getSourceEditorContext()
3849
current_row <- context$selections[[1]]$range$start[[1]]
39-
writeLines(context$contents[1:(current_row - 2)], r.file)
50+
if (is.infinite(last.line)) {
51+
last.line <- current_row
52+
shift.line <- 0
53+
}
54+
writeLines(context$contents[first.line:(last.line - shift.line)], r.file)
4055
writeLines(
4156
c(
4257
"#!/bin/bash",

man/slurm.Rd

Lines changed: 12 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)