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

Update read_camtrap_dp() to support Camtrap DP v1.0 onwards with convert_ functions #9

Closed
peterdesmet opened this issue Jul 15, 2023 · 4 comments
Labels
function:read Functions read_camtrapdp(), convert(), build_taxonomy()

Comments

@peterdesmet
Copy link
Member

peterdesmet commented Jul 15, 2023

Suggested in camtraptor July 2023 coding sprint

See inbo/camtraptor#251 for background. We plan to support all legacy versions of Camtrap DP from version 1.0 onwards.

This will be done by read_camtrap_dp() which can detect the used version and run the profile and data through a number of convert_ functions to get it to the latest versions, e.g.:

# package == v1.0 and since then there is a version 1.1, 1.2
package <- convert_1.0_to_1.1(package)
package <- convert_1.1_to_1.2(package)
package <- convert_1.2_to_1.3(package)

Working sequentially avoids us from having to repeat the same conversions over and over again. It also makes it easier to notice what has changed between versions.

If a certain step is more cumbersome to do via an intermediate version, it is possible to create a conversion function that skips a number of versions, e.g. convert_1.0_to_1.2(). The existing number of convert functions would then be:

# convert_1.0_to_1.1() deleted
convert_1.0_to_1.2()
convert_1.2_to_1.3()

This specific conversion functions could be all handled by a generic

convert(package)

This function would:

  • Get the dataframes and attach these to $data
  • Read the version
  • Call the required number of convert_ functions on the data frames and profile (metadata)
  • Return the package
@peterdesmet peterdesmet transferred this issue from inbo/camtraptor Mar 6, 2024
@damianooldoni damianooldoni changed the title Update read_camtrap_dp() to support Camtrap DP v1.0-rc.1 onwards with convert_ functions Update read_camtrap_dp() to support Camtrap DP v1.0 onwards with convert_ functions Mar 12, 2024
@damianooldoni
Copy link
Member

At the moment we are at version 1.0, so none of the convert_1.x_to_1.y() functions need to be implemented. In other words:

  • read_camtrap_dp() calls convert().
  • convert() controls the version via get_version() and in case of a valid supported version (= 1.0) will return the package as it is at the moment.

@damianooldoni damianooldoni added this to the code sprint (v1) milestone Mar 12, 2024
@peterdesmet
Copy link
Member Author

Correct. The template for conversion functions is ready in https://github.com/inbo/camtrapdp/blob/9ecceb07ff50a2fd243e28c2584ddc417ef9a51f/R/convert.R

@damianooldoni
Copy link
Member

I see you added a convert step from 0.1.6 to 1.0. Didn't we decide to start converting from 1.0 onwards? In inbo/camtraptor#251:

Supporting all legacy versions of Camtrap DP from version 1.0-rc.1 onwards. This means we will drop support for v0.1.6. Users will be able to recreate their exports in the latest version of Camtrap DP in Agouti and Trapper.

@peterdesmet
Copy link
Member Author

Yes, correct. the function is currently only there as an example for future me and co-developers. It is never called, since read_camtrap_dp() doesn't allow other versions than 1.0.

@peterdesmet peterdesmet added the function:read Functions read_camtrapdp(), convert(), build_taxonomy() label May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
function:read Functions read_camtrapdp(), convert(), build_taxonomy()
Projects
None yet
Development

No branches or pull requests

2 participants