Overview
Py Source Code (against 1262)
import brahms import numpy ... out = brahms.operation(persist['self'], OP, ...)

Operations are the mechanism through which Python Processes can request framework-functionality of this binding. Specifically, operations expose the SystemMLInterface, the Message Log, Utility classes, and Peer State. OP should be an operation constant (below) indicating the operation; remaining arguments are operation-specific.

Notes
  • Contents and Utility Function Arguments must be contiguous numpy arrays in FORTRAN order (read/write). The only exception is that Utility Functions will also accept strings (read-only).

Operations

Each operation takes the same first two arguments: the self member of persist (to identify the caller), and an operation code constant. Remaining additional arguments are operation-specific. The operation code can be any of those listed below. If the operation has a result, it is returned as the return value of brahms.operation().

Input/Output

OPERATION_ADD_PORT
Takes three arguments, the set name (can be the empty string for the default set), the SystemML class name and the structure of the new data object in a form suitable to be passed to EVENT_GENERIC_STRUCTURE_SET. Two additional arguments are optional: a name for the new port, and the sample rate of the new port. For example, persist['hPort'] = brahms.operation(persist['self'], OPERATION_ADD_PORT, '', 'std/2009/data/numeric', 'DOUBLE/REAL/1', 'out'). The returned port handle can be passed to OPERATION_SET_CONTENT whilst servicing EVENT_RUN_SERVICE.
OPERATION_SET_CONTENT
Takes two arguments, a port handle (returned from OPERATION_ADD_PORT) and the numeric array to set the output state to. For example, brahms.operation(persist['self'], OPERATION_SET_CONTENT, persist['hPort'], numpy.array([1, 0, 0, 1], numpy.float64)).

Reporting

OPERATION_BOUT
Takes two additional arguments, a message and a DetailLevel. For example, brahms.operation(persist['self'], OPERATION_BOUT, 'Viva La Revolucion', D_INFO).

Utility Objects and Functions

Notes
  • Why are objects exposed to the Python Process, when all it can call are functions?
    • Utility Objects may be stateful, so a Process may wish to maintain more than one, and it may be important which is called.
OPERATION_GET_UTILITY_OBJECT
Obtain a Utility Object. Takes two additional arguments, the SystemML Class and SystemML Release of the required object. The return value of the call is a handle to the new object that can be passed to OPERATION_GET_UTILITY_FUNCTION. For example, persist['math'] = brahms.operation(persist['self'], OPERATION_GET_UTILITY_OBJECT, 'imaginary/math/class', 0).
OPERATION_GET_UTILITY_FUNCTION
Obtain an interface to a function offered by a Utility Object obtained in a previous call to OPERATION_GET_UTILITY_OBJECT. Takes two additional arguments, the utility object handle, and the name of the function you are requesting. The return value of the call is a handle to the new function that can be passed to OPERATION_CALL_UTILITY_FUNCTION. For example, persist['sum'] = brahms.operation(persist['self'], OPERATION_GET_UTILITY_FUNCTION, persist['math'], 'sum').
OPERATION_CALL_UTILITY_FUNCTION
Call a Utility Function obtained in a previous call to OPERATION_GET_UTILITY_FUNCTION. Takes two additional arguments, the identifier of the function to be called, and a cell vector of arguments for the function. The return value of the call is the result returned by the utility function. For example, total = brahms.operation(persist['self'], OPERATION_CALL_UTILITY_FUNCTION, persist['sum'], numpy.array([1, 2, 3], numpy.float64)) (where we expect total to be equal to numpy.array([6], float64) after the function returns).