Skip to content

Commit

Permalink
Merge pull request #3196 from moki1202/base_remaining_notes
Browse files Browse the repository at this point in the history
fix-notes/warnings/errors in base packages
  • Loading branch information
infotroph authored Jan 3, 2024
2 parents 03cbff8 + baa6b6d commit 20dfc2b
Show file tree
Hide file tree
Showing 34 changed files with 172 additions and 35 deletions.
3 changes: 2 additions & 1 deletion base/remote/R/remote.execute.R.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
#'
#' @title Execute command remotely
#' @param script the script to be invoked, as a list of commands.
#' @param args a character vector of arguments to command.
#' @param host settings host list
#' @param user the username to use for remote login
#' @param verbose should the output be printed to the console
#' @param R Path to the R executable or binary file.
#' @param scratchdir Path to the scratch directory for temporary files during remote execution.
#' @return the captured output of the command (both stdout and stderr)
#' @author Rob Kooper
#' @export
Expand Down
2 changes: 1 addition & 1 deletion base/remote/R/remote.execute.cmd.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' machine it will execute the command locally without ssh.
#'
#' @title Execute command remotely
#' @param command the system command to be invoked, as a character string.
#' @param cmd the system command to be invoked, as a character string.
#' @param host host structure to execute command on
#' @param args a character vector of arguments to command.
#' @param stderr should stderr be returned as well.
Expand Down
2 changes: 2 additions & 0 deletions base/remote/R/test_remote.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#' Test remote execution
#'
#' @inheritParams remote.execute.cmd
#'
#' @param ... additional arguments.
#'
#' @return `TRUE` is remote execution is successful.
#' If unsuccessful, depends on the value of `stderr`.
Expand Down
4 changes: 3 additions & 1 deletion base/remote/man/remote.execute.R.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions base/remote/man/remote.execute.cmd.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions base/remote/man/test_remote.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion base/settings/R/MultiSettings.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ names.MultiSettings <- function(x) {
stop("Can't name MultiSettings this way. Use settingNames() instead.")
}

#' function that can retrieve or update the names of multi-settings.
#'
#' @param multiSettings object for which to retrieve or set the names.
#' @param settingNames names to be set for the multi-settings object.
#'
#' @export
settingNames <- function(multiSettings, settingNames) {
if (missing(settingNames)) {
Expand All @@ -159,6 +164,10 @@ print.MultiSettings <- function(x, printAll = FALSE, ...) {
}
}

#' generic function for printing contents of objects.
#'
#' @param x object to be printed.
#'
#' @export
printAll <- function(x) {
UseMethod("printAll", x)
Expand Down Expand Up @@ -196,7 +205,10 @@ listToXml.MultiSettings <- function(item, tag, collapse = TRUE) {
NextMethod()
} # listToXml.MultiSettings


#' generic function for expanding multi-settings.
#'
#' @param x object to be expanded.
#'
#' @export
expandMultiSettings <- function(x) {
UseMethod("expandMultiSettings")
Expand Down
1 change: 1 addition & 0 deletions base/settings/R/addSecrets.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#'
#' @title Add Users secrets
#' @param settings settings file
#' @param force Logical: add secrets even if they have been added previously?
#' @return will return the updated settings values
#' @author Rob Kooper
#' @export addSecrets
Expand Down
12 changes: 12 additions & 0 deletions base/settings/R/check.all.settings.R
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ check.bety.version <- function(dbcon) {
#' - pfts with at least one pft defined
#' @title Check Settings
#' @param settings settings file
#' @param force Logical: Rerun check even if these settings have been checked previously?
#' @return will return the updated settings values with defaults set.
#' @author Rob Kooper, David LeBauer
#' @export check.settings
Expand Down Expand Up @@ -614,6 +615,7 @@ check.settings <- function(settings, force = FALSE) {

#' @title Check Run Settings
#' @param settings settings file
#' @param dbcon database connection.
#' @export check.run.settings
check.run.settings <- function(settings, dbcon = NULL) {
scipen <- getOption("scipen")
Expand Down Expand Up @@ -805,6 +807,7 @@ check.run.settings <- function(settings, dbcon = NULL) {

#' @title Check Model Settings
#' @param settings settings file
#' @param dbcon database connection.
#' @export check.model.settings
check.model.settings <- function(settings, dbcon = NULL) {
# check modelid with values
Expand Down Expand Up @@ -1077,6 +1080,7 @@ check.database.settings <- function(settings) {
#' @param settings settings file
#' @export check.ensemble.settings
check.ensemble.settings <- function(settings) {

# check ensemble
if (!is.null(settings$ensemble)) {
if (is.null(settings$ensemble$variable)) {
Expand All @@ -1097,6 +1101,10 @@ check.ensemble.settings <- function(settings) {

if (is.null(settings$ensemble$start.year)) {
if (!is.null(settings$run$start.date)) {
startdate <- lubridate::parse_date_time(
settings$run$start.date,
"ymd_HMS",
truncated = 3)
settings$ensemble$start.year <- lubridate::year(
settings$run$start.date)
PEcAn.logger::logger.info(
Expand All @@ -1116,6 +1124,10 @@ check.ensemble.settings <- function(settings) {

if (is.null(settings$ensemble$end.year)) {
if (!is.null(settings$run$end.date)) {
enddate <- lubridate::parse_date_time(
settings$run$end.date,
"ymd_HMS",
truncated = 3)
settings$ensemble$end.year <- lubridate::year(settings$run$end.date)
PEcAn.logger::logger.info(
"No end date passed to ensemble - using the run date (",
Expand Down
1 change: 1 addition & 0 deletions base/settings/R/clean.settings.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#' @param inputfile the PEcAn settings file to be used.
#' @param outputfile the name of file to which the settings will be
#' written inside the outputdir.
#' @param write Indicates whether to write the modified settings to a file.
#' @return list of all settings as saved to the XML file(s)
#' @export clean.settings
#' @author Rob Kooper
Expand Down
1 change: 1 addition & 0 deletions base/settings/R/fix.deprecated.settings.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#'
#' @title Fix Deprecated Settings
#' @param settings settings list
#' @param force Logical: re-run fixing of deprecated settings even if it has been done previously?
#' @return updated settings list
#' @author Ryan Kelly
#' @export fix.deprecated.settings
Expand Down
48 changes: 31 additions & 17 deletions base/settings/R/listToXml.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#' A generic function to convert list to XML
#'
#' @param x list to be converted
#' @param ... arguments passed to methods
#' @export
listToXml <- function(x, ...) {
UseMethod("listToXml")
Expand All @@ -8,43 +12,53 @@ listToXml <- function(x, ...) {
#'
#' Can convert list or other object to an xml object using xmlNode
#' @title List to XML
#' @param item object to be converted.
#' @param x object to be converted.
#' Despite the function name, need not actually be a list
#' @param tag xml tag
#' @param ... further arguments.
#' Used to set the element name of the created XML object,
#' which is taken from an argument named `tag` if present,
#' or otherwise from the first element of `...`
#' @return xmlNode
#' @export
#' @author David LeBauer, Carl Davidson, Rob Kooper
listToXml.default <- function(item, tag) {

listToXml.default <- function(x, ...) {
args <- list(...)
if (length(args) == 0) {
PEcAn.logger::logger.error("no tag provided")
} else if ("tag" %in% names(args)) {
tag <- args$tag
} else {
tag <- args[[1]]
}
# just a textnode, or empty node with attributes
if (typeof(item) != "list") {
if (length(item) > 1) {
if (typeof(x) != "list") {
if (length(x) > 1) {
xml <- XML::xmlNode(tag)
for (name in names(item)) {
XML::xmlAttrs(xml)[[name]] <- item[[name]]
for (name in names(x)) {
XML::xmlAttrs(xml)[[name]] <- x[[name]]
}
return(xml)
} else {
return(XML::xmlNode(tag, item))
return(XML::xmlNode(tag, x))
}
}

# create the node
if (identical(names(item), c("text", ".attrs"))) {
if (identical(names(x), c("text", ".attrs"))) {
# special case a node with text and attributes
xml <- XML::xmlNode(tag, item[["text"]])
xml <- XML::xmlNode(tag, x[["text"]])
} else {
# node with child nodes
xml <- XML::xmlNode(tag)
for (i in seq_along(item)) {
if (is.null(names(item)) || names(item)[i] != ".attrs") {
xml <- XML::append.xmlNode(xml, listToXml(item[[i]], names(item)[i]))
for (i in seq_along(x)) {
if (is.null(names(x)) || names(x)[i] != ".attrs") {
xml <- XML::append.xmlNode(xml, listToXml(x[[i]], names(x)[i]))
}
}
}

# add attributes to node
attrs <- item[[".attrs"]]
attrs <- x[[".attrs"]]
for (name in names(attrs)) {
XML::xmlAttrs(xml)[[name]] <- attrs[[name]]
}
Expand Down
1 change: 1 addition & 0 deletions base/settings/R/update.settings.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#' @title Update Settings
#' @name update.settings
#' @param settings settings file
#' @param force Logical: update even if settings have previously been updated?.
#' @return will return the updated settings values
#' @export update.settings
#' @author Rob Kooper
Expand Down
2 changes: 2 additions & 0 deletions base/settings/man/addSecrets.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions base/settings/man/check.model.settings.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions base/settings/man/check.run.settings.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions base/settings/man/check.settings.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions base/settings/man/clean.settings.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions base/settings/man/expandMultiSettings.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions base/settings/man/fix.deprecated.settings.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions base/settings/man/listToXml.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions base/settings/man/listToXml.default.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions base/settings/man/printAll.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 20dfc2b

Please sign in to comment.