Skip to content

Commit 0177629

Browse files
implement get_current_workflow_step
1 parent 33702bb commit 0177629

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ Suggests:
2929
Config/testthat/edition: 3
3030
Encoding: UTF-8
3131
Roxygen: list(markdown = TRUE)
32-
RoxygenNote: 7.1.2
32+
RoxygenNote: 7.2.1
3333
VignetteBuilder: knitr
3434
Language: en-US

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
export(add_workflow_step)
44
export(change_next_workflow_step)
55
export(create_workflow)
6+
export(get_current_workflow_step)
67
export(get_workflow_root)
78
export(helper_use_setup_lines)
89
export(helper_write_instructions)

R/workflow.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ get_workflow_root <- function(wf_summary = NULL) {
158158
#' \dontrun{
159159
#' # Instruct the workflow to run the step 3 after this one
160160
#' change_next_workflow_step(3)
161+
#'
162+
#' # Instruct the workflow to run the previous step after this one
163+
#' change_next_workflow_step(get_current_workflow_step() - 1)
161164
#' }
162165
#'
163166
#' @export
@@ -200,3 +203,12 @@ change_next_workflow_step <- function(next_step, sbatch_opts = NULL) {
200203
writeLines(as.character(next_step), next_step_file)
201204
invisible(next_step)
202205
}
206+
207+
#' Get the number of the currently running step of a workflow
208+
#'
209+
#' @return The `current_step` value
210+
#'
211+
#' @export
212+
get_current_workflow_step <- function() {
213+
Sys.getenv("SWF_CUR")
214+
}

inst/templates/step_tmpl_map.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if (swf__array_id == swf__array_max) {
1717
sbatch_opts <- list("array" = paste0(next_slice_beg, "-", next_slice_end))
1818

1919
slurmworkflow::change_next_workflow_step(
20-
next_step = Sys.getenv("SWF_CUR"),
20+
next_step = get_current_workflow_step(),
2121
sbatch_opts = sbatch_opts
2222
)
2323

man/change_next_workflow_step.Rd

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

0 commit comments

Comments
 (0)