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

bump to dev; fix tests for hubUtils 0.2.0 #61

Merged
merged 6 commits into from
Oct 31, 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
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: hubData
Title: Tools for accessing and working with hubverse data
Version: 1.2.3
Version: 1.2.3.9000
Authors@R:
c(person("Anna", "Krystalli", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-2378-4915")),
Expand Down Expand Up @@ -45,7 +45,8 @@ Suggests:
knitr,
mockery,
rmarkdown,
testthat (>= 3.2.0)
testthat (>= 3.2.0),
withr
Remotes:
hubverse-org/hubUtils
Config/Needs/website: hubverse-org/hubStyle
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# hubData (development version)

# hubData 1.2.3

* Fix bug in `create_hub_schema()` where `output_type_id` data type was being incorrectly determined as `Date` instead of `character` (Reported in https://github.com/reichlab/variant-nowcast-hub/pull/87#issuecomment-2387372238).
Expand Down
60 changes: 54 additions & 6 deletions tests/testthat/_snaps/hub-connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
.. .. ..$ model_type: chr "baseline"
..$ file_format : chr [1:3] "csv" "parquet" "arrow"
..$ timezone : chr "US/Eastern"
..- attr(*, "schema_id")= chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/admin-schema.json"
..- attr(*, "type")= chr "admin"
..- attr(*, "class")= chr [1:2] "config" "list"
- attr(*, "config_tasks")=List of 2
..$ schema_version: chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/tasks-schema.json"
..$ rounds :List of 2
Expand Down Expand Up @@ -147,6 +150,9 @@
.. .. .. ..$ relative_to: chr "origin_date"
.. .. .. ..$ start : int -6
.. .. .. ..$ end : int 1
..- attr(*, "schema_id")= chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/tasks-schema.json"
..- attr(*, "type")= chr "tasks"
..- attr(*, "class")= chr [1:2] "config" "list"

# connect_hub works on a local simple forecasting hub with no csvs

Expand Down Expand Up @@ -200,6 +206,9 @@
.. .. ..$ model_type: chr "baseline"
..$ file_format : chr [1:3] "csv" "parquet" "arrow"
..$ timezone : chr "US/Eastern"
..- attr(*, "schema_id")= chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/admin-schema.json"
..- attr(*, "type")= chr "admin"
..- attr(*, "class")= chr [1:2] "config" "list"
- attr(*, "config_tasks")=List of 2
..$ schema_version: chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/tasks-schema.json"
..$ rounds :List of 2
Expand Down Expand Up @@ -300,6 +309,9 @@
.. .. .. ..$ relative_to: chr "origin_date"
.. .. .. ..$ start : int -6
.. .. .. ..$ end : int 1
..- attr(*, "schema_id")= chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/tasks-schema.json"
..- attr(*, "type")= chr "tasks"
..- attr(*, "class")= chr [1:2] "config" "list"

# connect_hub returns empty list when model output folder is empty

Expand Down Expand Up @@ -395,6 +407,9 @@
..$ file_format : chr [1:3] "csv" "parquet" "arrow"
..$ timezone : chr "US/Eastern"
..$ model_output_dir: chr "forecasts"
..- attr(*, "schema_id")= chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/admin-schema.json"
..- attr(*, "type")= chr "admin"
..- attr(*, "class")= chr [1:2] "config" "list"
- attr(*, "config_tasks")=List of 2
..$ schema_version: chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/tasks-schema.json"
..$ rounds :List of 1
Expand Down Expand Up @@ -480,6 +495,9 @@
.. .. .. ..$ relative_to: chr "forecast_date"
.. .. .. ..$ start : int -6
.. .. .. ..$ end : int 2
..- attr(*, "schema_id")= chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/tasks-schema.json"
..- attr(*, "type")= chr "tasks"
..- attr(*, "class")= chr [1:2] "config" "list"

---

Expand Down Expand Up @@ -542,6 +560,9 @@
..$ file_format : chr [1:3] "csv" "parquet" "arrow"
..$ timezone : chr "US/Eastern"
..$ model_output_dir: chr "forecasts"
..- attr(*, "schema_id")= chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/admin-schema.json"
..- attr(*, "type")= chr "admin"
..- attr(*, "class")= chr [1:2] "config" "list"
- attr(*, "config_tasks")=List of 2
..$ schema_version: chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/tasks-schema.json"
..$ rounds :List of 1
Expand Down Expand Up @@ -627,6 +648,9 @@
.. .. .. ..$ relative_to: chr "forecast_date"
.. .. .. ..$ start : int -6
.. .. .. ..$ end : int 2
..- attr(*, "schema_id")= chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/tasks-schema.json"
..- attr(*, "type")= chr "tasks"
..- attr(*, "class")= chr [1:2] "config" "list"

# connect_model_output works on local model_output_dir

Expand Down Expand Up @@ -853,6 +877,9 @@
.. .. ..$ model_type: chr "baseline"
..$ file_format : chr [1:3] "csv" "parquet" "arrow"
..$ timezone : chr "US/Eastern"
..- attr(*, "schema_id")= chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/admin-schema.json"
..- attr(*, "type")= chr "admin"
..- attr(*, "class")= chr [1:2] "config" "list"
- attr(*, "config_tasks")=List of 2
..$ schema_version: chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/tasks-schema.json"
..$ rounds :List of 2
Expand Down Expand Up @@ -953,6 +980,9 @@
.. .. .. ..$ relative_to: chr "origin_date"
.. .. .. ..$ start : int -6
.. .. .. ..$ end : int 1
..- attr(*, "schema_id")= chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/tasks-schema.json"
..- attr(*, "type")= chr "tasks"
..- attr(*, "class")= chr [1:2] "config" "list"

# mod_out_connection print method works

Expand Down Expand Up @@ -1065,7 +1095,7 @@
- attr(*, "hub_path")= chr "test/hub_path"
- attr(*, "model_output_dir")= chr "test/model_output_dir"
- attr(*, "config_admin")=List of 8
..$ schema_version: chr "https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v2.0.0/admin-schema.json"
..$ schema_version: chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/admin-schema.json"
..$ name : chr "Simple Forecast Hub"
..$ maintainer : chr "Consortium of Infectious Disease Modeling Hubs"
..$ contact :List of 2
Expand All @@ -1079,8 +1109,11 @@
.. .. ..$ model_type: chr "baseline"
..$ file_format : chr [1:3] "csv" "parquet" "arrow"
..$ timezone : chr "US/Eastern"
..- attr(*, "schema_id")= chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/admin-schema.json"
..- attr(*, "type")= chr "admin"
..- attr(*, "class")= chr [1:2] "config" "list"
- attr(*, "config_tasks")=List of 2
..$ schema_version: chr "https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v2.0.0/tasks-schema.json"
..$ schema_version: chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/tasks-schema.json"
..$ rounds :List of 2
.. ..$ :List of 4
.. .. ..$ round_id_from_variable: logi TRUE
Expand Down Expand Up @@ -1179,6 +1212,9 @@
.. .. .. ..$ relative_to: chr "origin_date"
.. .. .. ..$ start : int -6
.. .. .. ..$ end : int 1
..- attr(*, "schema_id")= chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/tasks-schema.json"
..- attr(*, "type")= chr "tasks"
..- attr(*, "class")= chr [1:2] "config" "list"

---

Expand Down Expand Up @@ -1235,7 +1271,7 @@
- attr(*, "hub_path")= chr "test/hub_path"
- attr(*, "model_output_dir")= chr "test/model_output_dir"
- attr(*, "config_admin")=List of 8
..$ schema_version: chr "https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v2.0.0/admin-schema.json"
..$ schema_version: chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/admin-schema.json"
..$ name : chr "Simple Forecast Hub"
..$ maintainer : chr "Consortium of Infectious Disease Modeling Hubs"
..$ contact :List of 2
Expand All @@ -1249,8 +1285,11 @@
.. .. ..$ model_type: chr "baseline"
..$ file_format : chr [1:3] "csv" "parquet" "arrow"
..$ timezone : chr "US/Eastern"
..- attr(*, "schema_id")= chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/admin-schema.json"
..- attr(*, "type")= chr "admin"
..- attr(*, "class")= chr [1:2] "config" "list"
- attr(*, "config_tasks")=List of 2
..$ schema_version: chr "https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v2.0.0/tasks-schema.json"
..$ schema_version: chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/tasks-schema.json"
..$ rounds :List of 2
.. ..$ :List of 4
.. .. ..$ round_id_from_variable: logi TRUE
Expand Down Expand Up @@ -1349,6 +1388,9 @@
.. .. .. ..$ relative_to: chr "origin_date"
.. .. .. ..$ start : int -6
.. .. .. ..$ end : int 1
..- attr(*, "schema_id")= chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/tasks-schema.json"
..- attr(*, "type")= chr "tasks"
..- attr(*, "class")= chr [1:2] "config" "list"

---

Expand Down Expand Up @@ -1436,7 +1478,7 @@
- attr(*, "hub_path")= chr "test/hub_path"
- attr(*, "model_output_dir")= chr "test/model_output_dir"
- attr(*, "config_admin")=List of 8
..$ schema_version: chr "https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v2.0.0/admin-schema.json"
..$ schema_version: chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/admin-schema.json"
..$ name : chr "Simple Forecast Hub"
..$ maintainer : chr "Consortium of Infectious Disease Modeling Hubs"
..$ contact :List of 2
Expand All @@ -1450,8 +1492,11 @@
.. .. ..$ model_type: chr "baseline"
..$ file_format : chr [1:3] "csv" "parquet" "arrow"
..$ timezone : chr "US/Eastern"
..- attr(*, "schema_id")= chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/admin-schema.json"
..- attr(*, "type")= chr "admin"
..- attr(*, "class")= chr [1:2] "config" "list"
- attr(*, "config_tasks")=List of 2
..$ schema_version: chr "https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v2.0.0/tasks-schema.json"
..$ schema_version: chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/tasks-schema.json"
..$ rounds :List of 2
.. ..$ :List of 4
.. .. ..$ round_id_from_variable: logi TRUE
Expand Down Expand Up @@ -1550,6 +1595,9 @@
.. .. .. ..$ relative_to: chr "origin_date"
.. .. .. ..$ start : int -6
.. .. .. ..$ end : int 1
..- attr(*, "schema_id")= chr "https://raw.githubusercontent.com/hubverse-org/schemas/main/v2.0.0/tasks-schema.json"
..- attr(*, "type")= chr "tasks"
..- attr(*, "class")= chr [1:2] "config" "list"

---

Expand Down
38 changes: 29 additions & 9 deletions tests/testthat/test-hub-connection.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,33 @@ test_that("connect_hub works on a local simple forecasting hub with no csvs", {
test_that("connect_hub returns empty list when model output folder is empty", {
# Local
hub_path <- system.file("testhubs/empty", package = "hubUtils")
expect_warning(connect_hub(hub_path))
hub_con <- suppressWarnings(connect_hub(hub_path))
suppressWarnings({
expect_warning(hub_con <- connect_hub(hub_path), "No files of file formats")
})
attr(hub_con, "model_output_dir") <- "test/model_output_dir"
attr(hub_con, "hub_path") <- "test/hub_path"
expect_snapshot(hub_con)

# S3
hub_path <- s3_bucket("hubverse/hubutils/testhubs/empty/")
hub_con <- suppressWarnings(connect_hub(hub_path))
suppressWarnings({
suppressMessages({
expect_message(hub_con <- connect_hub(hub_path), "superseded URL")
})
})
attr(hub_con, "model_output_dir") <- "test/model_output_dir"
attr(hub_con, "hub_path") <- "test/hub_path"
expect_snapshot(hub_con)

# S3, skip_checks is TRUE
hub_path <- s3_bucket("hubverse/hubutils/testhubs/empty/")
hub_con <- suppressWarnings(connect_hub(hub_path, skip_checks = TRUE))
suppressWarnings({
suppressMessages({
expect_message(hub_con <- connect_hub(hub_path, skip_checks = TRUE),
"superseded URL"
)
})
})
attr(hub_con, "model_output_dir") <- "test/model_output_dir"
attr(hub_con, "hub_path") <- "test/hub_path"
expect_snapshot(hub_con)
Expand Down Expand Up @@ -309,7 +320,6 @@ test_that("connect_hub data extraction works on simple forecasting hub", {
hub_path <- system.file("testhubs/simple", package = "hubUtils")
hub_con <- connect_hub(hub_path)

suppressMessages(library(dplyr))
expect_snapshot(hub_con %>%
dplyr::filter(
origin_date == "2022-10-08",
Expand Down Expand Up @@ -345,7 +355,9 @@ test_that("connect_hub works on S3 bucket simple forecasting hub on AWS", {
# Simple forecasting Hub example ----

hub_path <- s3_bucket("hubverse/hubutils/testhubs/simple/")
hub_con <- connect_hub(hub_path)
suppressMessages({
expect_message(hub_con <- connect_hub(hub_path), "superseded URL")
zkamvar marked this conversation as resolved.
Show resolved Hide resolved
})

# Tests that paths are assigned to attributes correctly
expect_equal(
Expand Down Expand Up @@ -388,7 +400,11 @@ test_that("connect_hub works on S3 bucket simple parquet forecasting hub on AWS"
# Simple forecasting Hub example ----

hub_path <- s3_bucket("hubverse/hubutils/testhubs/parquet/")
hub_con <- connect_hub(hub_path, file_format = "parquet")
suppressMessages({
expect_message(hub_con <- connect_hub(hub_path, file_format = "parquet"),
"superseded URL"
)
})

# Tests that paths are assigned to attributes correctly
expect_equal(
Expand Down Expand Up @@ -442,7 +458,11 @@ test_that("connect_hub works on parquet-only hub when skip_checks is TRUE", {

# S3
hub_path <- s3_bucket("hubverse/hubutils/testhubs/parquet/")
hub_con <- connect_hub(hub_path, file_format = "parquet", skip_checks = TRUE)
suppressMessages({
expect_message({
hub_con <- connect_hub(hub_path, file_format = "parquet", skip_checks = TRUE)
}, "superseded URL")
})

# Tests that paths are assigned to attributes correctly
expect_equal(
Expand Down Expand Up @@ -486,7 +506,7 @@ test_that("connect_hub & connect_model_output fail correctly", {
expect_snapshot(connect_hub("random/hub/path"), error = TRUE)
expect_snapshot(connect_model_output("random/model-output/"), error = TRUE)

temp_dir <- tempdir()
temp_dir <- withr::local_tempdir()
expect_snapshot(connect_hub(temp_dir), error = TRUE)

dir.create(fs::path(temp_dir, "hub-config"))
Expand Down
Loading