LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only

Disable a node based on a parameter - BRX

  • 1.  Disable a node based on a parameter - BRX

    Employee
    Posted 12-18-2014 07:11

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: gmullin

    I'm doing some testing with using a BRX and I'm finding that enabling and disabling a node based on the values in a parameter is not working quite as easily as I hoped. I have a parameter called Populated. I'm trying to enable an output node if Populated is equal to "abc". I've saved the BRX and I'm feeding in Populated as a parameter. So far I've found this:

    "{{^Populated^}}" == "abc" => The node is never enabled, no matter what value I feed into the BRX. I import the BRS and the node is enabled but not run.
    "{{$Populated$}}" == "abc" => The node is always enabled. Even when I import the BRX, it shows the node disabled but with a green tick over it.
    {{?Populated?}} => In the BRG this checks if there's any value in Populated and enables or disables appropriately. In the BRX it just always enables it.

    I'm getting quite confused over this, as everything works perfectly in the BRG, but when I save it as BRX and run it via the BRX node, I'm getting issues with the node enabling and disabling. I use a parameter in the output filename and in a filter in the graph, which both work perfectly in the format {{^ParamName^}}.


    Edit: I can't upload files where I am, so I've pasted in a test graph I've been using. I'm on a server version also, so the output and BRX locations will have to be changed.


  • 2.  RE: Disable a node based on a parameter - BRX

    Employee
    Posted 12-18-2014 07:21

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: gmullin

    node:Static_Data
    bretype:core::Static Data
    editor:sortkey=5492e16e29877fa8
    output:@40fe6c55598828e5/=
    editor:XY=170,150
    end:Static_Data

    node:Filter
    bretype:core::Filter
    editor:sortkey=5492e19410e45488
    input:@40fd2c74167f1ca2/=Static_Data.40fe6c55598828e5
    output:@40fd2c7420761db6/=
    prop:Script=<<EOX

    emit '{{^FieldName^}}'
    EOX
    editor:XY=350,150
    end:Filter

    node:Dummy_Input_3
    bretype:core::Dummy Input
    editor:sortkey=545a11b2743f4f53_3
    output:@40fd2c7452fa204a/=
    inclock:/=Execute_DQE_2
    prop:Header=x
    prop:NumberOfRecords=1
    editor:XY=170,400
    end:Dummy_Input_3

    node:Output_BRD_File
    bretype:core::Output BRD File
    editor:sortkey=549020621a1e091a
    input:@40fd2c7476600190/=Filter.40fd2c7420761db6
    prop:Enabled={{?Populated?}}
    prop:File=/data/inout/FDS/input/FDS_lavasp02/Data/TEST/Output_Files/brx_test_run_{{^Table_Name^}}.brd
    editor:XY=540,150
    end:Output_BRD_File

    node:Extract_Parameters_3
    bretype:core::Filter
    editor:Label=Extract Parameters
    editor:sortkey=545a11bc3aed7394_3
    input:@40fd2c74167f1ca2/=Dummy_Input_3.40fd2c7452fa204a
    output:@40fd2c7420761db6/=
    prop:Script=<<EOX
    #emit "3.2.1.1" as Version
    emit "MyTable" as Table_Name
    #emit "abc" as Populated
    emit "color" as FieldName
    EOX
    editor:XY=330,400
    end:Extract_Parameters_3

    node:Execute_DQE_4
    bretype:core::Execute BRX
    editor:Label=Execute DQE
    editor:sortkey=5459f61e33c649fb_4
    input:@41f6ad97248f3165/=Extract_Parameters_3.40fd2c7420761db6
    output:@4bb4ae93325d3528/=
    output:@4bb363d451d1784a/=
    prop:Brx=/data/inout/FDS/input/FDS_lavasp02/Data/TEST/mapping_test.brx
    prop:Password=mugerar
    prop:Username=mugerar
    editor:XY=470,400
    end:Execute_DQE_4


  • 3.  RE: Disable a node based on a parameter - BRX

    Employee
    Posted 12-18-2014 07:33

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Tim Meagher

    Hi,

    It isn't possible to enable or disable a node within a BRX.
    Essentially, the enabled/disabled status of a node is determined prior to compiling the BRX.
    If the node is disabled at the time of saving the BRX, it won't get compiled into the BRX, otherwise it will get compiled and exist in the BRX.

    What are you trying to achieve with the enabling/disabling of the node?
    Perhaps there is another solution that will work for you.

    Tim.


  • 4.  RE: Disable a node based on a parameter - BRX

    Employee
    Posted 12-18-2014 07:41

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: stonysmith

    The one syntax you missed was:

    "{{*Populated*}}" == "abc" => this will look for a parameter in the *nix environment.

    You can set the value one of two ways:
    In a script, you can use:
    export p_Populated=abc
    #notice the p_ in front of the parameter name
    #the parameter name is case sensitive in both *nix and BRE
    or on the commandline:
    laeController -P p_Populated=abc ......... graph.brx ........
    and the parameter will be passed to the graph.


  • 5.  RE: Disable a node based on a parameter - BRX

    Employee
    Posted 12-18-2014 08:35

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: gmullin

    Originally posted by: Tim Meagher
    					

    Hi,

    It isn't possible to enable or disable a node within a BRX.
    Essentially, the enabled/disabled status of a node is determined prior to compiling the BRX.
    If the node is disabled at the time of saving the BRX, it won't get compiled into the BRX, otherwise it will get compiled and exist in the BRX.

    What are you trying to achieve with the enabling/disabling of the node?
    Perhaps there is another solution that will work for you.

    Tim.
    We have a graph that has to perform some conversion if a particular parameter is populated with a certain value. This has been working perfectly for BRG, but it looks like I need a new solution to convert this to BRX. I guess I will have to do some check and bypass if the parameter isn't set.

    Is there any way to manually add some code to the BRX in order to check that parameter, like put an if statement around that part of the BRX?


  • 6.  RE: Disable a node based on a parameter - BRX

    Employee
    Posted 12-18-2014 09:54

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: gmullin

    I have a solution for this that works when I compile the BRX:


    node:Filter
    bretype:core::Filter
    editor:sortkey=5492e19410e45488
    input:@40fd2c74167f1ca2/=Static_Data.40fe6c55598828e5
    output:@40fd2c7420761db6/=
    prop:Script=<<EOX

    emit '{{^FieldName^}}'
    EOX
    editor:XY=350,360
    end:Filter

    node:Output_BRD_File
    bretype:core::Output BRD File
    editor:sortkey=549020621a1e091a
    input:@40fd2c7476600190/=Filter.40fd2c7420761db6
    inclock:/=Meta_Check
    prop:File=/data/inout/FDS/input/FDS_lavasp02/Data/TEST/Output_Files/brx_test_run_{{^Table_Name^}}.brd
    editor:XY=590,360
    end:Output_BRD_File

    node:Static_Data
    bretype:core::Static Data
    editor:sortkey=5492e16e29877fa8
    output:@40fe6c55598828e5/=
    editor:XY=170,360
    end:Static_Data

    node:Filter_4
    bretype:core::Filter
    editor:sortkey=5492fdcc37444b1d
    input:@40fd2c74167f1ca2/=Dummy_Input.40fd2c7452fa204a
    output:@40fd2c7420761db6/=
    prop:Script=<<EOX
    result = if "{{^Populated^}}" == "abc" then 1 else 0
    emit result
    where result == 1
    EOX
    editor:XY=420,200
    end:Filter_4

    node:Dummy_Input
    bretype:core::Dummy Input
    editor:sortkey=5492fe45101a030e
    output:@40fd2c7452fa204a/=
    inclock:/=Filter
    prop:Header=x
    prop:NumberOfRecords=1
    editor:XY=280,200
    end:Dummy_Input

    node:Meta_Check
    bretype:core::Meta Check
    editor:sortkey=549304455bbb678c
    input:@43c285fc347d19f2/=Filter_4.40fd2c7420761db6
    output:549304a0433e30a5/out1=
    prop:MinimumRecordCount=1
    prop:SuccessAction=Clock
    prop:TerminusAction=Output
    editor:XY=530,200
    end:Meta_Check


  • 7.  RE: Disable a node based on a parameter - BRX

    Employee
    Posted 12-18-2014 11:04

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ejones

    Thanks. I've wondered about this myself. I suspected that enabling and disabling nodes was 100% decided at compile time. I had heard something that made me less sure of this, but never tested it for myself.

    So you've solved it. In this example, the last node of the set will either run or not run depending on a parameter. Essentially you are using a parameter to control whether or not the rest of the graph runs.


  • 8.  RE: Disable a node based on a parameter - BRX

    Employee
    Posted 12-19-2014 03:04

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: gmullin

    I'm not quite out of the woods yet. What I've mentioned above works fine if I have a value set, but if a parameter is blank I get the following error from my filter node:

    Parameter "Populated" is not defined. (Called from "Script").

    Is there a way to have the default value for a parameter to be blank and then have it overriden by whatever parameter we actually declare (if we declare a value). I see in the logisitics tab it works when I put in {{^Populated=^}} but it doesn't seem to work like that in the BRAINScript of the filter node.


  • 9.  RE: Disable a node based on a parameter - BRX

    Employee
    Posted 12-19-2014 05:46

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Tim Meagher

    Have you declared "Populated" as a Run Parameter in the Graph Parameters dialog for the graph prior to saving?
    Think that should then correctly substitute into the BRX that it expects the value to come from a run parameter when executing the graph.


  • 10.  RE: Disable a node based on a parameter - BRX

    Employee
    Posted 12-19-2014 07:58

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: lnason

    I'm not 100% clear on the requirements here.... but this seems like the kind of scenario where the use of the "Path Enabler" node is appropriate.

    I've attached a graph that will execute one of 3 paths of nodes depending on whether or not a graph parameter is populated and then if that parameter IS populated..it performs another test to compare the parameter to a specific literal value.

    The attached brp file has three different runs set up already so you can see how each path gets evaluated....for the case where the parameter is not defined I put in {{^^}} to set the parameter to an empty string.

    When it comes to running this outside of the BRE environment, I tested this successfully from Logistics Manager in cases where the parameter was left blank and where it had a value.

    It looks like you are using scripts to kick off the brx, so I know this isn't an apples to apples test....

    In your script I'd be interested to see what happens when you set TestParam to '' or if you set it to '{{^^}}'....you'd still need to override the value of the TestParam run parameter in the attached graph to {{*TestParam*}} before deploying the brx to your server.

    Luke

    Enable_Disable_Nodes_at_Run_Time.brg

    Enable_Disable_Nodes_at_Run_Time.brp


  • 11.  RE: Disable a node based on a parameter - BRX

    Employee
    Posted 01-15-2015 03:08

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: gmullin

    I just wanted to post a solution that I got off ejones and I found it very helpful because I can execute all nodes in my graph now, rather than splitting the graph into 2 paths and leaving some nodes that won't run in it.

    node:Static_Data_2
    bretype:core::Static Data
    editor:sortkey=54abc3e63927093e_3
    output:@40fe6c55598828e5/=
    editor:XY=810,150
    end:Static_Data_2
    
    node:Potential_Data_3
    bretype:core::Static Data
    editor:Label=Potential Data
    editor:sortkey=54abc3ee015a3fc9_3
    output:@40fe6c55598828e5/=
    prop:StaticData=<<EOX
    color:string,new_color:string
    Red,Purple
    EOX
    editor:XY=810,270
    end:Potential_Data_3
    
    node:No_Change_Color_Gate
    bretype:core::Filter
    editor:Label=No Change Color Gate
    editor:sortkey=54ac07ae7d8a2f03
    input:@40fd2c74167f1ca2/=Static_Data_2.40fe6c55598828e5
    output:@40fd2c7420761db6/=
    prop:Script=<<EOX
    if firstExec
    	then changeColor = bool("{{^Change_Colour=false^}}")
    
    emit *
    where not changeColor
    EOX
    editor:XY=980,150
    end:No_Change_Color_Gate
    
    node:Change_Color_Gate
    bretype:core::Lookup
    editor:Label=Change Color Gate
    editor:sortkey=54abc4975bba3012_3
    input:@40fd2c746abc6dc7/=Static_Data_2.40fe6c55598828e5
    input:@40fd2c74486e4494/=Potential_Data_3.40fe6c55598828e5
    output:@40fd2c7445835585/=
    prop:InputKey=<<EOX
    color
    EOX
    prop:LookupKey=<<EOX
    color
    EOX
    prop:Script=<<EOX
    if firstExec
    	then changeColor = bool("{{^Change_Colour=false^}}")
    
    color1 = if '2:new_color'.isNotNull() then '2:new_color' else '1:color'
    
    emit 1:*
    override emit color1 as color
    exclude referencedFields(2,{{^LookupKey^}})
    
    where changeColor
    
    EOX
    editor:XY=980,260
    end:Change_Color_Gate
    
    node:Cat
    bretype:core::Cat
    editor:sortkey=54ac07823edd2b21
    input:@40fd2c7476b11c42/=No_Change_Color_Gate.40fd2c7420761db6
    input:54ac07bd764a4ad3/out1=Change_Color_Gate.40fd2c7445835585
    output:@40fd2c74676e03c3/=
    editor:XY=1110,150
    end:Cat
    
    node:This_node_must_execute_under_any_condition
    bretype:core::Filter
    editor:Label=This node must execute under any condition
    editor:sortkey=54abc4f5351338e1_3
    input:@40fd2c74167f1ca2/=Cat.40fd2c74676e03c3
    output:@40fd2c7420761db6/=
    editor:XY=1210,150
    end:This_node_must_execute_under_any_condition


  • 12.  RE: Disable a node based on a parameter - BRX

    Employee
    Posted 05-11-2016 04:32

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: SteveTaylor

    Learnt a lot from this thread ... thanks all
    I'm running BRX graphs from LXAs in Explorer. I was trying to set the 'Enabled' parameter of nodes based on a runtime parameter, but can see now why this wasn't working. From the advice above, I've now successfully terminated certain threads of my analysis using the 'Meta Check' which works, except that in Explorer, the graph completes with an overall fail status, showing in the run history with a red cross - a little disconcerting for my users.

    The gate approach recommended above doesn't fit in my case as the threads of analysis I'm toggling between generally start independently e.g. with a Directory List or a file import.

    Any ideas? Many thanks.


  • 13.  RE: Disable a node based on a parameter - BRX

    Employee
    Posted 05-31-2016 08:37

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: gmullin

    Do you have the TerminusAction parameter in the Meta Check node to something other than NodeError?

    When you download the LXS and open in BRE can you get more information on where the error is in the graph?