Dealing with Fireworks that are dependent on children of another firework that don't exist yet

I have a workflow that looks like this:

At start I have enough information to write fireworks A, B and C.

B generates additions B’,B1,B2,B3,B4…
C generates additions C’,C1,C2,C3,C4…
B’ is a child of B1,B2,B3,B4…
C’ is a child of C1,C2,C3,C4…
B’ generates additions B’’,B’1,B’2,B’3,B’4…
C’ generates additions C’’,C’1,C’2,C’3,C’4…
B’’ is a child of B’1,B’2,B’3,B’4…
C’’ is a child of C’1,C’2,C’3,C’4…

The number of generated fireworks at each step is not constant.

A is dependent on B’’ and C’’. However, as B’’ and C’’ don’t exist at the start of the workflow I can’t write A with them as parents. I also can’t generate A off of B’’ for example because I don’t know if C’’ is finished or not.

I can get around this by running a while loop outside fireworks and looking for files I expect B’’ and C’’ to generate and adding A when those are available. But is there a way to handle this inside fireworks?

Hi Matt,

It’s possible I don’t understand the dependencies correctly, but how about the following:

  1. Initialize the workflow with A dependent on B and C
  2. When B completes, use a “detour” FWAction to create B’. When B’ completes, use a “detour” FWAction to create B’’. When B’’ completes, use the normal FWAction (no detours) to connect back to the main branch of A.
  3. Similarly, use “detours” for C going to C’ and C’’, and then when C’’ completes use a normal FWAction to connect back to the main branch of A.

There’s also a schematic of detours here under the FWAction header: The Comprehensive Guide to Writing Firetasks with Python — FireWorks 2.0.3 documentation

Awesome! Thanks! I think that should work!

So there seems to be a problem with this solution. When I generate B’ for example I add the additions B1,B2,B3,B4… as parents of B’. However, when B’ enters the workflow through the FWAction detour it doesn’t have any parents causing it to immediately execute, not find the results of B1,B2,B3,B4… and fizzle.

This inability to assign parents also seems to be true for additions to the workflow as well through FWAction.

Oh, it seems I just needed to specify them all of them together as a new detour workflow in order to preserve parent-child relationships between the new fireworks.