From 548d3bc04367ab6f7c5a2548e96afa07021424f5 Mon Sep 17 00:00:00 2001 From: katieb1 Date: Wed, 6 Dec 2023 11:23:25 -0800 Subject: [PATCH] Test template arg in ssimLibrary --- R/ssimLibrary.R | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/R/ssimLibrary.R b/R/ssimLibrary.R index f706027f..a738b341 100644 --- a/R/ssimLibrary.R +++ b/R/ssimLibrary.R @@ -7,8 +7,8 @@ setMethod( f = "initialize", signature = "SsimLibrary", definition = function(.Object, name = NULL, packages = NULL, session = NULL, template = NULL, forceUpdate = FALSE, overwrite = FALSE, useConda = NULL) { - browser() enabled <- NULL + if (is.null(session)) { e <- ssimEnvironment() if (!is.na(e$ProgramDirectory)) { @@ -96,7 +96,7 @@ setMethod( # Load template args <- list(create = NULL, library = NULL, name = path, pkg = templatePkg, - template = template) + template = pkgTemplate) cStatus <- command(args, session) if (grepl(cStatus[1], "Creating Library from Template")) { @@ -108,7 +108,7 @@ setMethod( tt <- command(args, session) tempScenarios <- read.csv(text = tt) message(paste(c("Scenarios available in this template:", - tempScenarios$Name), collapse = " ")) + tempScenarios$Name), collapse = "\n")) } else { stop(paste(template, "does not exist among packages selected:", packages)) } @@ -311,12 +311,16 @@ setMethod("ssimLibrary", signature(name = "missingOrNULLOrChar"), function(name # Add specified packages to the library packageOptions <- .packages(session, installed = TRUE) + addedPackages <- .packages(newLib) if (!is.null(packages)) { for (pkg in packages){ if (!is.null(pkg) && !is.element(pkg, packageOptions$name)) { stop(paste(pkg, "not currently installed. Use packages(session, installed = TRUE) to see options.")) } + if (pkg %in% addedPackages$name){ + next + } addPackage(newLib, pkg) } }