From ede6ff5478b461d234d4d5878789c906ad279c13 Mon Sep 17 00:00:00 2001 From: Shashank Singh Date: Sat, 22 Jul 2023 09:51:37 +0000 Subject: [PATCH 1/3] fix notes/warnings in assim.batch package --- modules/assim.batch/R/get.da.data.R | 10 ++++++- modules/assim.batch/R/get.da.data.growth.R | 11 ++++++- modules/assim.batch/R/pda.utils.R | 7 ++++- modules/assim.batch/R/plot.da.R | 34 ++++++++++++++++++++-- 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/modules/assim.batch/R/get.da.data.R b/modules/assim.batch/R/get.da.data.R index b6cff004b58..16997b7b4ca 100644 --- a/modules/assim.batch/R/get.da.data.R +++ b/modules/assim.batch/R/get.da.data.R @@ -41,7 +41,15 @@ calculate.nee.L <- function(yeardoytime, model.i.nee, observed.flux, be, bu) { get.da.data <- function(out.dir, ameriflux.dir, years, be, bu, ensemble.size = 199) { - load(paste(out.dir, "samples.Rdata", sep = "")) + samples.file <- paste(out.dir, "samples.Rdata" , sep = "") + if(file.exists(samples.file)) { + samples <- new.env() + load(samples.file, envir = samples) + ensemble.samples <- samples$ensemble.samples + sa.samples <- samples$sa.samples + } else { + PEcAn.logger::logger.error(samples.file, "not found, this file is required by the get.da.data function") + } pfts <- names(ensemble.samples) pfts <- pfts[pfts != "env"] diff --git a/modules/assim.batch/R/get.da.data.growth.R b/modules/assim.batch/R/get.da.data.growth.R index 4aca974fcf4..37737b37bd7 100644 --- a/modules/assim.batch/R/get.da.data.growth.R +++ b/modules/assim.batch/R/get.da.data.growth.R @@ -80,7 +80,16 @@ get.da.data.growth <- function() { growth <- cbind(buds[, c("plot", "individual", "pft")], growth) ensemble.size <- 500 - load(paste(out.dir, "samples.Rdata", sep = "")) + samples.file <- paste(out.dir, "samples.Rdata" , sep = "") + + if(file.exists(samples.file)) { + samples <- new.env() + load(samples.file, envir = samples) + ensemble.samples <- samples$ensemble.samples + sa.samples <- samples$sa.samples + } else { + PEcAn.logger::logger.error(samples.file, "not found, this file is required by the get.da.data function") + } pfts <- names(ensemble.samples) pfts <- pfts[pfts != "env"] diff --git a/modules/assim.batch/R/pda.utils.R b/modules/assim.batch/R/pda.utils.R index 158cf0a1e12..bf619061aee 100644 --- a/modules/assim.batch/R/pda.utils.R +++ b/modules/assim.batch/R/pda.utils.R @@ -297,6 +297,7 @@ pda.load.priors <- function(settings, con, extension.check = FALSE) { if (length(pid) == 0) { pid <- grep("prior.distns.Rdata", files$file_name) ## is there a prior file? + } if (length(pid) > 0) { @@ -322,7 +323,11 @@ pda.load.priors <- function(settings, con, extension.check = FALSE) { # make sure there are no left over distributions in the environment suppressWarnings(rm(post.distns, prior.distns)) - load(prior.paths[[i]]) + distns <- new.env() + load(prior.paths[[i]], envir = "distns") + prior.distns <- distns$prior.distns + post.distns <- distns$post.distns + if (!exists("post.distns")) { prior.out[[i]] <- prior.distns } else { diff --git a/modules/assim.batch/R/plot.da.R b/modules/assim.batch/R/plot.da.R index d83e988e436..5e5408894ad 100644 --- a/modules/assim.batch/R/plot.da.R +++ b/modules/assim.batch/R/plot.da.R @@ -23,8 +23,27 @@ plot.da <- function(prior.dir, prior.file, in.dir, out.dir, next.run.dir) { num.run.ids <- 5 #commandArgs(trailingOnly = TRUE) print(num.run.ids) - load(paste(in.dir, "samples.Rdata", sep = "")) - load(paste(in.dir, "L.nee.Rdata", sep = "")) + samples.file <- paste(in.dir, "samples.Rdata", sep = "") + L.nee.file <- paste(in.dir, "L.nee.Rdata", sep = "") + + if(file.exists(samples.file)) { + samples <- new.env() + load(samples.file, envir = "samples") + ensemble.samples <- samples$ensemble.samples + sa.samples <- samples$sa.samples + } else { + PEcAn.logger::logger.error(samples.file, "not found, this file is required by the plot.da function") + } + + if(file.exists(L.nee.file)) { + L.nee <- new.env() + load(L.nee.file, envir = "L.nee") + x <- L.nee$x + y <- L.nee$y + } else { + PEcAn.logger::logger.error(L.nee.file, "not found, this file is required by the plot.da function") + } + prior.x <- x prior.y <- y @@ -90,7 +109,16 @@ plot.da <- function(prior.dir, prior.file, in.dir, out.dir, next.run.dir) { samp <- lapply(seq(num.run.ids), function(run.id) { print(paste0(in.dir, "./mcmc", run.id, ".Rdata")) - load(paste0(in.dir, "./mcmc", run.id, ".Rdata")) + run.id.file <- paste0(in.dir, "./mcmc", run.id, ".Rdata") + + if(file.exists(run.id.file)) { + run.env <- new.env() + load(run.id.file, envir = "run.env") + m <- run.env$m + } else { + PEcAn.logger::logger.error(run.id.file, "not found, this file is required by the plot.da function") + } + return(m) }) From 687d97ff701b0939ddcf2124686ff559ff2c55af Mon Sep 17 00:00:00 2001 From: Shashank Singh Date: Thu, 4 Jan 2024 10:51:00 +0000 Subject: [PATCH 2/3] add check.log file --- .../assim.batch/tests/Rcheck_reference.log | 106 +++++------------- 1 file changed, 30 insertions(+), 76 deletions(-) diff --git a/modules/assim.batch/tests/Rcheck_reference.log b/modules/assim.batch/tests/Rcheck_reference.log index 4dbe004041b..46f8890b1e3 100644 --- a/modules/assim.batch/tests/Rcheck_reference.log +++ b/modules/assim.batch/tests/Rcheck_reference.log @@ -1,62 +1,13 @@ -* using log directory ‘/home/tanishq010/pecan/modules/PEcAn.assim.batch.Rcheck’ -* using R version 4.2.1 (2022-06-23) +* using log directory ‘/tmp/Rtmp0m7lr6/PEcAn.assim.batch.Rcheck’ +* using R version 4.1.3 (2022-03-10) * using platform: x86_64-pc-linux-gnu (64-bit) * using session charset: UTF-8 * using options ‘--no-manual --as-cran’ * checking for file ‘PEcAn.assim.batch/DESCRIPTION’ ... OK * checking extension type ... Package -* this is package ‘PEcAn.assim.batch’ version ‘1.7.2’ +* this is package ‘PEcAn.assim.batch’ version ‘1.7.2.9000’ * package encoding: UTF-8 -* checking CRAN incoming feasibility ... WARNING -Maintainer: ‘Istem Fer ’ - -New submission - -License components with restrictions and base license permitting such: - BSD_3_clause + file LICENSE -File 'LICENSE': - University of Illinois/NCSA Open Source License - - Copyright (c) 2012, University of Illinois, NCSA. All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal with the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimers. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimers in the - documentation and/or other materials provided with the distribution. - - Neither the names of University of Illinois, NCSA, nor the names - of its contributors may be used to endorse or promote products - derived from this Software without specific prior written permission. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR - ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. - -Strong dependencies not in mainstream repositories: - PEcAn.benchmark, PEcAn.DB, PEcAn.emulator, PEcAn.logger, PEcAn.MA, - PEcAn.remote, PEcAn.settings, PEcAn.uncertainty, PEcAn.utils, - PEcAn.workflow - -The Date field is over a month old. * checking package namespace information ... OK -* checking package dependencies ... WARNING -Imports includes 27 non-default packages. -Importing from so many packages makes the package vulnerable to any of -them becoming unavailable. Move as many as possible to Suggests and -use conditionally. - * checking package dependencies ... NOTE Imports includes 27 non-default packages. Importing from so many packages makes the package vulnerable to any of @@ -87,37 +38,17 @@ use conditionally. * checking whether the namespace can be loaded with stated dependencies ... OK * checking whether the namespace can be unloaded cleanly ... OK * checking loading without being on the library search path ... OK -* checking use of S3 registration ... OK -* checking dependencies in R code ... NOTE -Namespace in Imports field not imported from: ‘dplyr’ - All declared Imports should be used. +* checking dependencies in R code ... OK * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for possible problems ... NOTE -get.da.data: no visible binding for global variable ‘ensemble.samples’ -get.da.data : : no visible binding for global variable - ‘sa.samples’ -get.da.data: no visible binding for global variable ‘sa.samples’ get.da.data : : no visible global function definition for ‘read.output.type’ -get.da.data.growth: no visible binding for global variable - ‘ensemble.samples’ -get.da.data.growth: no visible binding for global variable ‘sa.samples’ get.da.data.growth : : no visible global function definition for ‘read.output.type’ -pda.load.priors: no visible binding for global variable ‘post.distns’ -pda.load.priors: no visible binding for global variable ‘prior.distns’ -plot.da: no visible binding for global variable ‘y’ -plot.da: no visible binding for global variable ‘ensemble.samples’ -plot.da : : no visible binding for global variable - ‘ensemble.samples’ -plot.da : : no visible binding for global variable - ‘sa.samples’ -plot.da : : no visible binding for global variable ‘m’ Undefined global functions or variables: - ensemble.samples m post.distns prior.distns read.output.type - sa.samples y + read.output.type Found the following assignments to the global environment: File ‘PEcAn.assim.batch/R/pda.get.model.output.R’: @@ -140,9 +71,32 @@ File ‘PEcAn.assim.batch/R/pda.get.model.output.R’: OK * checking for unstated dependencies in vignettes ... OK * checking package vignettes in ‘inst/doc’ ... OK -* checking re-building of vignette outputs ... OK +* checking re-building of vignette outputs ... WARNING +Error(s) in re-building vignettes: + ... +--- re-building ‘AssimBatchVignette.Rmd’ using rmarkdown +Error: processing vignette 'AssimBatchVignette.Rmd' failed with diagnostics: +The function xfun::isFALSE() will be deprecated in the future. Please consider using base::isFALSE(x) or identical(x, FALSE) instead. +--- failed re-building ‘AssimBatchVignette.Rmd’ + +--- re-building ‘MultiSitePDAVignette.Rmd’ using rmarkdown +Error: processing vignette 'MultiSitePDAVignette.Rmd' failed with diagnostics: +The function xfun::isFALSE() will be deprecated in the future. Please consider using base::isFALSE(x) or identical(x, FALSE) instead. +--- failed re-building ‘MultiSitePDAVignette.Rmd’ + +SUMMARY: processing the following files failed: + ‘AssimBatchVignette.Rmd’ ‘MultiSitePDAVignette.Rmd’ + +Error: Vignette re-building failed. +Execution halted + * checking for non-standard things in the check directory ... OK * checking for detritus in the temp directory ... OK * DONE -Status: 2 WARNING, 3 NOTEs +Status: 1 WARNING, 2 NOTEs +See + ‘/tmp/Rtmp0m7lr6/PEcAn.assim.batch.Rcheck/00check.log’ +for details. + + From ebd20c2f82c5a20f517a0c306423a00fc27c934c Mon Sep 17 00:00:00 2001 From: Michael Dietze Date: Wed, 17 Jan 2024 15:38:34 -0500 Subject: [PATCH 3/3] Update modules/assim.batch/tests/Rcheck_reference.log Co-authored-by: Chris Black --- .../assim.batch/tests/Rcheck_reference.log | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/modules/assim.batch/tests/Rcheck_reference.log b/modules/assim.batch/tests/Rcheck_reference.log index 46f8890b1e3..5e4b5185f07 100644 --- a/modules/assim.batch/tests/Rcheck_reference.log +++ b/modules/assim.batch/tests/Rcheck_reference.log @@ -71,25 +71,7 @@ File ‘PEcAn.assim.batch/R/pda.get.model.output.R’: OK * checking for unstated dependencies in vignettes ... OK * checking package vignettes in ‘inst/doc’ ... OK -* checking re-building of vignette outputs ... WARNING -Error(s) in re-building vignettes: - ... ---- re-building ‘AssimBatchVignette.Rmd’ using rmarkdown -Error: processing vignette 'AssimBatchVignette.Rmd' failed with diagnostics: -The function xfun::isFALSE() will be deprecated in the future. Please consider using base::isFALSE(x) or identical(x, FALSE) instead. ---- failed re-building ‘AssimBatchVignette.Rmd’ - ---- re-building ‘MultiSitePDAVignette.Rmd’ using rmarkdown -Error: processing vignette 'MultiSitePDAVignette.Rmd' failed with diagnostics: -The function xfun::isFALSE() will be deprecated in the future. Please consider using base::isFALSE(x) or identical(x, FALSE) instead. ---- failed re-building ‘MultiSitePDAVignette.Rmd’ - -SUMMARY: processing the following files failed: - ‘AssimBatchVignette.Rmd’ ‘MultiSitePDAVignette.Rmd’ - -Error: Vignette re-building failed. -Execution halted - +* checking re-building of vignette outputs ... OK * checking for non-standard things in the check directory ... OK * checking for detritus in the temp directory ... OK * DONE