Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix check warnings/notes in assim.batch package #3200

Merged
merged 5 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion modules/assim.batch/R/get.da.data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
11 changes: 10 additions & 1 deletion modules/assim.batch/R/get.da.data.growth.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
7 changes: 6 additions & 1 deletion modules/assim.batch/R/pda.utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down
34 changes: 31 additions & 3 deletions modules/assim.batch/R/plot.da.R
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
})

Expand Down
106 changes: 30 additions & 76 deletions modules/assim.batch/tests/Rcheck_reference.log
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>’

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
Expand Down Expand Up @@ -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 : <anonymous>: no visible binding for global variable
‘sa.samples’
get.da.data: no visible binding for global variable ‘sa.samples’
get.da.data : <anonymous>: no visible global function definition for
‘read.output.type’
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required for the PR, but I'm curious what's up with read.output.type and why this one undefined variable was left?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdietze I think I remember this. I was unable to find which package does read.output.type function belong to.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at those functions, I suspect get.da.data.growth.R and get.da.data.R can both be moved from the /R folder to the /inst folder. I don't have time to go through all the code in detail, but I think most of what's here is redundant with newer code by @istfer and others. This code doesn't appear to be operationally linked to other bits of the PDA and the value of retaining this code is primarily because it provides a record of what Carl Davidson did in his (still unpublished) Master thesis.

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 : <anonymous>: 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 : <anonymous>: no visible binding for global variable
‘ensemble.samples’
plot.da : <anonymous>: no visible binding for global variable
‘sa.samples’
plot.da : <anonymous>: 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’:
Expand All @@ -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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that this gets us around the isFalse issue, but I don't feel great about switching a reference log from an OK to a WARNING (the idea of the log was to only move in the direction towards fewer warnings)

...
--- 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
mdietze marked this conversation as resolved.
Show resolved Hide resolved
* 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.


Loading