Skip to content

Commit

Permalink
Merge pull request PecanProject#3222 from moki1202/fix_data_remote
Browse files Browse the repository at this point in the history
fix warnings/notes in data.remote package
  • Loading branch information
mdietze authored Nov 6, 2023
2 parents f3d4f47 + 301903d commit b344c8e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 90 deletions.
11 changes: 5 additions & 6 deletions modules/data.remote/R/NLCD.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ download.NLCD <- function(outdir, year = 2011, con = NULL) {

## before downloading, check if the file already exists on this host
if (!is.null(con)) {

chk <- dbfile.check(type = "Input", id = input.id, con = con)
chk <- PEcAn.DB::dbfile.check(type = "Input", id = input.id, con = con)
if (nrow(chk) > 0) {
machines <- db.query(paste("SELECT * from machines where id in (",
machines <- PEcAn.DB::db.query(paste("SELECT * from machines where id in (",
paste(chk$machine_id, sep = ","), ")"), con)
if (PEcAn.remote::fqdn() %in% machines$hostname) {
## record already exists on this host
Expand All @@ -49,7 +48,7 @@ download.NLCD <- function(outdir, year = 2011, con = NULL) {
prefix <- table(sapply(strsplit(dir(data_dir), ".", fixed = TRUE), function(x) { x[1] }))
prefix <- names(which.max(prefix))
site.id <- 1000000676
return(dbfile.insert(data_dir, in.prefix = prefix, type = "Input", input.id, con,
return(PEcAn.DB::dbfile.insert(data_dir, in.prefix = prefix, type = "Input", input.id, con,
reuse = TRUE))
}
return(data_dir)
Expand Down Expand Up @@ -78,9 +77,9 @@ extract_NLCD <- function(buffer, coords, data_dir = NULL, con = NULL, year = 201
} else {
print(paste("Year not yet supported: ", year))
}
chk <- dbfile.check(type = "Input", id = input.id, con = con)
chk <- PEcAn.DB::dbfile.check(type = "Input", id = input.id, con = con)
if (nrow(chk) > 0) {
machines <- db.query(paste("SELECT * from machines where id in (",
machines <- PEcAn.DB::db.query(paste("SELECT * from machines where id in (",
paste(chk$machine_id, sep = ","), ")"), con)
if (PEcAn.remote::fqdn() %in% machines$hostname) {
## record already exists on this host
Expand Down
2 changes: 1 addition & 1 deletion modules/data.remote/R/call_MODIS.R
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ call_MODIS <- function(var, product,
fname <- paste(site_info$site_id[i], "/", product, "_", band, "_", start_date, "-", end_date, "_unfiltered.csv", sep = "")
}
fname <- file.path(outdir, fname)
write.csv(site, fname, row.names = FALSE)
utils::write.csv(site, fname, row.names = FALSE)
}

}
Expand Down
6 changes: 3 additions & 3 deletions modules/data.remote/R/download.thredds.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ download.thredds.AGB <- function(outdir = NULL, site_ids, run_parallel = FALSE,
# option to save output dataset to directory for user.
if (!(is.null(outdir)))
{
write.csv(output, file = paste0(outdir, "THREDDS_", sub("^([^.]*).*", "\\1",basename(files[1])), "_site_", site, ".csv"), row.names = FALSE)
utils::write.csv(output, file = paste0(outdir, "THREDDS_", sub("^([^.]*).*", "\\1",basename(files[1])), "_site_", site, ".csv"), row.names = FALSE)
}

return(output)
Expand All @@ -86,8 +86,8 @@ download.thredds.AGB <- function(outdir = NULL, site_ids, run_parallel = FALSE,
PEcAn.logger::logger.info(paste0("Running in parallel with: ", ncores))
cl = parallel::makeCluster(ncores)
doParallel::registerDoParallel(cl)
data = foreach(i = seq_along(mylat), .combine = rbind) %dopar% get_data(i)
stopCluster(cl)
data = foreach::foreach(i = seq_along(mylat), .combine = rbind) %dopar% get_data(i)
parallel::stopCluster(cl)

} else {
# setup sequential run
Expand Down
93 changes: 13 additions & 80 deletions modules/data.remote/tests/Rcheck_reference.log
Original file line number Diff line number Diff line change
@@ -1,55 +1,12 @@
* using log directory ‘/home/tanishq010/pecan/modules/PEcAn.data.remote.Rcheck’
* using R version 4.2.1 (2022-06-23)
* using log directory ‘/tmp/Rtmpr2UgRH/PEcAn.data.remote.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-tests --no-manual --as-cran’
* using options ‘--no-manual --as-cran’
* checking for file ‘PEcAn.data.remote/DESCRIPTION’ ... OK
* checking extension type ... Package
* this is package ‘PEcAn.data.remote’ version ‘1.7.2.9000’
* package encoding: UTF-8
* checking CRAN incoming feasibility ... WARNING
Maintainer: ‘Bailey Morrison <[email protected]>’

New submission

Version contains large components (1.7.2.9000)

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.DB, PEcAn.utils, PEcAn.logger, PEcAn.remote

The Date field is over a month old.
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
Expand All @@ -63,11 +20,7 @@ The Date field is over a month old.
* checking installed package size ... OK
* checking package directory ... OK
* checking for future file timestamps ... OK
* checking DESCRIPTION meta-information ... NOTE
Author field differs from that derived from Authors@R
Author: ‘Mike Dietze, Bailey Morrison’
Authors@R: ‘Mike Dietze [aut], Bailey Morrison [aut, cre], University of Illinois, NCSA [cph]’

* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking for left-over files ... OK
* checking index information ... OK
Expand All @@ -80,47 +33,22 @@ Author field differs from that derived from Authors@R
* 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 ... WARNING
'library' or 'require' calls in package code:
‘PEcAn.DB’ ‘doParallel’ ‘raster’ ‘rgdal’
Please use :: or requireNamespace() instead.
See section 'Suggested packages' in the 'Writing R Extensions' manual.
Namespace in Imports field not imported from: ‘stringr’
All declared Imports should be used.
Missing or unexported objects:
‘PEcAn.utils::download_file’ ‘PEcAn.utils::need_packages’
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... NOTE
call_MODIS: no visible global function definition for ‘write.csv’
download.LandTrendr.AGB: no visible binding for global variable ‘k’
download.NLCD: no visible global function definition for ‘dbfile.check’
download.NLCD: no visible global function definition for ‘db.query’
download.NLCD: no visible global function definition for
‘dbfile.insert’
download.thredds.AGB : get_data: no visible global function definition
for ‘write.csv’
download.thredds.AGB: no visible global function definition for
‘foreach’
download.thredds.AGB: no visible global function definition for
‘stopCluster’
extract_NLCD: no visible global function definition for ‘dbfile.check’
extract_NLCD: no visible global function definition for ‘db.query’
extract_NLCD: no visible global function definition for ‘raster’
extract_NLCD: no visible global function definition for ‘SpatialPoints’
extract_NLCD: no visible global function definition for ‘CRS’
extract_NLCD: no visible global function definition for ‘spTransform’
extract_NLCD: no visible global function definition for ‘crs’
extract_NLCD: no visible global function definition for ‘extract’
grid2netcdf: no visible binding for global variable ‘years’
grid2netcdf: no visible binding for global variable ‘yieldarray’
Undefined global functions or variables:
CRS SpatialPoints crs db.query dbfile.check dbfile.insert
download.file extract foreach k raster spTransform stopCluster
write.csv
Consider adding
importFrom("utils", "download.file", "write.csv")
to your NAMESPACE file.
k years yieldarray
* checking Rd files ... OK
* checking Rd metadata ... OK
* checking Rd line widths ... OK
Expand All @@ -146,4 +74,9 @@ Extensions’ manual.
* checking for detritus in the temp directory ... OK
* DONE

Status: 3 WARNINGs, 2 NOTEs
Status: 2 WARNINGs, 1 NOTE
See
‘/tmp/Rtmpr2UgRH/PEcAn.data.remote.Rcheck/00check.log’
for details.


0 comments on commit b344c8e

Please sign in to comment.