8000 New function write_camtrapdp() by sannegovaert · Pull Request #137 · inbo/camtrapdp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

New function write_camtrapdp() #137

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 Gi 8000 tHub”, 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

Merged
merged 24 commits into from
Oct 25, 2024
Merged

New function write_camtrapdp() #137

merged 24 commits into from
Oct 25, 2024

Conversation

sannegovaert
Copy link
Member
@sannegovaert sannegovaert commented Oct 17, 2024

Copy link
codecov bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.89%. Comparing base (8c4981e) to head (73b354a).
Report is 25 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #137   +/-   ##
=======================================
  Coverage   99.89%   99.89%           
=======================================
  Files          22       23    +1     
  Lines         958      983   +25     
=======================================
+ Hits          957      982   +25     
  Misses          1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sannegovaert sannegovaert marked this pull request as ready for review October 24, 2024 10:55
#'
#' Writes a Camera Trap Data Package and its related Data Resources to disk as a
#' `datapackage.json` and CSV files.
#' Already existing CSV files of the same name will not be overwritten.
Copy link
Member

Choose a reason for hiding this comment

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

They are overwritten, which is:

I've updated the frictionless issue to clarify that overwriting is the desired behaviour.

R/version.R Outdated
x$resources <- purrr::map(x$resources, function(resource) {
resource$schema <- sub(old, new, resource$schema, fixed = TRUE)
if (resource$name %in% camtrapdp_resource_names) {
Copy link
Member

Choose a reason for hiding this comment

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

I added more checks here, since just checking for the existence of schema was not sufficient (e.g. it converts verbose list schemas to character + affects non-camtrapdp resources)

write_camtrapdp <- function(x, directory) {
check_camtrapdp(x)

# Update spatial, temporal and taxonomic scope in metadata
Copy link
Member

Choose a reason for hiding this comment

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

Why is this step necessary?

#'
#' @inheritParams print.camtrapdp
#' @param directory Path to local directory to write files to.
#' @return `x` invisibly, as written to file.
Copy link
Member

Choose a reason for hiding this comment

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

The returned x is no longer valid, so I wonder how useful it is to return.

Copy link
Member

Choose a reason for hiding this comment

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

I've updated this to return NULL invisibly.

@@ -13,6 +13,7 @@ test_that("write_dwc() writes CSV and meta.xml files to a directory and
expect_identical(names(result), c("occurrence", "multimedia"))
expect_s3_class(result$occurrence, "tbl")
expect_s3_class(result$multimedia, "tbl")
expect_invisible(suppressMessages(write_dwc(x, temp_dir)))
Copy link
Member

Choose a reason for hiding this comment

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

I've added this here and to movepub, since we don't actually test that the result is returned invisibly.

@@ -0,0 +1,93 @@
test_that("write_camtrapdp() writes datapackage.json and CSV files to a
Copy link
Member

Choose a reason for hiding this comment

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

I've deviated from the frictionless::write_package() test and aligned it more with write_dwc()

expect_invisible(write_camtrapdp(x, temp_dir))
})

test_that("write_camtrapdp() writes a (filtered) dataset that can be read", {
Copy link
Member

Choose a reason for hiding this comment

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

New test

expect_identical(written_observations, original_observations)
})

test_that("write_camtrapdp() can write compressed files", {
Copy link
Member

Choose a reason for hiding this comment

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

We now pass arguments via ... allowing write_camtrapdp() to compress resources.

@peterdesmet peterdesmet merged commit 4e52a04 into main Oct 25, 2024
9 checks passed
@peterdesmet peterdesmet mentioned this pull request Oct 25, 2024
6 tasks
@peterdesmet peterdesmet deleted the write_camtrapdp() branch December 12, 2024 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

version<- adds $schema to resource when $schema did not exist
2 participants
0