-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
…into write_camtrapdp()
R/write_camtrapdp.R
Outdated
#' | ||
#' 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. |
There was a problem hiding this comment.
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:
- An error in the frictionless documentation
- A good thing for camtrapdp, so I will remove the sentence
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) { |
There was a problem hiding this comment.
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)
R/write_camtrapdp.R
Outdated
write_camtrapdp <- function(x, directory) { | ||
check_camtrapdp(x) | ||
|
||
# Update spatial, temporal and taxonomic scope in metadata |
There was a problem hiding this comment.
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?
R/write_camtrapdp.R
Outdated
#' | ||
#' @inheritParams print.camtrapdp | ||
#' @param directory Path to local directory to write files to. | ||
#' @return `x` invisibly, as written to file. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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))) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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", { |
There was a problem hiding this comment.
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", { |
There was a problem hiding this comment.
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.
write_camtrapdp()
function #74version<-
adds $schema to resource when $schema did not exist #139