From b0923f66c394b27d8791402f3b8fc97570f7384b Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar (UMass)" Date: Tue, 29 Oct 2024 07:49:03 -0700 Subject: [PATCH 1/6] Increment version number to 1.2.3.9000 --- DESCRIPTION | 2 +- NEWS.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index eed8605..528860a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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", , "annakrystalli@googlemail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-2378-4915")), diff --git a/NEWS.md b/NEWS.md index 73b41cc..82e2b3c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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). From cb276a4cee9cefdec37b5b6b36a7d0eb044e6612 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar (UMass)" Date: Tue, 29 Oct 2024 08:42:10 -0700 Subject: [PATCH 2/6] update snapshots for hubUtils 0.2.0 --- tests/testthat/_snaps/hub-connection.md | 60 ++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 6 deletions(-) diff --git a/tests/testthat/_snaps/hub-connection.md b/tests/testthat/_snaps/hub-connection.md index 559c462..d96fd18 100644 --- a/tests/testthat/_snaps/hub-connection.md +++ b/tests/testthat/_snaps/hub-connection.md @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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" --- @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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" --- @@ -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 @@ -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 @@ -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" --- @@ -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 @@ -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 @@ -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" --- From 8f3b7788e74b4264803d729d525c21f94eb4a42a Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar (UMass)" Date: Tue, 29 Oct 2024 08:42:42 -0700 Subject: [PATCH 3/6] use `withr::local_tempdir()` for tests I was getting errors when I ran tests/testthat/test-hub-connection.R with `devtools::test_active_file()` in a single session. This was caused by the tempdir not being cleaned up after the test was finished. --- DESCRIPTION | 3 ++- tests/testthat/test-hub-connection.R | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 528860a..4f7a55d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 diff --git a/tests/testthat/test-hub-connection.R b/tests/testthat/test-hub-connection.R index 0772721..ba217b8 100644 --- a/tests/testthat/test-hub-connection.R +++ b/tests/testthat/test-hub-connection.R @@ -486,7 +486,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")) From d6994d5cf93ab7d94f0ca37f4d985f96705e21a3 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar (UMass)" Date: Tue, 29 Oct 2024 08:55:04 -0700 Subject: [PATCH 4/6] update expectation for warning; test for hubUtils msg --- tests/testthat/test-hub-connection.R | 35 ++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/tests/testthat/test-hub-connection.R b/tests/testthat/test-hub-connection.R index ba217b8..00a4602 100644 --- a/tests/testthat/test-hub-connection.R +++ b/tests/testthat/test-hub-connection.R @@ -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) @@ -345,7 +356,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") + }) # Tests that paths are assigned to attributes correctly expect_equal( @@ -388,7 +401,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( @@ -442,7 +459,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( From 2b50fef71a0697742ed016bc00a991244be5ff38 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar (UMass)" Date: Tue, 29 Oct 2024 09:16:25 -0700 Subject: [PATCH 5/6] fix lintr --- tests/testthat/test-hub-connection.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-hub-connection.R b/tests/testthat/test-hub-connection.R index 00a4602..1fc6a32 100644 --- a/tests/testthat/test-hub-connection.R +++ b/tests/testthat/test-hub-connection.R @@ -93,7 +93,7 @@ test_that("connect_hub returns empty list when model output folder is empty", { hub_path <- s3_bucket("hubverse/hubutils/testhubs/empty/") suppressWarnings({ suppressMessages({ - expect_message(hub_con <- connect_hub(hub_path, skip_checks = TRUE), + expect_message(hub_con <- connect_hub(hub_path, skip_checks = TRUE), "superseded URL" ) }) From d5a498d6f7ea6288a3d90e9dde39e14cf7f0b817 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar (UMass)" Date: Thu, 31 Oct 2024 10:54:45 -0700 Subject: [PATCH 6/6] remove dplyr library call --- tests/testthat/test-hub-connection.R | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/testthat/test-hub-connection.R b/tests/testthat/test-hub-connection.R index 1fc6a32..dfb9827 100644 --- a/tests/testthat/test-hub-connection.R +++ b/tests/testthat/test-hub-connection.R @@ -320,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",