Skip to content

Commit

Permalink
Don't fail if params not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
Eliot McIntire committed Dec 2, 2024
1 parent 340dbb6 commit 7815a04
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Description: Quickly setup a 'SpaDES' project directories and add modules using
URL:
https://spades-project.predictiveecology.org/,
https://github.com/PredictiveEcology/SpaDES.project
Date: 2024-11-29
Version: 0.1.1.9001
Date: 2024-12-02
Version: 0.1.1.9002
Authors@R: c(
person("Eliot J B", "McIntire", email = "[email protected]",
role = c("aut", "cre"), comment = c(ORCID = "0000-0002-6914-8316")),
Expand Down
32 changes: 26 additions & 6 deletions R/setupProject.R
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,8 @@ setupProject <- function(name, paths, modules, packages,
# TODO from here to out <- should be brought into the "else" block when `SpaDES.config is worked on`
remainingArgs <- origArgOrder[!argsAreInFormals]
remainingArgs <- remainingArgs[nzchar(remainingArgs)]
# if (missing(paramsSUB))
# params <- list()
for (ar in remainingArgs) {
if (identical(ar, "params")) {
params <- setupParams(name, paramsSUB, paths, modules, times, options = opts[["newOptions"]],
Expand Down Expand Up @@ -600,12 +602,30 @@ setupProject <- function(name, paths, modules, packages,
paths <- paths[spPaths]
attr(paths, "extraPaths") <- pathsOrig[extras]

out <- append(list(
modules = modules,
paths = paths, # this means we lose the packagePath --> but it is in .libPaths()[1]
# we also lose projectPath --> but this is getwd()
params = params,
times = times), dotsSUB)
out <- dotsSUB
toAppend <- rev(list("modules", "paths", "params"))
for (toA in toAppend) {
# some may be missing, e.g., params
arg <- try(eval(parse(text = toA)), silent = TRUE)
if (!is(arg, "try-error")) {
argToAppend <- list(arg) |> setNames(toA)
out <- append(argToAppend, out)
} else {
message("Argument ", toA, " is missing; proceeding without")
}
# append(list(
# modules = modules,
# paths = paths, # this means we lose the packagePath --> but it is in .libPaths()[1]
# # we also lose projectPath --> but this is getwd()
# params = params,
# times = times), dotsSUB)
}
# out <- append(list(
# modules = modules,
# paths = paths, # this means we lose the packagePath --> but it is in .libPaths()[1]
# # we also lose projectPath --> but this is getwd()
# params = params,
# times = times), dotsSUB)
if (!is.null(options)) {
attr(out, "projectOptions") <- opts$updates
}
Expand Down

0 comments on commit 7815a04

Please sign in to comment.