From b9a25718011d80a3fdb14a62906aa226147c7a5c Mon Sep 17 00:00:00 2001 From: "zxBIB Schreyer,Daniel (TMCP Data Sc) EXTERNAL" Date: Fri, 25 Oct 2024 11:13:54 +0200 Subject: [PATCH 01/14] introducing rstudio addin for dso repro stage --- CHANGELOG.md | 6 ++++++ DESCRIPTION | 5 +++-- NAMESPACE | 1 + R/addin.R | 39 +++++++++++++++++++++++++++++++++++++++ inst/rstudio/addins.dcf | 4 ++++ 5 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 R/addin.R create mode 100644 inst/rstudio/addins.dcf diff --git a/CHANGELOG.md b/CHANGELOG.md index 821f52b..aacd6bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## v0.5.1 + +### New Features + +- Introduced the rstudio addin to `dso repro` the current stage + ## v0.5.0 ### New Features diff --git a/DESCRIPTION b/DESCRIPTION index ca2b966..e6e1b76 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: dso Type: Package Title: dso R companion package -Version: 0.5.0 +Version: 0.5.1 Author: Daniel Schreyer, Gregor Sturm, Thomas Schwarzl @@ -18,7 +18,8 @@ Imports: here, stringr, methods, - rlang + rlang, + rstudioapi (>= 0.11) RoxygenNote: 7.3.2 Suggests: testthat (>= 3.0.0) diff --git a/NAMESPACE b/NAMESPACE index c49e432..005d27f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -6,6 +6,7 @@ S3method(print,dsoParams) export(compile_config) export(create_stage) export(dsoParams) +export(dso_repro_addin) export(init) export(read_params) export(reload) diff --git a/R/addin.R b/R/addin.R new file mode 100644 index 0000000..26c7fca --- /dev/null +++ b/R/addin.R @@ -0,0 +1,39 @@ +#' Execute dso repro and display the result +#' @export +dso_repro_addin <- function() { + tryCatch({ + if (length(stage_here()) == 0) { + stop("stage_here() is not defined. Please read in your config file using read_params().") + } else { + stage_path <- stage_here() + } + + dvc_yaml_path <- file.path(stage_path, "dvc.yaml") + + tryCatch({ + message(glue::glue("Reproducing the current stage")) + result <- system2(DSO_EXEC, + c("repro -s", shQuote(dvc_yaml_path))) + if (result != 0) { + stop("System command failed with status: {result}") + } + message("System command executed successfully") + }, error = function(e) { + glue::glue("An error occurred while executing dso repro") + }) + + 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}")) + message(glue::glue("Displaying report file: {report_file}")) + # Check the file extension and display in the viewer + rstudioapi::viewer(report_file) + } else { + stop("No report file or multiple report files were identified. Please check the report directory.") + } + }, error = function(e) { + message(glue::glue("An error occurred: {e$message}")) + }) +} diff --git a/inst/rstudio/addins.dcf b/inst/rstudio/addins.dcf new file mode 100644 index 0000000..29e2bc4 --- /dev/null +++ b/inst/rstudio/addins.dcf @@ -0,0 +1,4 @@ +Name: dso repro stage +Description: Execute dso repro and display the result in the viewer +Binding: dso_repro_addin +Interactive: false From 266b8039807e26befe0d2f9582c8a6813ec3bae5 Mon Sep 17 00:00:00 2001 From: "zxBIB Schreyer,Daniel (TMCP Data Sc) EXTERNAL" Date: Fri, 25 Oct 2024 11:24:31 +0200 Subject: [PATCH 02/14] changed docu based on warnings --- R/addin.R | 10 ++++++++++ R/class-dsoParams.R | 4 ++-- man/dso_repro_addin.Rd | 20 ++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 man/dso_repro_addin.Rd diff --git a/R/addin.R b/R/addin.R index 26c7fca..f958abb 100644 --- a/R/addin.R +++ b/R/addin.R @@ -1,4 +1,14 @@ #' Execute dso repro and display the result +#' +#' This function runs the `dso repro` command on the specified `dvc.yaml` file +#' and displays the resulting report in the RStudio Viewer pane. +#' +#' @return None +#' @export +#' @examples +#' \dontrun{ +#' dso_repro_addin() +#' } #' @export dso_repro_addin <- function() { tryCatch({ diff --git a/R/class-dsoParams.R b/R/class-dsoParams.R index 5f27b5f..889ee9f 100644 --- a/R/class-dsoParams.R +++ b/R/class-dsoParams.R @@ -113,10 +113,10 @@ setMethod( #' @title reload function #' @description -#' -#' Generic for function reload +#' Generic function for reloading configurations. #' #' @param object dsoParams config object +#' @param ... Additional arguments passed to the method. #' @export setGeneric("reload", function(object,...) standardGeneric("reload")) diff --git a/man/dso_repro_addin.Rd b/man/dso_repro_addin.Rd new file mode 100644 index 0000000..4cf76ef --- /dev/null +++ b/man/dso_repro_addin.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/addin.R +\name{dso_repro_addin} +\alias{dso_repro_addin} +\title{Execute dso repro and display the result} +\usage{ +dso_repro_addin() +} +\value{ +None +} +\description{ +This function runs the `dso repro` command on the specified `dvc.yaml` file +and displays the resulting report in the RStudio Viewer pane. +} +\examples{ +\dontrun{ +dso_repro_addin() +} +} From 20be58c2416196d62ff496a4ff7624dbf73dd36e Mon Sep 17 00:00:00 2001 From: "zxBIB Schreyer,Daniel (TMCP Data Sc) EXTERNAL" Date: Fri, 25 Oct 2024 13:18:21 +0200 Subject: [PATCH 03/14] updated stage addin; removed reload ... param --- CHANGELOG.md | 4 ++++ NAMESPACE | 3 ++- R/addin.R | 6 ++++-- R/class-dsoParams.R | 3 +-- inst/rstudio/addins.dcf | 2 +- man/{dso_repro_addin.Rd => dso_repro_stage_addin.Rd} | 8 ++++---- man/reload.Rd | 4 ++-- 7 files changed, 18 insertions(+), 12 deletions(-) rename man/{dso_repro_addin.Rd => dso_repro_stage_addin.Rd} (76%) diff --git a/CHANGELOG.md b/CHANGELOG.md index aacd6bd..9f613f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Introduced the rstudio addin to `dso repro` the current stage +### Fixes + +- Removed ... in reload function + ## v0.5.0 ### New Features diff --git a/NAMESPACE b/NAMESPACE index 005d27f..17cdbf8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -6,7 +6,7 @@ S3method(print,dsoParams) export(compile_config) export(create_stage) export(dsoParams) -export(dso_repro_addin) +export(dso_repro_stage_addin) export(init) export(read_params) export(reload) @@ -22,6 +22,7 @@ importFrom(here,here) importFrom(here,i_am) importFrom(methods,show) importFrom(rlang,caller_env) +importFrom(rstudioapi,viewer) importFrom(stringr,coll) importFrom(stringr,str_match_all) importFrom(stringr,str_replace) diff --git a/R/addin.R b/R/addin.R index f958abb..9365fe3 100644 --- a/R/addin.R +++ b/R/addin.R @@ -5,12 +5,14 @@ #' #' @return None #' @export +#' @importFrom glue glue +#' @importFrom rstudioapi viewer #' @examples #' \dontrun{ -#' dso_repro_addin() +#' dso_repro_stage_addin() #' } #' @export -dso_repro_addin <- function() { +dso_repro_stage_addin <- function() { tryCatch({ if (length(stage_here()) == 0) { stop("stage_here() is not defined. Please read in your config file using read_params().") diff --git a/R/class-dsoParams.R b/R/class-dsoParams.R index 889ee9f..f64cd04 100644 --- a/R/class-dsoParams.R +++ b/R/class-dsoParams.R @@ -116,9 +116,8 @@ setMethod( #' Generic function for reloading configurations. #' #' @param object dsoParams config object -#' @param ... Additional arguments passed to the method. #' @export -setGeneric("reload", function(object,...) standardGeneric("reload")) +setGeneric("reload", function(object) standardGeneric("reload")) #' @title reload dso params diff --git a/inst/rstudio/addins.dcf b/inst/rstudio/addins.dcf index 29e2bc4..a970acf 100644 --- a/inst/rstudio/addins.dcf +++ b/inst/rstudio/addins.dcf @@ -1,4 +1,4 @@ Name: dso repro stage Description: Execute dso repro and display the result in the viewer -Binding: dso_repro_addin +Binding: dso_repro_stage_addin Interactive: false diff --git a/man/dso_repro_addin.Rd b/man/dso_repro_stage_addin.Rd similarity index 76% rename from man/dso_repro_addin.Rd rename to man/dso_repro_stage_addin.Rd index 4cf76ef..062a14e 100644 --- a/man/dso_repro_addin.Rd +++ b/man/dso_repro_stage_addin.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/addin.R -\name{dso_repro_addin} -\alias{dso_repro_addin} +\name{dso_repro_stage_addin} +\alias{dso_repro_stage_addin} \title{Execute dso repro and display the result} \usage{ -dso_repro_addin() +dso_repro_stage_addin() } \value{ None @@ -15,6 +15,6 @@ and displays the resulting report in the RStudio Viewer pane. } \examples{ \dontrun{ -dso_repro_addin() +dso_repro_stage_addin() } } diff --git a/man/reload.Rd b/man/reload.Rd index 7fd4b29..2e63c58 100644 --- a/man/reload.Rd +++ b/man/reload.Rd @@ -4,11 +4,11 @@ \alias{reload} \title{reload function} \usage{ -reload(object, ...) +reload(object) } \arguments{ \item{object}{dsoParams config object} } \description{ -Generic for function reload +Generic function for reloading configurations. } From 941bc91b3af5049fb9baf64f7ed5e9187d22b4b5 Mon Sep 17 00:00:00 2001 From: "zxBIB Schreyer,Daniel (TMCP Data Sc) EXTERNAL" Date: Mon, 4 Nov 2024 10:48:53 +0100 Subject: [PATCH 04/14] included dso repro stage with dependencies --- CHANGELOG.md | 3 ++- DESCRIPTION | 2 +- R/addin.R | 44 ++++++++++++++++++++++++++++++++++++++--- inst/rstudio/addins.dcf | 7 ++++++- 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f613f7..e193162 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## v0.5.1 +## v0.6 ### New Features - Introduced the rstudio addin to `dso repro` the current stage +- Introduced the rstudio addin to `dso repro` the current stage with dependencies ### Fixes diff --git a/DESCRIPTION b/DESCRIPTION index e6e1b76..1cf4126 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: dso Type: Package Title: dso R companion package -Version: 0.5.1 +Version: 0.6 Author: Daniel Schreyer, Gregor Sturm, Thomas Schwarzl diff --git a/R/addin.R b/R/addin.R index 9365fe3..06bd9b8 100644 --- a/R/addin.R +++ b/R/addin.R @@ -15,7 +15,7 @@ dso_repro_stage_addin <- function() { tryCatch({ if (length(stage_here()) == 0) { - stop("stage_here() is not defined. Please read in your config file using read_params().") + stop(glue::glue("stage_here() is not defined. Please read in your config file using read_params().")) } else { stage_path <- stage_here() } @@ -27,7 +27,7 @@ dso_repro_stage_addin <- function() { result <- system2(DSO_EXEC, c("repro -s", shQuote(dvc_yaml_path))) if (result != 0) { - stop("System command failed with status: {result}") + stop(glue::glue("System command failed with status: {result}")) } message("System command executed successfully") }, error = function(e) { @@ -43,7 +43,45 @@ dso_repro_stage_addin <- function() { # Check the file extension and display in the viewer rstudioapi::viewer(report_file) } else { - stop("No report file or multiple report files were identified. Please check the report directory.") + stop(glue::glue("No report file or multiple report files were identified. Please check the report directory.")) + } + }, error = function(e) { + message(glue::glue("An error occurred: {e$message}")) + }) +} + +dso_repro_stage_w_dependencies_addin <- function() { + tryCatch({ + if (length(stage_here()) == 0) { + stop(glue::glue("stage_here() is not defined. Please read in your config file using read_params().")) + } else { + stage_path <- stage_here() + } + + dvc_yaml_path <- file.path(stage_path, "dvc.yaml") + + tryCatch({ + message(glue::glue("Reproducing the current stage with all its dependency stages.")) + result <- system2(DSO_EXEC, + c("repro", shQuote(dvc_yaml_path))) + if (result != 0) { + stop(glue::glue("System command failed with status: {result}")) + } + message("System command executed successfully") + }, error = function(e) { + glue::glue("An error occurred while executing dso repro") + }) + + 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}")) + message(glue::glue("Displaying report file: {report_file}")) + # Check the file extension and display in the viewer + rstudioapi::viewer(report_file) + } else { + stop(glue::glue("No report file or multiple report files were identified. Please check the report directory.")) } }, error = function(e) { message(glue::glue("An error occurred: {e$message}")) diff --git a/inst/rstudio/addins.dcf b/inst/rstudio/addins.dcf index a970acf..3e0a82f 100644 --- a/inst/rstudio/addins.dcf +++ b/inst/rstudio/addins.dcf @@ -1,4 +1,9 @@ Name: dso repro stage -Description: Execute dso repro and display the result in the viewer +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 From 8fc0020850789882c2bc5ff6dcd97ef8cd0fca92 Mon Sep 17 00:00:00 2001 From: DSchreyer Date: Mon, 4 Nov 2024 09:52:15 +0000 Subject: [PATCH 05/14] pre-commit autofixes --- R/addin.R | 132 +++++++++++++++++++++++++++--------------------- R/read_params.R | 59 ++++++++++++---------- 2 files changed, 107 insertions(+), 84 deletions(-) diff --git a/R/addin.R b/R/addin.R index 06bd9b8..db489d6 100644 --- a/R/addin.R +++ b/R/addin.R @@ -13,77 +13,93 @@ #' } #' @export dso_repro_stage_addin <- function() { - tryCatch({ - if (length(stage_here()) == 0) { - stop(glue::glue("stage_here() is not defined. Please read in your config file using read_params().")) - } else { - stage_path <- stage_here() - } + tryCatch( + { + if (length(stage_here()) == 0) { + stop(glue::glue("stage_here() is not defined. Please read in your config file using read_params().")) + } else { + stage_path <- stage_here() + } - dvc_yaml_path <- file.path(stage_path, "dvc.yaml") + dvc_yaml_path <- file.path(stage_path, "dvc.yaml") - tryCatch({ - message(glue::glue("Reproducing the current stage")) - result <- system2(DSO_EXEC, - c("repro -s", shQuote(dvc_yaml_path))) - if (result != 0) { - stop(glue::glue("System command failed with status: {result}")) - } - message("System command executed successfully") - }, error = function(e) { - glue::glue("An error occurred while executing dso repro") - }) + tryCatch( + { + message(glue::glue("Reproducing the current stage")) + result <- system2( + DSO_EXEC, + c("repro -s", shQuote(dvc_yaml_path)) + ) + if (result != 0) { + stop(glue::glue("System command failed with status: {result}")) + } + message("System command executed successfully") + }, + error = function(e) { + glue::glue("An error occurred while executing dso repro") + } + ) - report_files <- list.files(stage_here("report"), pattern = "\\.pdf$|\\.html$", full.names = TRUE) + 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}")) - message(glue::glue("Displaying report file: {report_file}")) - # Check the file extension and display in the viewer - rstudioapi::viewer(report_file) + if (length(report_files) == 1) { + report_file <- report_files[1] + message(glue::glue("Report generated: {report_file}")) + message(glue::glue("Displaying report file: {report_file}")) + # Check the file extension and display in the viewer + rstudioapi::viewer(report_file) } else { - stop(glue::glue("No report file or multiple report files were identified. Please check the report directory.")) + stop(glue::glue("No report file or multiple report files were identified. Please check the report directory.")) + } + }, + error = function(e) { + message(glue::glue("An error occurred: {e$message}")) } - }, error = function(e) { - message(glue::glue("An error occurred: {e$message}")) - }) + ) } dso_repro_stage_w_dependencies_addin <- function() { - tryCatch({ - if (length(stage_here()) == 0) { - stop(glue::glue("stage_here() is not defined. Please read in your config file using read_params().")) - } else { - stage_path <- stage_here() - } + tryCatch( + { + if (length(stage_here()) == 0) { + stop(glue::glue("stage_here() is not defined. Please read in your config file using read_params().")) + } else { + stage_path <- stage_here() + } - dvc_yaml_path <- file.path(stage_path, "dvc.yaml") + dvc_yaml_path <- file.path(stage_path, "dvc.yaml") - tryCatch({ - message(glue::glue("Reproducing the current stage with all its dependency stages.")) - result <- system2(DSO_EXEC, - c("repro", shQuote(dvc_yaml_path))) - if (result != 0) { - stop(glue::glue("System command failed with status: {result}")) - } - message("System command executed successfully") - }, error = function(e) { - glue::glue("An error occurred while executing dso repro") - }) + tryCatch( + { + message(glue::glue("Reproducing the current stage with all its dependency stages.")) + result <- system2( + DSO_EXEC, + c("repro", shQuote(dvc_yaml_path)) + ) + if (result != 0) { + stop(glue::glue("System command failed with status: {result}")) + } + message("System command executed successfully") + }, + error = function(e) { + glue::glue("An error occurred while executing dso repro") + } + ) - report_files <- list.files(stage_here("report"), pattern = "\\.pdf$|\\.html$", full.names = TRUE) + 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}")) - message(glue::glue("Displaying report file: {report_file}")) - # Check the file extension and display in the viewer - rstudioapi::viewer(report_file) + if (length(report_files) == 1) { + report_file <- report_files[1] + message(glue::glue("Report generated: {report_file}")) + message(glue::glue("Displaying report file: {report_file}")) + # Check the file extension and display in the viewer + rstudioapi::viewer(report_file) } else { - stop(glue::glue("No report file or multiple report files were identified. Please check the report directory.")) + stop(glue::glue("No report file or multiple report files were identified. Please check the report directory.")) + } + }, + error = function(e) { + message(glue::glue("An error occurred: {e$message}")) } - }, error = function(e) { - message(glue::glue("An error occurred: {e$message}")) - }) + ) } diff --git a/R/read_params.R b/R/read_params.R index d446784..ee7d34d 100644 --- a/R/read_params.R +++ b/R/read_params.R @@ -14,23 +14,23 @@ #' @importFrom yaml read_yaml #' @export read_params <- function(stage_path = NULL, return_list = FALSE) { - if(!is.logical(return_list)) + if (!is.logical(return_list)) { stop("Argument return_list needs to be logical.") + } # if stage_path argument was path, set stage from that argument - if(!is.null(stage_path)) { - + if (!is.null(stage_path)) { # first check for input validity - if(!is.character(stage_path)) + if (!is.character(stage_path)) { stop("stage_path argument must be a character string or NULL to reload the config") + } # then set stage path stage_path <- set_stage(stage_path) - } else { # stage_path argument is null, therefore not set. Check if stage_dir # has been already set in config_env, if yes reload, if not, stop with error - if(is.null(config_env$stage_dir)) { + if (is.null(config_env$stage_dir)) { stop("stage_path argument missing.") } else { cat(paste("reloading from already set stage_path:", config_env$stage_dir)) @@ -41,30 +41,37 @@ read_params <- function(stage_path = NULL, return_list = FALSE) { tmp_config_file <- tempfile() tmp_err_file <- tempfile() - tryCatch({ - output <- system2(DSO_EXEC, - c("get-config", - shQuote(stage_path)), - stdout = tmp_config_file, - stderr = tmp_err_file) + tryCatch( + { + output <- system2(DSO_EXEC, + c( + "get-config", + shQuote(stage_path) + ), + stdout = tmp_config_file, + stderr = tmp_err_file + ) - stderror <- readLines(tmp_err_file) + stderror <- readLines(tmp_err_file) - # error handling, display only rows after first error - # for better readability - if (output != 0 || any(grepl("ERROR", stderror))) { - stop( - paste("An error occurred when executing dso get-config:\n", - paste( - stderror[which(grepl("ERROR", stderror)) : length(stderror)], - collapse = "\n" - ) + # error handling, display only rows after first error + # for better readability + if (output != 0 || any(grepl("ERROR", stderror))) { + stop( + paste( + "An error occurred when executing dso get-config:\n", + paste( + stderror[which(grepl("ERROR", stderror)):length(stderror)], + collapse = "\n" + ) + ) ) - ) + } + }, + error = function(e) { + stop("An error occurred when executing dso get-config: ", e$message) } - }, error = function(e) { - stop("An error occurred when executing dso get-config: ", e$message) - }) + ) yaml <- read_yaml(tmp_config_file) unlink(tmp_config_file) From da67e1afdd6b4098902ec8f316d9707f8a285dce Mon Sep 17 00:00:00 2001 From: "zxBIB Schreyer,Daniel (TMCP Data Sc) EXTERNAL" Date: Mon, 4 Nov 2024 11:29:15 +0100 Subject: [PATCH 06/14] styler --- R/addin.R | 132 +++++++++++++++++++++++++++--------------------- R/read_params.R | 59 ++++++++++++---------- 2 files changed, 107 insertions(+), 84 deletions(-) diff --git a/R/addin.R b/R/addin.R index 06bd9b8..db489d6 100644 --- a/R/addin.R +++ b/R/addin.R @@ -13,77 +13,93 @@ #' } #' @export dso_repro_stage_addin <- function() { - tryCatch({ - if (length(stage_here()) == 0) { - stop(glue::glue("stage_here() is not defined. Please read in your config file using read_params().")) - } else { - stage_path <- stage_here() - } + tryCatch( + { + if (length(stage_here()) == 0) { + stop(glue::glue("stage_here() is not defined. Please read in your config file using read_params().")) + } else { + stage_path <- stage_here() + } - dvc_yaml_path <- file.path(stage_path, "dvc.yaml") + dvc_yaml_path <- file.path(stage_path, "dvc.yaml") - tryCatch({ - message(glue::glue("Reproducing the current stage")) - result <- system2(DSO_EXEC, - c("repro -s", shQuote(dvc_yaml_path))) - if (result != 0) { - stop(glue::glue("System command failed with status: {result}")) - } - message("System command executed successfully") - }, error = function(e) { - glue::glue("An error occurred while executing dso repro") - }) + tryCatch( + { + message(glue::glue("Reproducing the current stage")) + result <- system2( + DSO_EXEC, + c("repro -s", shQuote(dvc_yaml_path)) + ) + if (result != 0) { + stop(glue::glue("System command failed with status: {result}")) + } + message("System command executed successfully") + }, + error = function(e) { + glue::glue("An error occurred while executing dso repro") + } + ) - report_files <- list.files(stage_here("report"), pattern = "\\.pdf$|\\.html$", full.names = TRUE) + 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}")) - message(glue::glue("Displaying report file: {report_file}")) - # Check the file extension and display in the viewer - rstudioapi::viewer(report_file) + if (length(report_files) == 1) { + report_file <- report_files[1] + message(glue::glue("Report generated: {report_file}")) + message(glue::glue("Displaying report file: {report_file}")) + # Check the file extension and display in the viewer + rstudioapi::viewer(report_file) } else { - stop(glue::glue("No report file or multiple report files were identified. Please check the report directory.")) + stop(glue::glue("No report file or multiple report files were identified. Please check the report directory.")) + } + }, + error = function(e) { + message(glue::glue("An error occurred: {e$message}")) } - }, error = function(e) { - message(glue::glue("An error occurred: {e$message}")) - }) + ) } dso_repro_stage_w_dependencies_addin <- function() { - tryCatch({ - if (length(stage_here()) == 0) { - stop(glue::glue("stage_here() is not defined. Please read in your config file using read_params().")) - } else { - stage_path <- stage_here() - } + tryCatch( + { + if (length(stage_here()) == 0) { + stop(glue::glue("stage_here() is not defined. Please read in your config file using read_params().")) + } else { + stage_path <- stage_here() + } - dvc_yaml_path <- file.path(stage_path, "dvc.yaml") + dvc_yaml_path <- file.path(stage_path, "dvc.yaml") - tryCatch({ - message(glue::glue("Reproducing the current stage with all its dependency stages.")) - result <- system2(DSO_EXEC, - c("repro", shQuote(dvc_yaml_path))) - if (result != 0) { - stop(glue::glue("System command failed with status: {result}")) - } - message("System command executed successfully") - }, error = function(e) { - glue::glue("An error occurred while executing dso repro") - }) + tryCatch( + { + message(glue::glue("Reproducing the current stage with all its dependency stages.")) + result <- system2( + DSO_EXEC, + c("repro", shQuote(dvc_yaml_path)) + ) + if (result != 0) { + stop(glue::glue("System command failed with status: {result}")) + } + message("System command executed successfully") + }, + error = function(e) { + glue::glue("An error occurred while executing dso repro") + } + ) - report_files <- list.files(stage_here("report"), pattern = "\\.pdf$|\\.html$", full.names = TRUE) + 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}")) - message(glue::glue("Displaying report file: {report_file}")) - # Check the file extension and display in the viewer - rstudioapi::viewer(report_file) + if (length(report_files) == 1) { + report_file <- report_files[1] + message(glue::glue("Report generated: {report_file}")) + message(glue::glue("Displaying report file: {report_file}")) + # Check the file extension and display in the viewer + rstudioapi::viewer(report_file) } else { - stop(glue::glue("No report file or multiple report files were identified. Please check the report directory.")) + stop(glue::glue("No report file or multiple report files were identified. Please check the report directory.")) + } + }, + error = function(e) { + message(glue::glue("An error occurred: {e$message}")) } - }, error = function(e) { - message(glue::glue("An error occurred: {e$message}")) - }) + ) } diff --git a/R/read_params.R b/R/read_params.R index d446784..ee7d34d 100644 --- a/R/read_params.R +++ b/R/read_params.R @@ -14,23 +14,23 @@ #' @importFrom yaml read_yaml #' @export read_params <- function(stage_path = NULL, return_list = FALSE) { - if(!is.logical(return_list)) + if (!is.logical(return_list)) { stop("Argument return_list needs to be logical.") + } # if stage_path argument was path, set stage from that argument - if(!is.null(stage_path)) { - + if (!is.null(stage_path)) { # first check for input validity - if(!is.character(stage_path)) + if (!is.character(stage_path)) { stop("stage_path argument must be a character string or NULL to reload the config") + } # then set stage path stage_path <- set_stage(stage_path) - } else { # stage_path argument is null, therefore not set. Check if stage_dir # has been already set in config_env, if yes reload, if not, stop with error - if(is.null(config_env$stage_dir)) { + if (is.null(config_env$stage_dir)) { stop("stage_path argument missing.") } else { cat(paste("reloading from already set stage_path:", config_env$stage_dir)) @@ -41,30 +41,37 @@ read_params <- function(stage_path = NULL, return_list = FALSE) { tmp_config_file <- tempfile() tmp_err_file <- tempfile() - tryCatch({ - output <- system2(DSO_EXEC, - c("get-config", - shQuote(stage_path)), - stdout = tmp_config_file, - stderr = tmp_err_file) + tryCatch( + { + output <- system2(DSO_EXEC, + c( + "get-config", + shQuote(stage_path) + ), + stdout = tmp_config_file, + stderr = tmp_err_file + ) - stderror <- readLines(tmp_err_file) + stderror <- readLines(tmp_err_file) - # error handling, display only rows after first error - # for better readability - if (output != 0 || any(grepl("ERROR", stderror))) { - stop( - paste("An error occurred when executing dso get-config:\n", - paste( - stderror[which(grepl("ERROR", stderror)) : length(stderror)], - collapse = "\n" - ) + # error handling, display only rows after first error + # for better readability + if (output != 0 || any(grepl("ERROR", stderror))) { + stop( + paste( + "An error occurred when executing dso get-config:\n", + paste( + stderror[which(grepl("ERROR", stderror)):length(stderror)], + collapse = "\n" + ) + ) ) - ) + } + }, + error = function(e) { + stop("An error occurred when executing dso get-config: ", e$message) } - }, error = function(e) { - stop("An error occurred when executing dso get-config: ", e$message) - }) + ) yaml <- read_yaml(tmp_config_file) unlink(tmp_config_file) From 9171db12ee0cfa96362f8d883d222ab73a77b110 Mon Sep 17 00:00:00 2001 From: "zxBIB Schreyer,Daniel (TMCP Data Sc) EXTERNAL" Date: Tue, 5 Nov 2024 13:57:58 +0100 Subject: [PATCH 07/14] updated addin functions for better usage --- R/addin.R | 50 ++++++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/R/addin.R b/R/addin.R index db489d6..b6985bd 100644 --- a/R/addin.R +++ b/R/addin.R @@ -23,22 +23,16 @@ dso_repro_stage_addin <- function() { dvc_yaml_path <- file.path(stage_path, "dvc.yaml") - tryCatch( - { - message(glue::glue("Reproducing the current stage")) - result <- system2( - DSO_EXEC, - c("repro -s", shQuote(dvc_yaml_path)) - ) - if (result != 0) { - stop(glue::glue("System command failed with status: {result}")) - } - message("System command executed successfully") - }, - error = function(e) { - glue::glue("An error occurred while executing dso repro") - } + message(glue::glue("Reproducing the current stage")) + result <- system2( + DSO_EXEC, + c("repro -s", shQuote(dvc_yaml_path)) ) + if (result != 0) { + stop(glue::glue("DSO repro -s failed with status: {result}")) + } else { + message("System command executed successfully") + } report_files <- list.files(stage_here("report"), pattern = "\\.pdf$|\\.html$", full.names = TRUE) @@ -69,22 +63,18 @@ dso_repro_stage_w_dependencies_addin <- function() { dvc_yaml_path <- file.path(stage_path, "dvc.yaml") - tryCatch( - { - message(glue::glue("Reproducing the current stage with all its dependency stages.")) - result <- system2( - DSO_EXEC, - c("repro", shQuote(dvc_yaml_path)) - ) - if (result != 0) { - stop(glue::glue("System command failed with status: {result}")) - } - message("System command executed successfully") - }, - error = function(e) { - glue::glue("An error occurred while executing dso repro") - } + message(glue::glue("Reproducing the current stage with all its dependency stages.")) + + result <- system2( + DSO_EXEC, + c("repro", shQuote(dvc_yaml_path)) ) + + if (result != 0) { + stop(glue::glue("DSO repro -s failed with status: {result}")) + } else { + message("System command executed successfully") + } report_files <- list.files(stage_here("report"), pattern = "\\.pdf$|\\.html$", full.names = TRUE) From 813dc1bc508c61109b2de9628009f41c40075e04 Mon Sep 17 00:00:00 2001 From: DSchreyer Date: Wed, 6 Nov 2024 10:17:48 +0000 Subject: [PATCH 08/14] pre-commit autofixes --- R/addin.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/addin.R b/R/addin.R index b6985bd..3005cb0 100644 --- a/R/addin.R +++ b/R/addin.R @@ -31,7 +31,7 @@ dso_repro_stage_addin <- function() { if (result != 0) { stop(glue::glue("DSO repro -s failed with status: {result}")) } else { - message("System command executed successfully") + message("System command executed successfully") } report_files <- list.files(stage_here("report"), pattern = "\\.pdf$|\\.html$", full.names = TRUE) @@ -64,16 +64,16 @@ dso_repro_stage_w_dependencies_addin <- function() { dvc_yaml_path <- file.path(stage_path, "dvc.yaml") message(glue::glue("Reproducing the current stage with all its dependency stages.")) - + result <- system2( DSO_EXEC, c("repro", shQuote(dvc_yaml_path)) ) - + if (result != 0) { stop(glue::glue("DSO repro -s failed with status: {result}")) } else { - message("System command executed successfully") + message("System command executed successfully") } report_files <- list.files(stage_here("report"), pattern = "\\.pdf$|\\.html$", full.names = TRUE) From f942af1474b197365206604cf613fb007a44be7e Mon Sep 17 00:00:00 2001 From: zxBIB Schreyer Date: Wed, 6 Nov 2024 12:01:25 +0100 Subject: [PATCH 09/14] updated addin; included repro function --- CHANGELOG.md | 4 +- NAMESPACE | 2 + R/addin.R | 130 +++++++++----------- R/repro.R | 30 +++++ man/dso_repro_stage_addin.Rd | 2 +- man/dso_repro_stage_w_dependencies_addin.Rd | 20 +++ man/repro.Rd | 21 ++++ 7 files changed, 134 insertions(+), 75 deletions(-) create mode 100644 R/repro.R create mode 100644 man/dso_repro_stage_w_dependencies_addin.Rd create mode 100644 man/repro.Rd diff --git a/CHANGELOG.md b/CHANGELOG.md index e193162..04818a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### New Features -- Introduced the rstudio addin to `dso repro` the current stage -- Introduced the rstudio addin to `dso repro` the current stage with dependencies +- Introduced the `repro` function that performs `dso repro` of a single stage with or without its dependencies +- Introduced the corresponding rstudio addins for the `repro` function ### Fixes diff --git a/NAMESPACE b/NAMESPACE index 17cdbf8..d7a70a1 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -7,9 +7,11 @@ export(compile_config) export(create_stage) export(dsoParams) export(dso_repro_stage_addin) +export(dso_repro_stage_w_dependencies_addin) export(init) export(read_params) export(reload) +export(repro) export(safe_get) export(set_stage) export(stage_here) diff --git a/R/addin.R b/R/addin.R index b6985bd..daf8c31 100644 --- a/R/addin.R +++ b/R/addin.R @@ -1,6 +1,6 @@ #' Execute dso repro and display the result #' -#' This function runs the `dso repro` command on the specified `dvc.yaml` file +#' This function reproduces the current stage without its dependencies #' and displays the resulting report in the RStudio Viewer pane. #' #' @return None @@ -11,85 +11,71 @@ #' \dontrun{ #' dso_repro_stage_addin() #' } -#' @export dso_repro_stage_addin <- function() { - tryCatch( - { - if (length(stage_here()) == 0) { - stop(glue::glue("stage_here() is not defined. Please read in your config file using read_params().")) - } else { - stage_path <- stage_here() - } - - dvc_yaml_path <- file.path(stage_path, "dvc.yaml") - - message(glue::glue("Reproducing the current stage")) - result <- system2( - DSO_EXEC, - c("repro -s", shQuote(dvc_yaml_path)) - ) - if (result != 0) { - stop(glue::glue("DSO repro -s failed with status: {result}")) - } else { - message("System command executed successfully") - } + stage_path <- get_stage_path() + dvc_yaml_path <- file.path(stage_path, "dvc.yaml") - report_files <- list.files(stage_here("report"), pattern = "\\.pdf$|\\.html$", full.names = TRUE) + repro(dvc_yaml_path, single_stage = TRUE) - if (length(report_files) == 1) { - report_file <- report_files[1] - message(glue::glue("Report generated: {report_file}")) - message(glue::glue("Displaying report file: {report_file}")) - # Check the file extension and display in the viewer - rstudioapi::viewer(report_file) - } else { - stop(glue::glue("No report file or multiple report files were identified. Please check the report directory.")) - } - }, - error = function(e) { - message(glue::glue("An error occurred: {e$message}")) - } - ) + 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() { - tryCatch( - { - if (length(stage_here()) == 0) { - stop(glue::glue("stage_here() is not defined. Please read in your config file using read_params().")) - } else { - stage_path <- stage_here() - } + stage_path <- get_stage_path() + dvc_yaml_path <- file.path(stage_path, "dvc.yaml") + + repro(dvc_yaml_path, single_stage = FALSE) - dvc_yaml_path <- file.path(stage_path, "dvc.yaml") + check_report() +} - message(glue::glue("Reproducing the current stage with all its dependency stages.")) - - result <- system2( - DSO_EXEC, - c("repro", shQuote(dvc_yaml_path)) - ) - - if (result != 0) { - stop(glue::glue("DSO repro -s failed with status: {result}")) - } else { - message("System command executed successfully") - } +#' 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 +get_stage_path <- function() { + if (length(stage_here()) == 0) { + stop(glue::glue("stage_here() is not defined. Please read in your config file using read_params().")) + } else { + return(stage_here()) + } +} - report_files <- list.files(stage_here("report"), pattern = "\\.pdf$|\\.html$", full.names = TRUE) +#' Check and display the report +#' +#' This function checks for the generated report files in the stage directory +#' and displays the report in the RStudio Viewer pane if a single report file is found. +#' +#' @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}")) - message(glue::glue("Displaying report file: {report_file}")) - # Check the file extension and display in the viewer - rstudioapi::viewer(report_file) - } else { - stop(glue::glue("No report file or multiple report files were identified. Please check the report directory.")) - } - }, - error = function(e) { - message(glue::glue("An error occurred: {e$message}")) - } - ) + if (length(report_files) == 1) { + report_file <- report_files[1] + message(glue::glue("Report generated: {report_file}")) + message(glue::glue("Displaying report file: {report_file}")) + # Check the file extension and display in the viewer + rstudioapi::viewer(report_file) + } else { + stop(glue::glue("No report file or multiple report files were identified. Please check the report directory.")) + } } diff --git a/R/repro.R b/R/repro.R new file mode 100644 index 0000000..bd9f123 --- /dev/null +++ b/R/repro.R @@ -0,0 +1,30 @@ +#' @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") + } +} + diff --git a/man/dso_repro_stage_addin.Rd b/man/dso_repro_stage_addin.Rd index 062a14e..1bc532c 100644 --- a/man/dso_repro_stage_addin.Rd +++ b/man/dso_repro_stage_addin.Rd @@ -10,7 +10,7 @@ dso_repro_stage_addin() None } \description{ -This function runs the `dso repro` command on the specified `dvc.yaml` file +This function reproduces the current stage without its dependencies and displays the resulting report in the RStudio Viewer pane. } \examples{ diff --git a/man/dso_repro_stage_w_dependencies_addin.Rd b/man/dso_repro_stage_w_dependencies_addin.Rd new file mode 100644 index 0000000..d785849 --- /dev/null +++ b/man/dso_repro_stage_w_dependencies_addin.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/addin.R +\name{dso_repro_stage_w_dependencies_addin} +\alias{dso_repro_stage_w_dependencies_addin} +\title{Execute dso repro with dependencies and display the result} +\usage{ +dso_repro_stage_w_dependencies_addin() +} +\value{ +None +} +\description{ +This function reproduces the current stage along its dependencies +and displays the resulting report in the RStudio Viewer pane. +} +\examples{ +\dontrun{ +dso_repro_stage_w_dependencies_addin() +} +} diff --git a/man/repro.Rd b/man/repro.Rd new file mode 100644 index 0000000..4a7f75a --- /dev/null +++ b/man/repro.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/repro.R +\name{repro} +\alias{repro} +\title{Reproduce a dso stage} +\usage{ +repro(stage_path = stage_here(), single_stage = F) +} +\arguments{ +\item{stage_path}{The path to a stage. Defaults to the current stage by using `stage_here()`.} + +\item{single_stage}{Logical flag indicating whether to reproduce only the current stage (`TRUE`) or the current stage with all dependencies (`FALSE`). Defaults to `FALSE`.} +} +\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. +} From 3a919715a7ee362ffd884ed1af51b220e04d2c3e Mon Sep 17 00:00:00 2001 From: DSchreyer Date: Wed, 6 Nov 2024 11:04:56 +0000 Subject: [PATCH 10/14] pre-commit autofixes --- R/repro.R | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/R/repro.R b/R/repro.R index bd9f123..36cc639 100644 --- a/R/repro.R +++ b/R/repro.R @@ -16,15 +16,14 @@ repro <- function(stage_path = stage_here(), single_stage = F) { 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"))) - ) + 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") - } + if (result != 0) { + stop(glue::glue("DSO {repro_cmd} failed with status: {result}")) + } else { + message("dso repro was executed successfully") + } } - From 981881e050fef70473669ec8a7e0e9a9f57817cc Mon Sep 17 00:00:00 2001 From: zxBIB Schreyer Date: Thu, 7 Nov 2024 11:27:31 +0100 Subject: [PATCH 11/14] fixed dvc.yaml error, removed show report --- R/addin.R | 19 ++++++------------ R/repro.R | 7 +++++-- man/repro.Rd | 7 +++++-- test_stage/dvc.lock | 38 ++++++++++++++++++++++++++++++++++++ test_stage/report/.gitignore | 1 + 5 files changed, 55 insertions(+), 17 deletions(-) create mode 100755 test_stage/dvc.lock create mode 100755 test_stage/report/.gitignore diff --git a/R/addin.R b/R/addin.R index daf8c31..2e5455f 100644 --- a/R/addin.R +++ b/R/addin.R @@ -12,10 +12,10 @@ #' dso_repro_stage_addin() #' } dso_repro_stage_addin <- function() { - stage_path <- get_stage_path() - dvc_yaml_path <- file.path(stage_path, "dvc.yaml") + check_stage_here() + dvc_yaml_path <- stage_here("dvc.yaml") - repro(dvc_yaml_path, single_stage = TRUE) + repro(stage_here(), single_stage = TRUE) check_report() } @@ -34,10 +34,9 @@ dso_repro_stage_addin <- function() { #' dso_repro_stage_w_dependencies_addin() #' } dso_repro_stage_w_dependencies_addin <- function() { - stage_path <- get_stage_path() - dvc_yaml_path <- file.path(stage_path, "dvc.yaml") + check_stage_here() - repro(dvc_yaml_path, single_stage = FALSE) + repro(stage_here(), single_stage = FALSE) check_report() } @@ -49,18 +48,15 @@ dso_repro_stage_w_dependencies_addin <- function() { #' #' @return The absolute path to the current stage. #' @noRd -get_stage_path <- function() { +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().")) - } else { - return(stage_here()) } } #' Check and display the report #' #' This function checks for the generated report files in the stage directory -#' and displays the report in the RStudio Viewer pane if a single report file is found. #' #' @return None #' @noRd @@ -72,9 +68,6 @@ check_report <- function() { if (length(report_files) == 1) { report_file <- report_files[1] message(glue::glue("Report generated: {report_file}")) - message(glue::glue("Displaying report file: {report_file}")) - # Check the file extension and display in the viewer - rstudioapi::viewer(report_file) } else { stop(glue::glue("No report file or multiple report files were identified. Please check the report directory.")) } diff --git a/R/repro.R b/R/repro.R index 36cc639..f81a185 100644 --- a/R/repro.R +++ b/R/repro.R @@ -2,8 +2,11 @@ #' @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. +#' 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`. diff --git a/man/repro.Rd b/man/repro.Rd index 4a7f75a..4de3c64 100644 --- a/man/repro.Rd +++ b/man/repro.Rd @@ -15,7 +15,10 @@ repro(stage_path = stage_here(), single_stage = F) 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. +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. } diff --git a/test_stage/dvc.lock b/test_stage/dvc.lock new file mode 100755 index 0000000..c1d2443 --- /dev/null +++ b/test_stage/dvc.lock @@ -0,0 +1,38 @@ +schema: '2.0' +stages: + test_stage: + cmd: + - dso exec quarto . + deps: + - path: src/test_stage.qmd + hash: md5 + md5: 7738437826e614530acc89ebcf7d68c4 + size: 367 + isexec: true + params: + params.yaml: + dso.quarto: + before_script: '' + author: + - name: Jane Doe + affiliations: + - Example Department + format: + html: + fig-format: svg + toc: true + code-fold: true + embed-resources: true + page-layout: full + execute: + warning: true + message: false + date: now + date-format: YYYY-MMM-DD + test: testing + outs: + - path: report/test_stage.html + hash: md5 + md5: b1e1700373b78385d582410bef7e09aa + size: 1126745 + isexec: true diff --git a/test_stage/report/.gitignore b/test_stage/report/.gitignore new file mode 100755 index 0000000..c73147d --- /dev/null +++ b/test_stage/report/.gitignore @@ -0,0 +1 @@ +/test_stage.html From 0e0a0ad189bc0d4f5399109507370935d6e8e7fa Mon Sep 17 00:00:00 2001 From: zxBIB Schreyer Date: Thu, 7 Nov 2024 11:32:20 +0100 Subject: [PATCH 12/14] removed test_stage --- test_stage/dvc.lock | 38 ------------------------------------ test_stage/report/.gitignore | 1 - 2 files changed, 39 deletions(-) delete mode 100755 test_stage/dvc.lock delete mode 100755 test_stage/report/.gitignore diff --git a/test_stage/dvc.lock b/test_stage/dvc.lock deleted file mode 100755 index c1d2443..0000000 --- a/test_stage/dvc.lock +++ /dev/null @@ -1,38 +0,0 @@ -schema: '2.0' -stages: - test_stage: - cmd: - - dso exec quarto . - deps: - - path: src/test_stage.qmd - hash: md5 - md5: 7738437826e614530acc89ebcf7d68c4 - size: 367 - isexec: true - params: - params.yaml: - dso.quarto: - before_script: '' - author: - - name: Jane Doe - affiliations: - - Example Department - format: - html: - fig-format: svg - toc: true - code-fold: true - embed-resources: true - page-layout: full - execute: - warning: true - message: false - date: now - date-format: YYYY-MMM-DD - test: testing - outs: - - path: report/test_stage.html - hash: md5 - md5: b1e1700373b78385d582410bef7e09aa - size: 1126745 - isexec: true diff --git a/test_stage/report/.gitignore b/test_stage/report/.gitignore deleted file mode 100755 index c73147d..0000000 --- a/test_stage/report/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/test_stage.html From 6290307119e531380845cf8365089f0856dd395b Mon Sep 17 00:00:00 2001 From: DSchreyer Date: Fri, 8 Nov 2024 07:04:34 +0000 Subject: [PATCH 13/14] pre-commit autofixes --- R/class-dsoParams.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/class-dsoParams.R b/R/class-dsoParams.R index a20cd5d..22a15bb 100644 --- a/R/class-dsoParams.R +++ b/R/class-dsoParams.R @@ -108,4 +108,4 @@ setMethod( } }) } -) \ No newline at end of file +) From 87054720072dac43b57b92324ac2c54947849990 Mon Sep 17 00:00:00 2001 From: zxBIB Schreyer Date: Mon, 11 Nov 2024 13:48:09 +0100 Subject: [PATCH 14/14] changelog fix and dvc_yaml_path removal --- CHANGELOG.md | 2 +- R/addin.R | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad50cef..990f503 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Fixes -- Removed ... in reload function +- Removed `...` in reload function ## v0.5.1 diff --git a/R/addin.R b/R/addin.R index 2e5455f..97afd4c 100644 --- a/R/addin.R +++ b/R/addin.R @@ -13,7 +13,6 @@ #' } dso_repro_stage_addin <- function() { check_stage_here() - dvc_yaml_path <- stage_here("dvc.yaml") repro(stage_here(), single_stage = TRUE)