Repository navigation
Add get_archival_data() function #409
Copy link
Copy link
Description
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
limitargument for tests? - Add argument so users can store csv files:
pathordir - Allow partial resume from previously downloaded files
- Name the local files: uuid for now
- BUG: case sensitivity in animal_project_code: BUG:
animal_project_codeis case sensitive inetnservice::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 - Require etnservice <= v0.7.0
- 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
- Offer friendly abort option when suggesting out of memory call, similar to
usethis::ui_yeah()
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 dataread from disk in this implementation - 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
- Perform requests in parallel?
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) ~~anddata 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Activity
get_archival_data()toget_package()#410PietrH commentedon Mar 19, 2026
PietrH commentedon Mar 19, 2026
Status 20260203: etn development roadmap, document by Lotte
PietrH commentedon Mar 19, 2026
Notes form discussion with Peter 20250606:
PietrH commentedon Mar 19, 2026
Notes from ETN meeting 20250909
PietrH commentedon Mar 19, 2026
Does a user need to log into MDA (marine data archive: https://mda.vliz.be/archive.php) to download the csv files?
PietrH commentedon Mar 19, 2026
No, I think these can be fetched from: "https://www.lifewatch.be/etn/archival-data/", files are selected via a GUID: eg: https://www.lifewatch.be/etn/archival-data/file/1980c349-b4df-4b58-a95d-0a6c77a31fc9
But an authentication cookie is passed in the GET request, so you need to login to access this data.
Is there a way around this? What is the preferred way of authentication on the ETN data platform?
PietrH commentedon Mar 19, 2026
Let's not do data aggregation to start with. Mongo-db could aggregate, but let's not depend on mongo-db. We are not sure it'll still be here on the long term.
The user can aggregate themselves.
PietrH commentedon Mar 19, 2026
Only support one
tag_serial_numberat a time, supporting a vector makes it too easy to ask for much much more data than you'd be able to process. Even a single tag is already 1GB+ of data.Users can call the function in a loop.
Stijn-VLIZ commentedon Mar 26, 2026
ETN can make these links unprotected by login, but we will need to add checks if people are allowed to retrieve certain files, question remains how we will do that...
PietrH commentedon Mar 26, 2026
If there is some sort of secret or token I can pass with the request, great, but we need to correctly estimate what the chances are a bad agent can guess the uuid of a file they might be interested in. Personally I believe this to be quite unlikely, but not impossible.
I suppose that depends on when/on what system the uuids were generated, but generally they are not considered a cryptographically safe token.
I'll think about a solution.
8 remaining items
PietrH commentedon May 5, 2026
Is it always?
PietrH commentedon May 7, 2026
I've come across a tag_serial_number:
A09119that results in a csv file that only has a header, no rows.CLAUMEMO commentedon May 7, 2026
Yes, they should be constant.
@Stijn-VLIZ maybe we should exclude from
digital_twin.archival_filesfiles that gave an error: https://www.lifewatch.be/etn/conversionlogs/253Stijn-VLIZ commentedon May 11, 2026
Good Idea, view was changed.
animal_project_codeis case sensitive inetnservice::get_archival_data_uuid()etnservice#154PietrH commentedon May 12, 2026
I'll cache csv files per R Session, not per function call.
PietrH commentedon Jul 17, 2026
I've added a warning with helpful suggestions if you are trying to return over 1GB of data as a tibble, suggesting you use out of memory processing instead.
Should I also give the option to abort at this step?
peterdesmet commentedon Jul 23, 2026
You mean a nicer way than using
Ctrl + Cto abort? Yeah, asking for user input (continue / abort) at that point might be useful.PietrH commentedon Jul 23, 2026
Will do.
etnservicev0.7.0 etnservice#173PietrH commentedon Aug 6, 2026
Requested deployment of etnservice v0.7.0
Stijn-VLIZ commentedon Aug 10, 2026
Deployed
PietrH commentedon Aug 11, 2026
The capital was a typo, would you like me to change it?
I wonder why the IO library is needed, there is a new dependency withr, but I don't see why it would need libuv1-dev.