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

Move arrow to Suggests to appease CRAN #20

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
*.png
*.rec
*.csv
*.Rcheck/*
inst/tools/starvz_fast_csv_split
starvz_*.tar.gz
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

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

CRAN acknowledges this field but doesn't use it. install.packages() does not use it. remotes::install_*() does use it, but pak::pak() does not (yet) 🤷

This PPPM repo is pinned to the current arrow release version. Alternatively, you can instead get the latest pre-release version of arrow by instead using Additional_repositories: https://apache.r-universe.dev/ or Additional_repositories: https://nightlies.apache.org/arrow/r.

6 changes: 1 addition & 5 deletions INSTALL.org
Original file line number Diff line number Diff line change
Expand Up @@ -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++
Expand Down Expand Up @@ -291,16 +291,12 @@ your R session:

#+begin_src R :results output :session :exports both
library(arrow)
arrow_available()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

arrow::CompressionType
#+end_src

Confirm the output is something like this:

#+BEGIN_EXAMPLE
> arrow_available()
[1] TRUE

> arrow::CompressionType
$UNCOMPRESSED
[1] 0
Expand Down
7 changes: 0 additions & 7 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions R/phase1.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions R/phase1_parse_csv.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}

Expand Down
9 changes: 7 additions & 2 deletions R/phase2_util.R
Original file line number Diff line number Diff line change
@@ -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)
}
}

Expand Down
11 changes: 7 additions & 4 deletions R/read_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand All @@ -31,15 +32,16 @@ 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 {
l1 <- list(Origin = directory)
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
Expand All @@ -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",
Expand Down Expand Up @@ -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/",
Expand Down
1 change: 0 additions & 1 deletion R/starvz_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions R/write_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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."))
}
Expand All @@ -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() %>%
Expand All @@ -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."))
}
Expand Down
5 changes: 4 additions & 1 deletion man/panel_st_agg_node.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/starvz_phase1.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/starvz_read.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion tests/testthat/test_lu.R
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

Expand Down
Loading