@@ -14,7 +14,14 @@ sbatch <- function(file) {
14
14
15
15
# ' Prepare the R script and sh file to submit to HPC managed with SLURM
16
16
# '
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.
18
25
# '
19
26
# ' @export
20
27
slurm <- function (
@@ -31,12 +38,20 @@ slurm <- function(
31
38
submit = FALSE ,
32
39
monitor = FALSE ,
33
40
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()
35
47
r.file <- paste0(working.dir , " /" , r.file )
36
48
sh.file <- paste0(working.dir , " /" , sh.file )
37
- context <- rstudioapi :: getSourceEditorContext()
38
49
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 )
40
55
writeLines(
41
56
c(
42
57
" #!/bin/bash" ,
0 commit comments