A target factory for tracking, but not duplicating, external targets
In #3, I we talked about 3 use cases for unitar, and created a target factory to track external targets into a secondary project.
But a common use case (for me at least) is to want to track the upstream target as an input without duplicating it. But as @wlandau said,
I think it might be difficult to make a sufficiently flexible target factory for (3).
I've been thinking about it a bit more. I think we could create a target factory that would take as input:
- An upstream target name
- A function call on that name.
I think it may be possible to use something like:
track_external_target = function(tname, ext_tname, func) {
fullpath = unitar_path(ext_tname)
name_file = paste0(sample_name, "_file")
command_data = substitute(func(fullpath), env=list(fullpath=as.symbol(name_file), func=as.symbol(func)))
list(
tar_target_raw(name_file, fullpath, format = "file"),
tar_target_raw(tname, command_data)
)
}
I just wanted to capture this as a separate issue
Yeah, this actually seems similar to stantargets and jagstargets, which require the user to supply code just to generate Stan/JAGS data. Seems to have worked out well so far because the need for custom code is reduced in so many other places for those packages.