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

recording failed tests here that only happen on GitHub Actions. Odd thing is that these test pass on local checks #363

Open
DanWismer opened this issue May 8, 2024 · 23 comments
Labels
bug Something isn't working

Comments

@DanWismer
Copy link
Contributor

DanWismer commented May 8, 2024

image

@DanWismer DanWismer added the bug Something isn't working label May 8, 2024
@DanWismer DanWismer changed the title recording failed tests here that only happen on HitHub Actions. Odd thing is that these test past on local checks recording failed tests here that only happen on GitHub Actions. Odd thing is that these test pass on local checks May 8, 2024
@DanWismer
Copy link
Contributor Author

image

@DanWismer
Copy link
Contributor Author

image

@DanWismer
Copy link
Contributor Author

image

@DanWismer
Copy link
Contributor Author

DanWismer commented Sep 10, 2024

@jeffreyhanson any idea on this?
image

Should I just add testthat here ?

install.packages(c("renv", "remotes"))

Wondering how it worked before? Never had this problem.

image

@jeffreyhanson
Copy link
Contributor

Yeah that's weird. Is listed testthat in Suggests part of the DESCRIPTION?

@jeffreyhanson
Copy link
Contributor

Hmm, also check if it's installed in renv?

@DanWismer
Copy link
Contributor Author

Its not in the rene.lock file.

I tried renv::instal("testthat") and then renv::snapshot(), however it says the the lockfile is up to date. I think because it is not used in the application code the new version of renv can't pick it up?

We have it listed in the Suggests part of the Description

@jeffreyhanson
Copy link
Contributor

Hmm, maybe try renv::snapshot(type="explicit") to capture those in the DESCRTION file?

@DanWismer
Copy link
Contributor Author

I tried that, no dice.

I am reading this:
rstudio/renv#1019

@DanWismer
Copy link
Contributor Author

Maybe?
rstudio/renv#315

@DanWismer
Copy link
Contributor Author

DanWismer commented Sep 10, 2024

so I did renv::snapshot(dev=TRUE) which will included the suggested packages into the renv.lock.

However now it says that the project is out of sync because the following packages are installed, recorded but not used...
image

@DanWismer
Copy link
Contributor Author

I see that renv doesn't capture dependencies in the testthat folder. It considers testthat as separate from the core project.

I ran renv::dependencies(path = "tests/testthat") and see that these packages are being used, where some are found in the main code base which is fine, but others are only found in the Sugests.

  • RColorBrewer (Import)
  • viridisLite (Import)
  • terra (Import)
  • tibble (Import)
  • dplyr (Import)
  • golem (Import)
  • processx (Suggests)
  • cachem (Import)
  • scales (Import)
  • prioritizr (Import)
  • sf (Depends)
  • leaflet (Import)
  • xml2 (Suggests)
  • rvest (Suggests)

@DanWismer
Copy link
Contributor Author

@jeffreyhanson I am getting a weird faliure when it trys to install igraph:
image

I found out where it is called:

reserve_sizes <- function(x, areas, boundary_matrix) {
# assert the argument are valid
assertthat::assert_that(
## x
is.numeric(x),
assertthat::noNA(x),
## areas
is.numeric(areas),
assertthat::noNA(areas),
length(areas) == length(x),
## boundary matrix
inherits(boundary_matrix, c("dsCMatrix", "dgCMatrix", "logical")))
if (inherits(boundary_matrix, c("dsCMatrix", "dgCMatrix"))) {
assertthat::assert_that(
nrow(boundary_matrix) == ncol(boundary_matrix),
nrow(boundary_matrix) == length(x)
)
}
# return NA if boundary_matrix is NA
if (!inherits(boundary_matrix, c("dsCMatrix", "dgCMatrix"))) {
return(NA_real_)
}
# return NA if no planning units selected, then return NA
if (sum(x) < 0.5) {
return(NA_real_)
}
# create adjacency matrix to describe relationships among units
idx <- which(x > 0.5)
adj_matrix <- boundary_matrix[idx, idx]
adj_matrix@x <- rep(1, length(adj_matrix@x))
Matrix::diag(adj_matrix) <- 1
# subset areas to contain only selected planning units
areas <- areas[idx]
# create graph
g <- igraph::graph_from_adjacency_matrix(adj_matrix, mode = "undirected")
# identify components
clu <- igraph::components(g)
# calculate total size of each reserve
vapply(seq_len(clu$no), FUN.VALUE = numeric(1), function(i) {
sum(areas[clu$membership == i])
})
}

I am wondering if you have a new / different way to calculate reserve sizes, without the need to use igraph?

@jeffreyhanson
Copy link
Contributor

jeffreyhanson commented Sep 11, 2024

Hmm, that's odd. Yeah, you could potentially use the sf package instead of igraph - but that will slow down performance a lot. I would suggest trying to work out why it's failing. The error message suggests that something is going wrong with the C/C++ compiled part of the package (since it's complaining about a DLL file). Looking at the compilation flags in the raw logs, we can see compilation of the igraph package depends on the cpp11 package (e.g., see I'D:/a/wheretowork/wheretowork/renv/staging/1/cpp11/include). In particular cpp11 is an R package for helping to write C++ code that interfaces with R (see https://cpp11.r-lib.org/). Could you try updating cpp11 in renv to the latest version?

@DanWismer
Copy link
Contributor Author

Thanks, I see that cpp11 R package updated at the end of August. I updated to the latest 0.5 version and will see it that works.

@DanWismer
Copy link
Contributor Author

Darn, still errors at the same spot. But only for Windows build

@jeffreyhanson
Copy link
Contributor

Hmm, maybe the issue is one of its other dependencies?

@DanWismer
Copy link
Contributor Author

I got it to pass on Windows!

in the igraph 2.0.3 NEWS, GMP is no longer a dependency, and libxml2 and glpk are optional.

I removed those from the R-CMD-check-windows.yaml script:
d6513ac

I didn't see these system dependecies for Ubuntu or in the Dockerfile. @jeffreyhanson would you know why?

@jeffreyhanson
Copy link
Contributor

Ah - nice work tracking that down! No idea why having those dependencies present would cause issues.

@DanWismer
Copy link
Contributor Author

This still happens randomly:
image

@DanWismer
Copy link
Contributor Author

DanWismer commented Sep 13, 2024

I think all these random fails have to do with the string encodings?

Maybe this:

# coerce characters to ASCII
params <- enc2ascii(params)

The random tests fail when simulated WTW data is generated, then saved using write_project. And then read using read_project.

It says that there is NULL in x$ which is weird.

@DanWismer
Copy link
Contributor Author

image
can not subset columns that don't exists

@jeffreyhanson
Copy link
Contributor

Yeah, that's odd - no idea what's going wrong here sorry. To help with debugging this, you could throw error messages that describe the contexts of x. E.g., something like: stop(names(x)) or stop(length(x))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants