-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introducing rstudio addin for dso repro stage (#19)
* introducing rstudio addin for dso repro stage * changed docu based on warnings * updated stage addin; removed reload ... param * included dso repro stage with dependencies * pre-commit autofixes * styler * updated addin functions for better usage * pre-commit autofixes * updated addin; included repro function * pre-commit autofixes * fixed dvc.yaml error, removed show report * removed test_stage * pre-commit autofixes * changelog fix and dvc_yaml_path removal --------- Co-authored-by: DSchreyer <[email protected]>
- Loading branch information
Showing
9 changed files
with
197 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Package: dso | ||
Type: Package | ||
Title: dso R companion package | ||
Version: 0.5.1 | ||
Version: 0.6 | ||
Author: Daniel Schreyer<[email protected]>, | ||
Gregor Sturm<[email protected]>, | ||
Thomas Schwarzl<[email protected]> | ||
|
@@ -18,7 +18,8 @@ Imports: | |
here, | ||
stringr, | ||
methods, | ||
rlang | ||
rlang, | ||
rstudioapi (>= 0.11) | ||
RoxygenNote: 7.3.2 | ||
Suggests: | ||
testthat (>= 3.0.0) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#' Execute dso repro and display the result | ||
#' | ||
#' This function reproduces the current stage without its dependencies | ||
#' and displays the resulting report in the RStudio Viewer pane. | ||
#' | ||
#' @return None | ||
#' @export | ||
#' @importFrom glue glue | ||
#' @importFrom rstudioapi viewer | ||
#' @examples | ||
#' \dontrun{ | ||
#' dso_repro_stage_addin() | ||
#' } | ||
dso_repro_stage_addin <- function() { | ||
check_stage_here() | ||
|
||
repro(stage_here(), single_stage = TRUE) | ||
|
||
check_report() | ||
} | ||
|
||
#' Execute dso repro with dependencies and display the result | ||
#' | ||
#' This function reproduces the current stage along its dependencies | ||
#' and displays the resulting report in the RStudio Viewer pane. | ||
#' | ||
#' @return None | ||
#' @export | ||
#' @importFrom glue glue | ||
#' @importFrom rstudioapi viewer | ||
#' @examples | ||
#' \dontrun{ | ||
#' dso_repro_stage_w_dependencies_addin() | ||
#' } | ||
dso_repro_stage_w_dependencies_addin <- function() { | ||
check_stage_here() | ||
|
||
repro(stage_here(), single_stage = FALSE) | ||
|
||
check_report() | ||
} | ||
|
||
#' Get the current stage path | ||
#' | ||
#' This function retrieves the absolute path to the current stage. | ||
#' If the stage is not defined, it stops with an error message. | ||
#' | ||
#' @return The absolute path to the current stage. | ||
#' @noRd | ||
check_stage_here <- function() { | ||
if (length(stage_here()) == 0) { | ||
stop(glue::glue("stage_here() is not defined. Please read in your config file using read_params().")) | ||
} | ||
} | ||
|
||
#' Check and display the report | ||
#' | ||
#' This function checks for the generated report files in the stage directory | ||
#' | ||
#' @return None | ||
#' @noRd | ||
#' @importFrom glue glue | ||
#' @importFrom rstudioapi viewer | ||
check_report <- function() { | ||
report_files <- list.files(stage_here("report"), pattern = "\\.pdf$|\\.html$", full.names = TRUE) | ||
|
||
if (length(report_files) == 1) { | ||
report_file <- report_files[1] | ||
message(glue::glue("Report generated: {report_file}")) | ||
} else { | ||
stop(glue::glue("No report file or multiple report files were identified. Please check the report directory.")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#' @title Reproduce a dso stage | ||
#' @description | ||
#' Reproduce a dso stage with or without its dependencies. | ||
#' @details | ||
#' This function reproduces a stage specified by `stage_path`. | ||
#' If `single_stage` is set to `TRUE`, | ||
#' it reproduces the stage without its dependencies. | ||
#' Otherwise, it reproduces the current stage | ||
#' along with all its dependency stages. | ||
#' By default, the current stage will be reproduced. | ||
#' @param stage_path The path to a stage. Defaults to the current stage by using `stage_here()`. | ||
#' @param single_stage Logical flag indicating whether to reproduce only the current stage (`TRUE`) or the current stage with all dependencies (`FALSE`). Defaults to `FALSE`. | ||
#' @export | ||
repro <- function(stage_path = stage_here(), single_stage = F) { | ||
if (single_stage) { | ||
message(glue::glue("Reproducing the current stage with all its dependency stages.")) | ||
repro_cmd <- "repro" | ||
} else { | ||
message(glue::glue("Reproducing the current stage without dependencies.")) | ||
repro_cmd <- "repro -s" | ||
} | ||
result <- system2( | ||
DSO_EXEC, | ||
c(repro_cmd, shQuote(file.path(stage_path, "dvc.yaml"))) | ||
) | ||
|
||
if (result != 0) { | ||
stop(glue::glue("DSO {repro_cmd} failed with status: {result}")) | ||
} else { | ||
message("dso repro was executed successfully") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Name: dso repro stage | ||
Description: Execute dso repro -s | ||
Binding: dso_repro_stage_addin | ||
Interactive: false | ||
|
||
Name: dso repro stage with dependencies | ||
Description: Execute dso repro | ||
Binding: dso_repro_stage_w_dependencies_addin | ||
Interactive: false |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.