Skip to content

Instantly share code, notes, and snippets.

@elipousson
Created July 26, 2024 18:48
Show Gist options
  • Save elipousson/d9887d8bd4dda4c69742432b9b7b8017 to your computer and use it in GitHub Desktop.
Save elipousson/d9887d8bd4dda4c69742432b9b7b8017 to your computer and use it in GitHub Desktop.
tar_url_read <- function(name,
command,
read,
tidy_eval = targets::tar_option_get("tidy_eval"),
packages = targets::tar_option_get("packages"),
library = targets::tar_option_get("library"),
format = targets::tar_option_get("format"),
repository = targets::tar_option_get("repository"),
error = targets::tar_option_get("error"),
memory = targets::tar_option_get("memory"),
garbage_collection = targets::tar_option_get("garbage_collection"),
deployment = targets::tar_option_get("deployment"),
priority = targets::tar_option_get("priority"),
resources = targets::tar_option_get("resources"),
storage = targets::tar_option_get("storage"),
retrieval = targets::tar_option_get("retrieval"),
cue = targets::tar_option_get("cue")) {
name_read <- deparse(rlang::enexpr(name))
name_url <- paste0(name_read, "_url")
sym_url <- rlang::sym(name_url)
command <- targets::tar_tidy_eval(
expr = as.expression(substitute(command)),
envir = targets::tar_option_get("envir"), tidy_eval = tidy_eval
)
read <- targets::tar_tidy_eval(
expr = as.expression(substitute(read)),
envir = list(.x = sym_url), tidy_eval = TRUE
)
list(
targets::tar_target_raw(
name = name_url,
command = command,
packages = packages, library = library, format = format,
repository = repository, error = error, memory = memory,
garbage_collection = garbage_collection, deployment = deployment,
priority = priority, storage = storage, retrieval = retrieval,
cue = cue
),
targets::tar_target_raw(
name = name_read,
command = read, packages = packages, library = library,
format = format, repository = repository, error = error,
memory = memory, garbage_collection = garbage_collection,
deployment = deployment, priority = priority, resources = resources,
storage = storage, retrieval = retrieval, cue = cue
)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment