Skip to content

Commit

Permalink
Run all outputs (#1491)
Browse files Browse the repository at this point in the history
* udpate core files

* Add options to run all outputs or only output selections in simulation snapshots
+ add tests

* Verify that number of column is greater when RunForAllOutputs == TRUE

* styler::style_pkg()

* 🤖 Update Core Files.

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
Felixmil and github-actions[bot] authored Oct 23, 2024
1 parent aedb533 commit c7354de
Show file tree
Hide file tree
Showing 25 changed files with 203 additions and 184 deletions.
10 changes: 6 additions & 4 deletions R/snapshots.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#'
#' @param ... character strings, path to snapshot files or a directory containing snapshot files
#' @param output character string, path to the output directory where to write simulation results
#' @param RunForAllOutputs logical, whether to run the simulation for all outputs or only OutputSelections (default = FALSE)
#' @param exportCSV logical, whether to export the results as csv (default = TRUE)
#' @param exportPKML logical, whether to export the results as pkml (default = FALSE)
#' @param exportJSON logical, whether to export simulation results as json (default = FALSE)
Expand All @@ -14,8 +15,8 @@
#' \dontrun{
#' runSimulationsFromSnapshot("path/to/my_snapshot.json", csv = TRUE, pkml = TRUE)
#' }
runSimulationsFromSnapshot <- function(..., output = ".", exportCSV = TRUE, exportPKML = FALSE, exportJSON = FALSE, exportXML = FALSE) {
ospsuite.utils::validateIsLogical(object = c(exportCSV, exportPKML, exportXML))
runSimulationsFromSnapshot <- function(..., output = ".", RunForAllOutputs = FALSE, exportCSV = TRUE, exportPKML = FALSE, exportJSON = FALSE, exportXML = FALSE) {
ospsuite.utils::validateIsLogical(object = c(exportCSV, exportPKML, exportXML, RunForAllOutputs))
ospsuite.utils::validateIsCharacter(object = c(..., output))

paths_exist <- file.exists(c(..., output))
Expand All @@ -31,6 +32,7 @@ runSimulationsFromSnapshot <- function(..., output = ".", exportCSV = TRUE, expo
JsonRunOptions <- rSharp::newObjectFromName("PKSim.CLI.Core.RunOptions.JsonRunOptions")
JsonRunOptions$set("InputFolder", temp_dir)
JsonRunOptions$set("OutputFolder", normalizePath(output))
JsonRunOptions$set("RunForAllOutputs", RunForAllOutputs)

if (isTRUE(exportJSON)) {
exportJSON <- 1L
Expand Down Expand Up @@ -143,8 +145,8 @@ convertSnapshot <- function(..., format, output = ".", runSimulations = FALSE) {
},
error = function(e) {
message <- stringr::str_extract(as.character(e), "(?<=Message: )[^\\n]*")
if (is.na(message)){

if (is.na(message)) {
message <- e
}

Expand Down
Loading

0 comments on commit c7354de

Please sign in to comment.