This deprecated node accesses the Python API to perform tasks that cannot be accomplished via standard nodes. Runs Python code within a node.
CAUTION:
This node has been deprecated and will not be supported in a future release.
The Python node allows you to write Python code to process node inputs and produce output data, and is typically suited to fast prototyping of complex logic. The Python node is targeted at advanced users who have some experience of writing Python code, or advanced Python programmers who have some experience of using Data360 Analyze. Although the Java node has better performance than the Python node for large data sets, there are several advantages of using the Python node over the Java node:
- The nature of the Python language may make it better suited for quick prototyping. While the Java node has performance benefits over the Python node, it is generally quicker to implement functionality in Python due to the nature of the language. For prototyping, and for nodes that will not need to operate on large data sets, the Python node can be ideal.
- You can use the Python node with third party Python libraries that already have the implemented complex algorithms and logic that you need, including functionality that is not freely or easily available in Java libraries.
- You can make use of the powerful Data360 Analyze Script language, see [%=GeneralProduct%] Script help.
In order to understand the Python programming language, there are numerous books, manuals and online sources of information, for example, the official Python website: http://www.python.org/.
For more detailed information on configuring the Python node, see Python node configuration.
The API for the Python node
braininfo module
loadModule(filename, moduleName) |
- Import a file to a module, must follow with "import moduleName"
|
braininfo.BrainNodeException |
- Use directly to throw exceptions, or inherit from for specific types of exceptions
|
BrainNodeControl
members |
|
methods |
- logInfo(msg), logLow(msg), logMedium(msg), logHigh(msg)
- setSuccessReturnCode(code) - set the return value of the node (on success)
- getSuccessReturnCode() - get the value that will be returned on success of the node
|
BrainNode (which you inherit from)
members |
- properties
- inputs - list of inputs, type BrainInput
- outputs - list of outputs, type BrainOutput
|
methods |
- newMetadata( ) - return empty BrainMetadata instance
- initialize( )
- finalize( )
- pump(BrainQuantObj)
- logInfo(msg), logLow(msg), logMedium(msg), logHigh(msg)
|
BrainInput
members |
- name
- index
- node - the BrainNode object that created it
- _signature - type BrainSpec
- coerce - bool, whether type coercion is allowed on records returned from read
- metadata
- consume - consume the remaining data on the input.
|
methods |
- read( ) - returns object of BrainRecord
|
BrainOutput
members |
- name
- index
- node - the BrainNode object that created it
- _signature - type BrainSpec
- coerce - bool, whether type coercion is allowed on records returned from newRecord
- metadata
|
methods |
- outputIf(conditional) - only perform writes if the conditional is true
- newRecord( )
- write(record) - if the metadata has not been assigned, will figure out metadata on first call
|
BrainSpec
methods |
- inherited from tuple, all tuple operations
- mapFrom(otherSpec)
- mapTo(otherSpec)
- equivalent(otherSpec) - true if there is a one-to-one mapping from all fields in otherSpec
- supersetOf(otherSpec)
- subsetOf(otherSpec)
- == vs "is" - use global "is" for signatures, faster....signatures are guaranteed to be the same instance if they are ==
|
BrainQuant
methods |
- permitsRunning(BrainNode ) - returns True if your quantum has not expired, pass self as first arg
|
BrainRecord
members |
- _input - the input that last populated the record. Only present if record has ever been populated by input.read( )
- every field name - for both getting and setting, refer directly to field name as member (ie, rec.col1 = rec.col2 + 5), names mangled as follows: any non-alphanumeric is mapped to _, leading underscore or digit is prefixed by c_.
If there are collisions, last field is one accessible, use subscripting for others.
- _signature - type BrainSpec
|
methods |
- _copyFrom(record) - take a record, and for any data that exist in self, copy that data into self.
- _clone( ) - create a new instance of BrainRecord, with all the same data in it as in self
- _number( ) - if read from an input, the 1-based number of the record, otherwise 0
- global len( ) support
- [index or name] - subscript record by index or name for each field, case insensitive
|
BrainMetadata
members |
- recordClass
- strings, ints, longints, dates, times, doubles, bools, all
- each are lists of tuples (name, type). Each member has only the appropriate fields of that type
|
methods |
- clone( )
- clear( )
- newRecord()
- setupRecordClass()
- global len( ) support
- [index or name] - subscript works by both index and name of field, returns tuple (name, type)
- append(name, type)
- name(idx)
- type(idx or name)
- find(name) - idx of field, -1 if not found
- remove(idx or name)
|
Properties - object found both in BrainNodeControl and BrainNodeClass
members |
- (used for getFilename, getDirectory)
- FS_NoCheck, FS_Exists, FS_NotExists
- FS_Read, FS_Write, FS_Execute
- FS_ReadWrite, FS_ReadExecute, FS_CheckAll
|
methods |
- default is always optional...will throw exception if no default given and not found
- isSet(name), isArray(name)
- standard accessors (default is optional, will throw exception if no default and not found):
- getString(name, default), getProcessedString(name, default)
- getBool(name, default)
- getInt(name, default), getInt64(name, default)
- getArray(name, default)
- getFilename(name, check), getDirectory(name, check) - check defaults to FS_NoCheck, FS_Exists respectively
- getPropertyNames( )
- resolvesTo(name)
- setPropertyFromLine(lineOfText)
- setProperty(name, value)
- [name] - alias for calling getString(name)
|
Properties
PythonCodeOnServer
Specify whether to use the python1 code that exists on the server, but disable customizing python1 behavior. This will reduce the size of BRXs.
The default value is True.
Inputs and outputs
Inputs: Multiple optional.
Outputs: Multiple optional.