diff --git a/.gitignore b/.gitignore index 7c4aaab..3ec2540 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ *.png *.rec *.csv +*.Rcheck/* inst/tools/starvz_fast_csv_split +starvz_*.tar.gz diff --git a/DESCRIPTION b/DESCRIPTION index d4cad91..b755391 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -44,14 +44,13 @@ Imports: methods, data.tree, RColorBrewer, zoo, - Rcpp, - arrow (>= 3.0.0) + Rcpp License: GPL-3 Encoding: UTF-8 SystemRequirements: C++, arrow package with gzip codec, StarPU LazyData: true LinkingTo: Rcpp (>= 1.0.6), BH -RoxygenNote: 7.1.1 +RoxygenNote: 7.2.3 Collate: 'RcppExports.R' 'starvz_data.R' @@ -83,9 +82,11 @@ Collate: 'read_functions.R' 'write_functions.R' Suggests: + arrow (>= 3.0.0), testthat, flexmix, car, viridis, ggrepel, mclust +Additional_repositories: https://p3m.dev/cran/2024-02-02 diff --git a/INSTALL.org b/INSTALL.org index 905eec5..771bf04 100644 --- a/INSTALL.org +++ b/INSTALL.org @@ -246,7 +246,7 @@ While the ~arrow~ installation is straightforward in many systems (pre-compiled binaries), it may be hard to obtain an installation with compression support in Debian systems. See [[https://issues.apache.org/jira/browse/ARROW-8556][this link for more information]]. A possible fix is do the following (install everything by -hand [[https://cran.r-project.org/web/packages/arrow/vignettes/install.html][following a combination of these instructions]]). See below for +hand [[https://arrow.apache.org/docs/r/articles/install.html][following a combination of these instructions]]). See below for details. *** Install the Apache Arrow C++ @@ -291,16 +291,12 @@ your R session: #+begin_src R :results output :session :exports both library(arrow) -arrow_available() arrow::CompressionType #+end_src Confirm the output is something like this: #+BEGIN_EXAMPLE -> arrow_available() -[1] TRUE - > arrow::CompressionType $UNCOMPRESSED [1] 0 diff --git a/NAMESPACE b/NAMESPACE index bf2a5f9..6f07d4d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -68,13 +68,6 @@ import(Rcpp) import(dplyr) import(ggplot2) importFrom(RColorBrewer,brewer.pal) -importFrom(arrow,ParquetWriterProperties) -importFrom(arrow,arrow_available) -importFrom(arrow,codec_is_available) -importFrom(arrow,read_feather) -importFrom(arrow,read_parquet) -importFrom(arrow,write_feather) -importFrom(arrow,write_parquet) importFrom(data.tree,Prune) importFrom(data.tree,Set) importFrom(data.tree,as.Node) diff --git a/R/phase1.R b/R/phase1.R index c3ee9c9..7863eda 100644 --- a/R/phase1.R +++ b/R/phase1.R @@ -18,7 +18,7 @@ NULL #' @return ggplot object with all starvz plots #' @family phase1 functions #' -#' @examples +#' @examplesIf requireNamespace("arrow", quietly = TRUE) #' \donttest{ #' example_folder <- system.file("extdata", "lu_trace", package = "starvz") #' starvz_phase1(directory = example_folder) @@ -262,8 +262,9 @@ hl_y_paje_tree <- function(where = ".") { entities.csv <- paste0(where, "/entities.csv") if (file.exists(entities.feather)) { + check_arrow() starvz_log(paste("Reading ", entities.feather)) - dfe <- read_feather(entities.feather) + dfe <- arrow::read_feather(entities.feather) } else if (file.exists(entities.csv)) { starvz_log(paste("Reading ", entities.csv)) dfe <- starvz_suppressWarnings(read_csv(entities.csv, diff --git a/R/phase1_parse_csv.R b/R/phase1_parse_csv.R index 65173e2..7f862bc 100644 --- a/R/phase1_parse_csv.R +++ b/R/phase1_parse_csv.R @@ -626,8 +626,9 @@ pmtool_bounds_csv_parser <- function(where = ".", ZERO = 0) { entities.csv <- paste0(where, "/pmtool.csv") if (file.exists(entities.feather)) { + check_arrow() starvz_log(paste("Reading ", entities.feather)) - pm <- read_feather(entities.feather) + pm <- arrow::read_feather(entities.feather) } else if (file.exists(entities.csv)) { starvz_log(paste("Reading ", entities.csv)) pm <- starvz_suppressWarnings(read_csv(entities.csv, @@ -795,8 +796,9 @@ task_handles_parser <- function(where = ".") { entities.feather <- paste0(where, "/task_handles.feather") if (file.exists(entities.feather)) { + check_arrow() starvz_log(paste("Reading ", entities.feather)) - ret <- read_feather(entities.feather) + ret <- arrow::read_feather(entities.feather) return(ret) } diff --git a/R/phase2_util.R b/R/phase2_util.R index 9527253..0f4c832 100644 --- a/R/phase2_util.R +++ b/R/phase2_util.R @@ -1,8 +1,13 @@ #' @include starvz_data.R check_arrow <- function() { - if (!arrow_available()) { - starvz_warn("R package arrow was not property installed, use: install_arrow()") + if (!requireNamespace("arrow", quietly = TRUE)) { + msg <- paste( + "The 'arrow' package is required but is not available. Install it with:", + 'install.packages("arrow", repos = c("https://p3m.dev/cran/2024-02-02", getOption("repos")))', + sep = "\n" + ) + stop(msg, call. = FALSE) } } diff --git a/R/read_functions.R b/R/read_functions.R index 57e2af5..ff24a2a 100644 --- a/R/read_functions.R +++ b/R/read_functions.R @@ -5,7 +5,7 @@ starvz_read_some_feather <- function(directory = ".", tables = c("application")) l2 <- lapply(tables, function(table) { table_file <- file.path(directory, paste0(table, ".feather")) if (file.exists(table_file)) { - read_parquet(table_file) + arrow::read_parquet(table_file) } else { starvz_log(paste("The file:", table_file, " does not exist on that directory. Ignore.")) NULL @@ -16,6 +16,7 @@ starvz_read_some_feather <- function(directory = ".", tables = c("application")) } starvz_read_feather <- function(directory = ".") { + check_arrow() filenames <- list.files( path = directory, pattern = "*.feather", @@ -31,7 +32,8 @@ starvz_read_feather <- function(directory = ".") { the_fast_reader_function <- starvz_read_feather starvz_read_some_parquet <- function(directory = ".", tables = c("application")) { - if (!codec_is_available("gzip")) { + check_arrow() + if (!arrow::codec_is_available("gzip")) { starvz_warn("R package arrow does not have 'gzip' codec, try using arrow::install_arrow()") return(list()) } else { @@ -39,7 +41,7 @@ starvz_read_some_parquet <- function(directory = ".", tables = c("application")) l2 <- lapply(tables, function(table) { table_file <- file.path(directory, paste0(table, ".parquet")) if (file.exists(table_file)) { - read_parquet(table_file) + arrow::read_parquet(table_file) } else { starvz_log(paste("The file:", table_file, " does not exist on that directory. Ignore.")) NULL @@ -51,6 +53,7 @@ starvz_read_some_parquet <- function(directory = ".", tables = c("application")) } starvz_read_parquet <- function(directory = ".") { + check_arrow() filenames <- list.files( path = directory, pattern = "*.parquet", @@ -99,7 +102,7 @@ starvz_read_some <- function(directory = ".", tables = c("application"), config_ #' @return The starvz_data with all tables #' @usage starvz_read(directory = ".", #' config_file = NULL, selective = TRUE) -#' @examples +#' @examplesIf requireNamespace("arrow", quietly = TRUE) #' starvz_read("folder_to_parquet_files/") #' starvz_read( #' directory = "folder_to_parquet_files/", diff --git a/R/starvz_data.R b/R/starvz_data.R index 2cbb452..7de44fb 100644 --- a/R/starvz_data.R +++ b/R/starvz_data.R @@ -16,7 +16,6 @@ #' @importFrom stringr str_replace str_replace_all str_to_title #' @importFrom purrr list_modify map map2 #' @importFrom patchwork wrap_plots -#' @importFrom arrow arrow_available read_feather read_parquet write_feather write_parquet codec_is_available ParquetWriterProperties #' @importFrom lpSolve lp #' @importFrom data.tree as.Node Prune Set #' @importFrom gtools mixedorder mixedsort diff --git a/R/write_functions.R b/R/write_functions.R index 589149b..ddc17c2 100644 --- a/R/write_functions.R +++ b/R/write_functions.R @@ -8,7 +8,7 @@ starvz_write_feather <- function(data, directory = ".") { starvz_log(filename) if (!is.null(data[[x]])) { if (is.data.frame(data[[x]])) { - write_feather(data[[x]], filename) + arrow::write_feather(data[[x]], filename) } else { starvz_log(paste(filename, "must be a data frame.")) } @@ -23,7 +23,7 @@ starvz_write_parquet <- function(data, directory = ".") { if (is.null(data)) { return(NULL) } - if (!codec_is_available("gzip")) { + if (!arrow::codec_is_available("gzip")) { starvz_warn("R package arrow does not have 'gzip' codec, try using arrow::install_arrow()") } else { invisible(data %>% list_modify("Origin" = NULL) %>% names() %>% @@ -32,7 +32,7 @@ starvz_write_parquet <- function(data, directory = ".") { starvz_log(filename) if (!is.null(data[[x]])) { if (is.data.frame(data[[x]])) { - write_parquet(data[[x]], filename, compression = "gzip") + arrow::write_parquet(data[[x]], filename, compression = "gzip") } else { starvz_log(paste(filename, "must be a data frame.")) } diff --git a/man/panel_st_agg_node.Rd b/man/panel_st_agg_node.Rd index bae57e9..d53dde6 100644 --- a/man/panel_st_agg_node.Rd +++ b/man/panel_st_agg_node.Rd @@ -9,7 +9,8 @@ panel_st_agg_node( x_start = data$config$limits$start, x_end = data$config$limits$end, step = data$config$st$aggregation$step, - legend = data$config$st$legend + legend = data$config$st$legend, + selected_nodes = data$config$selected_nodes ) } \arguments{ @@ -22,6 +23,8 @@ panel_st_agg_node( \item{step}{time-step} \item{legend}{option to activate legend} + +\item{selected_nodes}{select only some nodes in some plots} } \value{ A ggplot object diff --git a/man/starvz_phase1.Rd b/man/starvz_phase1.Rd index d27886b..578ddb7 100644 --- a/man/starvz_phase1.Rd +++ b/man/starvz_phase1.Rd @@ -37,9 +37,11 @@ shell tool \code{starvz} or \code{phase1-workflow.sh} in the \code{tools/} directory. } \examples{ +\dontshow{if (requireNamespace("arrow", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} \donttest{ example_folder <- system.file("extdata", "lu_trace", package = "starvz") starvz_phase1(directory = example_folder) } +\dontshow{\}) # examplesIf} } \concept{phase1 functions} diff --git a/man/starvz_read.Rd b/man/starvz_read.Rd index d105ef7..eb01b99 100644 --- a/man/starvz_read.Rd +++ b/man/starvz_read.Rd @@ -24,10 +24,12 @@ and the configuration file, and return a starvz_data class used in starvz functions } \examples{ +\dontshow{if (requireNamespace("arrow", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} starvz_read("folder_to_parquet_files/") starvz_read( directory = "folder_to_parquet_files/", config_file = "path_to_config.yaml" ) starvz_read() # Read current directory +\dontshow{\}) # examplesIf} } diff --git a/tests/testthat/test_lu.R b/tests/testthat/test_lu.R index a9d90c4..4ce92af 100644 --- a/tests/testthat/test_lu.R +++ b/tests/testthat/test_lu.R @@ -8,6 +8,7 @@ test_that("starvz_plot works", { expect_equal(class(pl), c("patchwork", "gg", "ggplot")) skip_on_cran() + skip_if_not_installed("arrow") other_data <- starvz_sample_lu @@ -49,7 +50,7 @@ test_that("starvz_plot works", { other_data <- starvz_phase1(system.file("extdata", "lu_trace", package = "starvz"), lu_colors, state_filter = 2, whichApplication = "lu") other_data <- starvz_read(system.file("extdata", "lu_trace", package = "starvz"), system.file("extdata", "config.yaml", package = "starvz")) result <- all.equal(nrow(other_data$Application), nrow(starvz_sample_lu$Application)) - if (codec_is_available("gzip")) { + if (arrow::codec_is_available("gzip")) { expect_equal(result, TRUE) }