Run workflow n times

Is there a simple way to run a workflow n times (yes, I could put in a for loop)? I thought a nested workflow with wf outer having an iterable equal to the number of times to call the inner workflow would work. Then I could use a join node in the outer workflow to collect all the runs of the inner workflows. However, the inner workflow is not actually expanded by the outer workflow’s iterable unless I tie that iterable as an input to the “head node” in the inner workflow. I have a dummy variable in the identity interface (which is the head node) of the inner workflow which must be passed to the first function node in the innerworkflow. If the iterable from the outer wf is not passed to the functional node, the functional node in the innerworkflow is not expanded. This is what I’ve concluded from a toy example.

def make_inner_wf():
return wf_inner

wf_meta = pe.Workflow(name=‘meta’)

for j in range(n):
wf_meta.add_nodes([wf_inner.clone(name=‘run%j’ %j)])

wf_meta.run(plugin args here eg SLURM propagate to enclosed inner workflows)

Solution thanks to @mgxd

1 Like