Skip to content

Add get_archival_data() function #409

Description

@PietrH

STRAITS

Add a new function get_archival_data() to retrieve processed tag archival data. The user can define tag (tag_serial_number) and data aggregation level (summarized or all). The function retrieves relevant data (files) and returns it to the user as a single data frame.

summarized: only return data from whole hours. Drop all other data points. I could easily add support for other steps in aggregation. Are we sure no averaging or similar takes place?

  • fetch csv's and combine them
  • fetch them where?
  • decompression
  • how does the user select the archival data, on what parameters?
  • Is a etn database query necessary? Or can it be done purely client based?
  • What postgres table contains the links to the csv files?
  • What is the best way to programmatically read the csv files without having to manage an authentication cookie.
  • Read csv with readr or via httr2? -> httr2 for throttling and retries
  • Add lazy evaluation support via duckdb? arrow
  • Fix bug: col classes need to match while merging: add schema?
`purrr::list_rbind()` at etn/R/get_archival_data.R:49:3:
! Can't combine `..1$timestamp_utc` <datetime<UTC>> and `..2$timestamp_utc` <character>.
  • Adjust throttling
  • BUG: running out of working memory when loading multliple large datasets into memory for parsing; Store onto disk and parse one by one?
  • Add progress bar argument
  • Idea: Break up progress in two steps: fetching data, reading/parsing csv
  • Idea: Fetch files sequentially (big files saturate network connections), and use httr2::req_progress() to show downloaded bytes.
  • Add aggregation and aggregation argument: via duckdb? need to group by the floor of the datetime, and then aggregate. duckdb is much faster. Let's not take this as extra maintenance for now.
  • Test on animal_project_code case sensitivitly
  • Test on invalid values for animal_project_code
  • Add caching via httr2 for return values: very stable
  • Add tests for col classes: hard to predict what cols we'll get back
  • Add limit argument for tests?
  • Add argument so users can store csv files: path or dir
  • Allow partial resume from previously downloaded files
  • Name the local files: uuid for now
  • BUG: case sensitivity in animal_project_code: BUG: animal_project_code is case sensitive in etnservice::get_archival_data_uuid() etnservice#154 (comment)

Minimal Viable Product

  • Describe changes in NEWS
  • Add extension to local files
  • Deploy etnservice::get_archival_data_uuid() to OpenCPU production
  • Add test skips on data domain offline and on no credentials
  • Add documentation of returned object, what cols to expect
  • Decide: Should invalid values for arguments be checked on the client or via the service? Currently all on service, is this robust?, to client, but postponed see Check for invalid values on the client side #588

Postponed/Extend goals

  • Should users be able to read local files without a database query? Without database credentials?
  • Don't allow tibble return on very large datasets? How to efficiently count rows of returned csv's? Decide purely on filesize?
  • Stop users from trying to read all archival data available to them, this will be millions of records
  • Add local caching of uuid values? very stable: cachem over memoise
  • return helpful error if a passed path (dir) doesn't exist
  • Abstract opening arrow dataset from online hosted files: reusable for public data
  • Abstract downloading a file with package defaults (declaring user agent, retries, path handling): can be reused for public data, and for get_acoustic_detections() feather and parquet files
  • rename temp_file_paths: not always temporary files
  • Abstract out extrating a uuid from a filepath: more readable
  • tests: cache http responses?: faster, more consistent, less load on VLIZ, but possibly unacceptably increases package size

Questions

How to detect if a project has archival data -> Will be useful for get_package(), it'll sometimes need to get achival data, how to know that you need to get it.

Requirements

  • Add a new function get_archival_data() to retrieve processed tag archival data.
  • The user can define tag (tag_serial_number) ~~and data aggregation level (summarized or all). ~~ -> users can aggregate themselves for now, if there is demand we can add aggregation functions later on. You'd need to read all the data anyway.
  • The function retrieves relevant data (files) and returns it to the user as a single data frame.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Fields

No fields configured for Feature.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions