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

Upgrades downloading file handling, tests and other package linting #7

Merged
merged 43 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
c0949db
Delete extra svg
adamhsparks Dec 1, 2024
4f34f8c
Clarify column renaming and reordering
adamhsparks Dec 1, 2024
db5821e
Simplify .retry_download() to actually work as intended with less lines
adamhsparks Dec 1, 2024
1fd1348
use httptest2 and test .retry_download()
adamhsparks Dec 1, 2024
7ff50b6
Fix tests!!! Tested wrong fn.
adamhsparks Dec 1, 2024
11f2d46
adds rlang and httptest2
adamhsparks Dec 1, 2024
c8e04bd
test in parallel
adamhsparks Dec 1, 2024
0a9ba82
completely rewrite download function to use tryCatch and {brio}
adamhsparks Dec 1, 2024
0651018
use CITATION file for test and mock download
adamhsparks Dec 1, 2024
f9691b1
try fixing bugs in get_agfd()
adamhsparks Dec 1, 2024
d431358
add references and sources to trade regions
adamhsparks Dec 1, 2024
e7cf24c
use {brio} to write files
adamhsparks Dec 1, 2024
63a0d18
Fix references field in get_abares_trade_regions()
adamhsparks Dec 1, 2024
cba882e
update Wordlist
adamhsparks Dec 1, 2024
a9390f6
don't wrap test w/ mocking dir, causes errors on check
adamhsparks Dec 1, 2024
6d5e236
use httr2 caching
adamhsparks Dec 1, 2024
8e93ccf
fix httr2 caching
adamhsparks Dec 1, 2024
e389db1
Update
adamhsparks Dec 2, 2024
8c34adf
Update some of the documentation
adamhsparks Dec 2, 2024
e39fb4b
increase timeout, remove tryCatch rely on httr2 error
adamhsparks Dec 2, 2024
6aac6f6
Update links and add source to documentation for estimates
adamhsparks Dec 3, 2024
5403abc
Simplify downloading of AGFD files
adamhsparks Dec 3, 2024
8985f22
Add source and references to documentation and update link to file
adamhsparks Dec 3, 2024
c806249
specify what files should be imported
adamhsparks Dec 3, 2024
3d2d8a1
redocument package
adamhsparks Dec 3, 2024
0c4d633
Update tests to align with new functionality
adamhsparks Dec 3, 2024
a1827f0
Update codemeta.json
adamhsparks Dec 3, 2024
b8456d9
Merge branch 'main' into example_data
adamhsparks Dec 4, 2024
4165502
Lint test files
adamhsparks Dec 4, 2024
a611a22
Update codemeta.json
adamhsparks Dec 4, 2024
3c2ad0e
Correct test
adamhsparks Dec 4, 2024
f5d796e
Update codemeta.json
adamhsparks Dec 4, 2024
6d4afc4
use cli::cat_line() and don't force newlines, let {cli} do that
adamhsparks Dec 4, 2024
b3ccc66
missed a `cat("\n")`
adamhsparks Dec 4, 2024
c0a16d7
Fix source and references for estimates by size/performance
adamhsparks Dec 4, 2024
121f11c
Add source/rerferences to forecast database
adamhsparks Dec 3, 2024
37f16a2
formatting in documentation
adamhsparks Dec 3, 2024
39b6a71
add sources for AGFD documentation
adamhsparks Dec 4, 2024
fb783a8
fix source in agfd
adamhsparks Dec 3, 2024
0fe8cf0
update codemeta.json
adamhsparks Dec 4, 2024
891a313
use cli::cat_line() and don't force newlines, let {cli} do that
adamhsparks Dec 4, 2024
9f30f01
re-add codemeta.json
adamhsparks Dec 4, 2024
a8ffd36
Merge branch 'main' into example_data
adamhsparks Dec 4, 2024
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: 1 addition & 1 deletion R/get_agfd.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ get_agfd <- function(fixed_prices = TRUE,
#' @autoglobal
#' @noRd
print.read.abares.agfd.nc.files <- function(x, ...) {
cli::cli_h1("\nLocally Available ABARES AGFD NetCDF Files\n")
cli::cli_h1("Locally Available ABARES AGFD NetCDF Files")
cli::cli_ul(basename(x))
cat("\n")
invisible(x)
Expand Down
4 changes: 2 additions & 2 deletions R/get_soil_thickness.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ print.read.abares.soil.thickness.files <- function(x, ...) {
cli::cli_text("To see the full metadata, call
{.fn print_soil_thickness_metadata} on a soil thickness object in your R
session.")
cat("\n")
cli::cat_line()
invisible(x)
}

Expand Down Expand Up @@ -184,6 +184,6 @@ print_soil_thickness_metadata <- function(x) {
cli::cli_h1("Soil Thickness for Australian areas of intensive agriculture of Layer 1 (A Horizon - top-soil)\n")
cli::cli_h2("Dataset ANZLIC ID ANZCW1202000149")
cli::cli_text(x$metadata)
cat("\n")
cli::cat_line()
invisible(x)
}
2 changes: 1 addition & 1 deletion R/inspect_cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ inspect_cache <- function(recursive = FALSE) {
)
))
} else {
cli::cli_h1("\nLocally Available {{read.abares}} Cached Files\n")
cli::cli_h1("Locally Available {{read.abares}} Cached Files")
cli::cli_ul(basename(f))
}
}
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
},
"SystemRequirements": null
},
"fileSize": "327.717KB",
"fileSize": "327.685KB",
"citation": [
{
"@type": "SoftwareSourceCode",
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-get_aagis_regions.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ test_that("get_aagis_regions caches", {
expect_true(file.exists(
file.path(.find_user_cache(), "aagis_regions_dir/aagis.gpkg")
))
expect_true(!file.exists(
expect_false(file.exists(
file.path(.find_user_cache(), "aagis_regions_dir/aagis_zip")
))
expect_true(!file.exists(file.path(
expect_false(file.exists(file.path(
.find_user_cache(), "aagis_asgs16v1_g5a.*"
)))
})
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-get_abares_trade.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ test_that("get_abares_trade caches", {
expect_true(file.exists(
file.path(.find_user_cache(), "abares_trade_dir/abares_trade.rds")
))
expect_true(!file.exists(
expect_false(file.exists(
file.path(.find_user_cache(), "abares_trade_dir/abares_trade.zip")
))
})
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-get_abares_trade_regions.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ test_that("get_abares_trade_regions caches", {
expect_true(file.exists(
file.path(.find_user_cache(), "abares_trade_dir/abares_trade_regions.rds")
))
expect_true(!file.exists(
expect_false(file.exists(
file.path(.find_user_cache(), "abares_trade_dir/abares_trade_regions.csv")
))
})
Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/test-get_agfd.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ test_that("get_agfd, fixed = TRUE works", {
agfd_nc <- list.files(agfd_nc_dir, full.names = TRUE)

nc_files <- function(agfd_nc_dir) {
cli::cli_h1("\nLocally Available ABARES AGFD NetCDF Files\n")
cli::cli_h1("Locally Available ABARES AGFD NetCDF Files")
cli::cli_ul(basename(list.files(agfd_nc_dir)))
cat("\n")
cli::cat_line()
}
print_out <- capture.output(nc_files)

Expand All @@ -32,9 +32,9 @@ test_that("get_agfd, fixed = FALSE works", {
agfd_nc <- list.files(agfd_nc_dir, full.names = TRUE)

nc_files <- function(agfd_nc_dir) {
cli::cli_h1("\nLocally Available ABARES AGFD NetCDF Files\n")
cli::cli_h1("Locally Available ABARES AGFD NetCDF Files")
cli::cli_ul(basename(list.files(agfd_nc_dir)))
cat("\n")
cli::cat_line()
}
print_out <- capture.output(nc_files)

Expand Down Expand Up @@ -88,9 +88,9 @@ test_that("print.read.abares.agfd.nc.files returns a properly formatted list",
skip_if_offline()
skip_on_ci()
print_out <- function(x) {
cli::cli_h1("\nLocally Available ABARES AGFD NetCDF Files\n")
cli::cli_h1("Locally Available ABARES AGFD NetCDF Files")
cli::cli_ul(basename(x))
cat("\n")
cli::cat_line()
}

x <- get_agfd(cache = TRUE)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-get_soil_thickness.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ test_that("print.read.abares.thickness.files prints metadata", {
cli::cli_text("To see the full metadata, call
{.fn print_soil_thickness_metadata} on a soil thickness object in your R
session.")
cat("\n")
cli::cat_line()
}
print_out <- capture.output(out_text())

Expand All @@ -101,7 +101,7 @@ test_that("print_soil_thickness_metadata prints full metadata", {
)
cli::cli_h2("Dataset ANZLIC ID ANZCW1202000149")
cli::cli_text(x$metadata)
cat("\n")
cli::cat_line()
}

x <- get_soil_thickness(cache = TRUE)
Expand Down
9 changes: 5 additions & 4 deletions tests/testthat/test-read_agfd_stars.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@


test_that("read_agfd_stars() returns a stars object", {
skip_if_offline()
skip_on_ci()
Expand All @@ -7,8 +8,8 @@ test_that("read_agfd_stars() returns a stars object", {

expect_type(x, "list")
expect_s3_class(x[[1]], "stars")
expect_identical(
names(x),
expect_named(
x,
c(
"f2022.c1991.p2022.t2022.nc",
"f2022.c1992.p2022.t2022.nc",
Expand Down Expand Up @@ -45,8 +46,8 @@ test_that("read_agfd_stars() returns a stars object", {
"f2022.c2023.p2022.t2022.nc"
)
)
expect_identical(
names(x[[1]]),
expect_named(
x[[1]],
c(
"farmno",
"R_total_hat_ha",
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-read_agfd_terra.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ test_that("read_agfd_terra() returns a terra object", {

expect_type(x, "list")
expect_s4_class(x[[1]], "SpatRaster")
expect_identical(
names(x),
expect_named(
x,
c(
"f2022.c1991.p2022.t2022.nc",
"f2022.c1992.p2022.t2022.nc",
Expand Down Expand Up @@ -45,8 +45,8 @@ test_that("read_agfd_terra() returns a terra object", {
"f2022.c2023.p2022.t2022.nc"
)
)
expect_identical(
names(x[[1]]),
expect_named(
x[[1]],
c(
"farmno",
"R_total_hat_ha",
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-read_agfd_tidync.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ test_that("read_agfd_tidync() returns a tidync object", {

expect_type(x, "list")
expect_s3_class(x[[1]], "tidync")
expect_identical(
names(x),
expect_named(
x,
c(
"f2022.c1991.p2022.t2022.nc",
"f2022.c1992.p2022.t2022.nc",
Expand Down
Loading