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

Accessing Graph Parameters from a Python Node

  • 1.  Accessing Graph Parameters from a Python Node

    Employee
    Posted 08-20-2012 16:16

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

    Originally posted by: GreggB

    Hi,
    How do I access the Graph Parameters from a Python node?

    Thanks,
    Gregg.


  • 2.  RE: Accessing Graph Parameters from a Python Node

    Employee
    Posted 08-20-2012 21:05

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

    Originally posted by: stonysmith

    The simple way is to use the standard parameter substitution notation such as:

    t = "{{^MyParm^}}"

    However, if you defined the parameter and gave it a "Runtime Property Name" (RPN) then you can read it that way

    t = self.properties.getString("ls.node.MyNode.MyParm", "defaultvalue")

    where ls.node.MyNode.MyParm is the name that you put in the RPN

    Check the python node help for other data types you can retrieve.


  • 3.  RE: Accessing Graph Parameters from a Python Node

    Employee
    Posted 08-21-2012 13:40

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

    Originally posted by: GreggB

    Thanks... never thought I could use normal parameter substitution in Python node. I was going after the "property" by its parameter name, and getting nothing - assigning a RPN fixed that.

    I see that I can also use the setProperty() method, but it doesn't seem to "stick". Is there a way of making a permanent change to a Graph Parameter from a Python node? (other than editing the .BRP file).

    Thanks,
    Gregg.


  • 4.  RE: Accessing Graph Parameters from a Python Node

    Employee
    Posted 08-21-2012 14:00

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

    Originally posted by: stonysmith

    Sorry.. none that I know of.

    There is a way to have one node write out a text file and then use that as input later in other nodes as an "Indirect" parameter type, but I don't know if that will fulfill your need or not.


  • 5.  RE: Accessing Graph Parameters from a Python Node

    Employee
    Posted 08-22-2012 09:57

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

    Originally posted by: GreggB

    The "Indirect" parameter sounds interesting. Are they usable with all node types?

    What I am doing is running a number of graphs that extract and process data based upon a date range. Currently the start and end dates are graph parameters used by several nodes in each of the graphs. I am currently running the graphs weekly on a desktop PC. To avoid typos when I update the graph parameters in each of the graphs, I have written a Python script that calculates the date range then updates the appropriate BRP files.

    At some point I will be running these graphs on a server as a scheduled job. I could include my Python script in the job, but thought it would be better if it were encasulated in a graph - hense my original question: a way to get the directory containing the BRPs to the python node.

    So if there is a way to get parameters into a node from a file, then I could avoid updating the BRPs all together. A quick look in the documentation didn't reveal anything about "indirect parameters". Could you provide more info.

    Thanks,
    Gregg.


  • 6.  RE: Accessing Graph Parameters from a Python Node

    Employee
    Posted 08-22-2012 17:58

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

    Originally posted by: stonysmith

    Attached is a graph that computes two dates and then uses them inside an Oracle query.
    In the filter node, you could have any level of complication for computing the dates.
    Attachments:
    DynamicQuery.brg


  • 7.  RE: Accessing Graph Parameters from a Python Node

    Employee
    Posted 08-23-2012 19:03

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

    Originally posted by: Adam Williamson

    Hot tip (correct me if I wrong) the DB Execute node will run once becuase there is only one row of data. Be careful not to pump multple records into the node if you desire it to only run once.


  • 8.  RE: Accessing Graph Parameters from a Python Node

    Employee
    Posted 08-29-2012 13:31

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

    Originally posted by: GreggB

    Actually, the query is the easy part... One of the dates is used downstream by some filter nodes. I used a Look-up node to inject the date into the data after the main query (and re-inject after a couple of other queries) so that it could be used by the filters. (As far as I know, there is no way of getting a filter to take two inputs?)

    I only ran into trouble when I got to the Excel output - the start-date paramater was used as part of the file name. I can use moveFile() to re-name the files, but the problem becomes waiting until the files are written before running the node that does the re-names. Asuming that I am the right track, should I open a new thread with that question?

    Thanks,
    Gregg.


  • 9.  RE: Accessing Graph Parameters from a Python Node

    Employee
    Posted 08-30-2012 06:51

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

    Originally posted by: rboccuzzi

    Gregg, you are on the right track, moving the file is the correct approach for now. There is a multi-file output node in the prototype lab, called "Output Delimited (multifile) that can solve that as well. We are in the process of creating an "Output Raw" node that could possibly help you as well; but might not, as it is unformatted output, you would have to format your output to a string field first.

    Cheers
    Rich


  • 10.  RE: Accessing Graph Parameters from a Python Node

    Employee
    Posted 09-04-2012 11:06

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

    Originally posted by: rpigneri

    Originally posted by: GreggB
    					

    What I am doing is running a number of graphs that extract and process data based upon a date range. Currently the start and end dates are graph parameters used by several nodes in each of the graphs. I am currently running the graphs weekly on a desktop PC. To avoid typos when I update the graph parameters in each of the graphs, I have written a Python script that calculates the date range then updates the appropriate BRP files.

    At some point I will be running these graphs on a server as a scheduled job. I could include my Python script in the job, but thought it would be better if it were encasulated in a graph - hense my original question: a way to get the directory containing the BRPs to the python node.
    Gregg,

    Do you know the start and end dates before the graph is run? Do they stay static throughout the graph execution? If both of those conditions are true, then you could input them into the graph as run parameters. Unlike the RPN's, these parameters are defined via the Graph->Edit Parameters->Parameter Declarations dialog but are set when the graph is run. This is particularly useful in scheduled runs since you can include them on the command line as you invoke the controller.

    Hope that helps,

    Rocco


  • 11.  RE: Accessing Graph Parameters from a Python Node

    Employee
    Posted 10-23-2012 08:03

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

    Originally posted by: GreggB

    Hi Rocco,
    I wrote a graph that generates the dates and puts them into a brx file. I then re-factored the other graphs so that the dates are inserted into the data stream using a lookup node. Another graph reads the date brx and renames the output.

    For the batch runs on the server, passing run parameters by the command line would probably have been easier, but I was not aware of this feature. Is it new in 4.5? Where is it documented?

    Thanks,
    Gregg.


  • 12.  RE: Accessing Graph Parameters from a Python Node

    Employee
    Posted 10-24-2012 08:28

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

    Originally posted by: rboccuzzi

    Gregg, this is not a new feature...you can see the usage help if you run the controller with a -h or -help option. It has an extensive amount of information that it produces here, so you might have missed it. I have simplified to highlight this functionality:

    >laeController -h
    Usage: laeController [--help] [options]

    [ Stuff deleted for brevity...]


    usage: Controller [-P <property>=<value>] [-a <argument>=<value>] [-u <username>] [-p <password>] [-
    s <brs file>] [-dump <brs dump>] [-r <run name>] [-v] <brx file>


    Options:
    -P <property>=<value> Set property to value
    -a <argument>=<value> Set runtime argument to value

    [ Stuff deleted for brevity...]



    Unfortunately, I do believe the Run Time Parameter help that can be found from within BRE does not mention this; I have filed a bug to note this disconnect on documentation (PR is #4265).

    Cheers
    Rich


  • 13.  RE: Accessing Graph Parameters from a Python Node

    Employee
    Posted 10-24-2012 09:49

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

    Originally posted by: GreggB

    Thanks Rich, but it's still not totally clear...

    I presume the -P switch assigns a value to a "Run Time Property Name" which is assosiated with a "Run Time Parameter". So that leaves me wondering what a "Runtime Argument" is?

    Thanks,
    Gregg.


  • 14.  RE: Accessing Graph Parameters from a Python Node

    Employee
    Posted 10-25-2012 11:57

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

    Originally posted by: rboccuzzi

    Sorry Gregg, understandable that it isn't clear; as mentioned, the doc is a bit out of date... if you use the Graph Parameters dialog, and change a parameter declaration to a Run parameter, then you should be using the -a, for a run time argument. The -P is a run time property, which generally isn't what you want. I think if you actually code the property use in a node as {{*foo*}} then you could use -P, but generally the -P is for the LAE properties (the ones in the prop files, or in the environment variables; the ones that the setBrainEnv.bat or lavastorm.cshrc setup).

    Cheers
    Rich