[help] Using format = "url"
with alternative modified metadata?
#1334
Unanswered
andrewheiss
asked this question in
Help
Replies: 1 comment 1 reply
-
Ahhh there's a similar question/use case from back in 2020 here: #131 (comment) - that led to the creation of tar_change(remote_data, download_data(), change = remote_hash(dep1, dep2)) So in this case, I'd do something like download_data <- function(url) {
httr2::request(url) |>
httr2::req_perform() |>
httr2::resp_body_json()
}
tar_change(
dataset,
download_data("https://election-testing.andhs.co/county?county=example"),
change = SOMETHING_HERE
) I'm not sure how to structure the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Help
Description
In a pipeline I'm building, I'm accessing JSON data from a URL that doesn't include
Last-Modified
in the HTTP header, but does include it as an entry in the JSON itself, like this:(I just whipped up this little example server that spits out JSON data formatted in this way, with a
last-modified
timestamp that updates every 5 minutes: https://election-testing.andhs.co/county?county=example)For a regular URL, I'd do something like this:
This doesn't work in this case, though, because of the missing metadata:
That all makes sense. It's not a normal website with normal HTTP headers or anything.
I'm curious what a recommended "different workaround" in this case might look like. The closest I've come is a process like this:
tarchetypes::tar_download()
, make two targets:remote_url
andremote_data
. In the function for theremote_url
target, save the timestamp in a temporary file somewheretarchetypes::tar_force()
to make theremote_url
target run every single time.remote_data
target that only grabs data from the URL if the timestamp in the temporary file is newBut that process feels wrong and un-targets-like (especially with the brute force of
tar_force()
). Is there a better way to use alast-modified
field in JSON data to invalidate a target?Beta Was this translation helpful? Give feedback.
All reactions