3434
3535
3636def  guardrail_selection (wf : 'Workflow' , node1 : 'Node' , node2 : 'Node' ,
37-                         ) ->  Node :
37+                         output_key : str  =  'registered' ,
38+                         guardrail_node : 'Node'  =  None ) ->  Node :
3839    """Generate requisite Nodes for choosing a path through the graph 
3940    with retries 
4041
@@ -43,7 +44,13 @@ def guardrail_selection(wf: 'Workflow', node1: 'Node', node2: 'Node',
4344    wf : Workflow 
4445
4546    node1, node2 : Node 
46-         try guardrail, retry guardrail 
47+         first try, retry 
48+ 
49+     output_key : str 
50+         field to choose 
51+ 
52+     guardrail_node : Node 
53+         guardrail to collect 'failed_qc' from if not node1 
4754
4855    Returns 
4956    ------- 
@@ -52,15 +59,19 @@ def guardrail_selection(wf: 'Workflow', node1: 'Node', node2: 'Node',
5259    # pylint: disable=redefined-outer-name,reimported,unused-import 
5360    # noqa: F401 
5461    from  CPAC .pipeline .nipype_pipeline_engine  import  Node , Workflow 
62+     if  guardrail_node  is  None :
63+         guardrail_node  =  node1 
5564    name  =  node1 .name 
65+     if  output_key  !=  'registered' :
66+         name  =  f'{ name }  _{ output_key }  ' 
5667    choices  =  Node (Merge (2 ), run_without_submitting = True ,
5768                   name = f'{ name }  _choices' )
5869    select  =  Node (Select (), run_without_submitting = True ,
5970                  name = f'choose_{ name }  ' )
60-     wf .connect ([(node1 , choices , [('registered' , 'in1' )]),
61-                 (node2 , choices , [('registered' , 'in2' )]),
71+     wf .connect ([(node1 , choices , [(output_key , 'in1' )]),
72+                 (node2 , choices , [(output_key , 'in2' )]),
6273                (choices , select , [('out' , 'inlist' )]),
63-                 (node1 , select , [('failed_qc' , 'index' )])])
74+                 (guardrail_node , select , [('failed_qc' , 'index' )])])
6475    return  select 
6576
6677
0 commit comments