ropensci / drake

An R-focused pipeline toolkit for reproducibility and high-performance computing
https://docs.ropensci.org/drake
GNU General Public License v3.0
1.34k stars 128 forks source link

Is it possible to invalidate all the predecessor targets? #1326

Closed kbzsl closed 3 years ago

kbzsl commented 3 years ago

Is it possible to invalidate all the predecessor targets (in backward direction) when one target is specified?

The goal would be to re-run only the minimum required number of targets needed to refresh one specified target. I understand that with this approach other targets might be invalidated too, considering all the dependencies from the workflow. But these can be solved by the next make() command at any later time.

Rationale: my workflow is running periodically based on trigger conditions, but sometimes I need to refresh just one of the “final targets”, which usually depends of some lower level targets (data collection, pre-processing, aggregation, analysis, …), but it is time consuming to rerun the complete workflow.

Thank you.

wlandau commented 3 years ago

The quickest way I can think to do this is to call make(plan, targets = "top_level_target", trigger = trigger(condition = TRUE)). Otherwise, drake_config(plan)$graph should give you an igraph object, and you can get all the upstream target names with igraph::nbhd_vertices(graph, vertices = "top_level_target", mode = "in", order = igraph::gorder(graph)) (with the rest of the processing up to you after that).