-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
132a50b
commit a21ca99
Showing
16 changed files
with
164 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Type: Package | ||
Package: r5r | ||
Title: Rapid Realistic Routing with 'R5' | ||
Version: 1.1.0999 | ||
Version: 1.1.0.9000 | ||
Authors@R: c( | ||
person("Marcus", "Saraiva", , "[email protected]", role = "aut", | ||
comment = c(ORCID = "0000-0001-6218-2338")), | ||
|
@@ -34,7 +34,7 @@ Description: Rapid realistic routing on multimodal transport networks | |
<https://docs.conveyal.com/changelog>) corresponds with the R5 version | ||
that r5r depends on. | ||
License: MIT + file LICENSE | ||
URL: https://github.com/ipeaGIT/r5r, https://ipeagit.github.io/r5r/ | ||
URL: https://github.com/ipeaGIT/r5r | ||
BugReports: https://github.com/ipeaGIT/r5r/issues | ||
Depends: | ||
R (>= 3.6) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# initial message about ram memory | ||
.onAttach <- function(lib, pkg) { | ||
packageStartupMessage( | ||
"Please make sure you have already allocated ", | ||
"some memory to Java by running:\n", | ||
" options(java.parameters = '-Xmx2G').\n", | ||
"You should replace '2G' by the amount of memory you'll require. ", | ||
"Currently, Java memory is set to ", getOption("java.parameters") | ||
) | ||
} | ||
|
||
# package global variables | ||
r5r_env <- new.env(parent = emptyenv()) # nocov start | ||
|
||
.onLoad <- function(lib, pkg) { | ||
|
||
# JAR version | ||
r5r_env$r5_jar_version <- "7.0.0" | ||
|
||
# create dir to store R5 Jar | ||
cache_d <- paste0('r5r/r5_jar_v', r5r_env$r5_jar_version) | ||
r5r_env$cache_dir <- tools::R_user_dir(cache_d, which = 'cache') | ||
if (!dir.exists(r5r_env$cache_dir)) dir.create(r5r_env$cache_dir, recursive = TRUE) | ||
# gsub("\\\\", "/", r5r_env$cache_dir) | ||
|
||
## delete any JAR files from old releases | ||
dir_above <- dirname(r5r_env$cache_dir) | ||
all_cache <- list.files(dir_above, pattern = 'r5',full.names = TRUE) | ||
old_cache <- all_cache[!grepl(r5r_env$r5_jar_version, all_cache)] | ||
if(length(old_cache)>0){ unlink(old_cache, recursive = TRUE) } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#' Manage cached files from the r5r package | ||
#' | ||
#' @param list_files Logical. Whether to print a message with the address of r5r | ||
#' JAR files cached locally. Defaults to `TRUE`. | ||
#' @param delete_file String. The file name (basename) of a JAR file cached | ||
#' locally that should be deleted. Defaults to `NULL`, so that no | ||
#' file is deleted. If `delete_file = "all"`, then all cached files are | ||
#' deleted. | ||
#' | ||
#' @return A message indicating which file exist and/or which ones have been | ||
#' deleted from local cache directory. | ||
#' @export | ||
#' @family Cache data | ||
#' @examplesIf identical(tolower(Sys.getenv("NOT_CRAN")), "true") | ||
#' # list all files cached | ||
#' r5r_cache(list_files = TRUE) | ||
#' | ||
#' # delete particular file | ||
#' r5r_cache(delete_file = '2010_deaths') | ||
#' | ||
r5r_cache <- function(list_files = TRUE, | ||
delete_file = NULL){ | ||
|
||
# check inputs | ||
checkmate::assert_logical(list_files) | ||
checkmate::assert_character(delete_file, null.ok = TRUE) | ||
|
||
# find / create local dir | ||
if (!dir.exists(r5r_env$cache_dir)) { dir.create(r5r_env$cache_dir, recursive=TRUE) } | ||
|
||
# list cached files | ||
files <- list.files(dirname(r5r_env$cache_dir), full.names = TRUE) | ||
|
||
# if wants to delete file | ||
# delete_file = "2_families.parquet" | ||
if (!is.null(delete_file)) { | ||
|
||
# IF file does not exist, print message | ||
if (!any(grepl(delete_file, files)) & delete_file != "all") { | ||
message(paste0("The file '", delete_file, "' is not cached.")) | ||
} | ||
|
||
# IF file exists, delete file | ||
if (any(grepl(delete_file, files))) { | ||
f <- files[grepl(delete_file, files)] | ||
unlink(f, recursive = TRUE) | ||
message(paste0("The file '", delete_file, "' has been removed.")) | ||
} | ||
|
||
# Delete ALL file | ||
if (delete_file=='all') { | ||
|
||
# delete any files from censobr, current and old data releases | ||
dir_above <- dirname(r5r_env$cache_dir) | ||
unlink(dir_above, recursive = TRUE) | ||
message(paste0("All files have been removed.")) | ||
|
||
} | ||
} | ||
|
||
# list cached files | ||
files <- list.files(r5r_env$cache_dir, full.names = TRUE) | ||
|
||
# print file names | ||
if(isTRUE(list_files)){ | ||
message('Files currently chached:') | ||
message(paste0(files, collapse = '\n')) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters