Branching over static branches in large pipeline, tar_combine() requires existing objects #421
Replies: 1 comment 1 reply
-
It may be an adjustment, but this kind of static branching is far more reliable than what
No, because we cannot always parse the names of the objects we branch over. And even if we could, dynamic branching assumes we do not know the branches in advance, so individual branch names should not be used to construct the pipeline to begin with. In practice, static branching operates best at a high level when there are few things to branch over, and dynamic branching is better suited to handle larger numbers of branches. That last example you wrote looks nice. If you find yourself wanting the names of dynamic branches, I would recommend instead saving any identifying metadata you need in the branch itself instead of encoding it in the name. If you want to select groups of individual branches programmatically, |
Beta Was this translation helpful? Give feedback.
-
Migrating a large pipeline over from Drake where I was doing a lot of static branching in different steps, loading files and then later combining them in different ways. With static branching in targets I have to first save the branches as a targets object that i then supply to
tar_combine()
. This disrupts the readability of my code a lot since i need to create lots of objects with different names. In targets, it seems its a lot simpler to do this with dynamic branching - the only downside being that the targets get names that are impossible to interpret. Is there any way to give dynamic targets custom names?Here are a couple of examples to illustrate the problem, of course, my real use cases are a lot more complicated:
This thus not work, but is what I started trying out when coming from drake:
It of course throws
object 'filtered_df' not found
. So I tried putting thetar_map()
code insidetar_combine()
which does not work astar_combine()
only returns the combined target:When one attempts a build it throws
Error : object 'filtered_df_1' not found
. To get it to work I need to assign parts of the pipeline to objects first:But this is a lot messier. I need to keep track of the objects,
mapped
andcombined
and if I want to keep the pipelinelist()
in_targets.R
organized I need to split parts of the code that are not even being mapped too. So, I've now changed most of my code using such branching in Drake to use the following style with dynamic branching:The only downsides being that I need to create an extra target for "group" and of course that the branch names are uninformative. What would you say is the best way to run these kinds of workflows? Is there any way to assign names to dynamic targets?
Beta Was this translation helpful? Give feedback.
All reactions