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
  • 1.  How to avoid �parameter <�> is not defined� error

    Employee
    Posted 08-03-2010 22:20

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

    Originally posted by: mzhao

    I try to develop a library node based on core::python. In this node I need to simulate the input behaviour of the core::Delimited File node:
    1. By default, it does not have an input pin. The input file name is provided by a parameter named File, which is declared in this node as string type, none validator.
    2. When drag the output pin of another node and drop into this node, it will create an input pin and the node will read input from self.inputs.

    The node worked fine in scenario 1. However in scenario 2 where the parameter File was not used, it didn�t have a value. Executing the node would trigger an error �Parameter <File> is not defined�. The error was triggered by a line of code inFile = "{{^File^}}" in Python2Implementation.

    I added ls.brain.node.tailFile.CreateTail.InputPath to the File parameter�s Run Time Property Name, and replaced the code with
    inFile = self.properties.getString("ls.brain.node.tailFile. CreateTail.InputPath", None)
    but received the same error.

    It looks like when a parameter is declared, it must a value. That doesn�t suit my purpose. Is there any way to avoid this?


  • 2.  RE: How to avoid �parameter <�> is not defined� error

    Employee
    Posted 08-04-2010 02:00

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

    Originally posted by: Tim Meagher

    Hey,

    First, using the {{^File^}} implementation means that the property substituter will go through and attempt to substitute in the property prior to analyzing any of the python code. This is true for any case when you use the {{^^}} notation.
    You can always set defaults to use in case the property isn't set, for example {{^File=NotDefined^}} or something similar. In this case, rather than the node failing straight away, if the File parameter is not defined, then the default of NotDefined is used.

    Using the run time properties means within the python code means that the property is only attempted to be obtained if that line of code is ever executed.

    You can try a similar thing by providing a default value (other than None) such that this won't throw an error if the property isn't defined - e.g. in your case, this could be something like:

    inFile = self.properties.getString("ls.brain.node.tailFile. CreateTail.InputPath", "NotDefined")
    However, this isn't really the best way.
    Since the property isn't searched for unless the code reading it is executed, the best way to handle this is simply to make sure that this code isn't executed if you have an input pin.

    This can be done using the following logic:

    if len(self.inputs) == 0:
    	#Should attempt to read file parameter here
    else:
    	#Attempt to read the stuff from input pin
    Without knowing exactly what the use case is, this seems like it should fit with what you want to do.
    I've attached a graph with a working example, which just spits out text onto the output pin, dependant on whether or not an input pin was present.
    Attachments:
    inputPinOrParmeter.brg


  • 3.  RE: How to avoid �parameter <�> is not defined� error

    Employee
    Posted 08-04-2010 17:12

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

    Originally posted by: mzhao

    Hi Tim,

    Thank you very much for the prompt response. Actually I came very close to the solution you have suggested, except in the self.properties.getString function, I had none instead of "NotDefined". The python code works now after the replacement.

    It took me long time, a lot of guesswork, as well as asking around, to work on this part of BRAIN. Your assistance is valuable and highly appreciated. However is that any documentation available in addition to the core.brg help library?


  • 4.  RE: How to avoid �parameter <�> is not defined� error

    Employee
    Posted 08-09-2010 11:32

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

    Originally posted by: rboccuzzi

    Aside from the help on the core library, there is help on BRE and BRAINscript...some of the BRE help deals with parameters. To access that help, inside of BRE, click on the Help menu, and then choose BRE Help.

    When IE comes up, take a look at the contents on the left, and check out the Parameters section. Additionally, you can find more help in the online Training Guide, that gets installed with our product. Inside the start group, look under documentation.

    Cheers
    Rich