Create Operators with the Python Subengine
Create operators in Python using the Python subengine, and use them to build graphs in the SAP Data Intelligence Modeler.
When you run a graph in the Modeler, the main engine that coordinates all subengines breaks the graph into large subgraphs. The advantage is that every operator in the same subgraph is run by the same subengine. The main engine then starts a subengine process for each subgraph.
Data Type Mapping
The following table shows the data type mapping between the Modeler and the Python subengine.
|
Modeler Data Type |
Python Subengine Data Type |
|---|---|
|
string |
str |
|
blob |
bytes |
|
int64 |
int |
|
uint64 |
int |
|
float64 |
float |
|
byte |
int |
|
message |
Message |
|
[ ]x Replace the letter x with any of the allowed data types, excluding message. For example, [ ]string, [ ]uint64, [ ]blob, and so on. |
list |
-
body can be any object.
-
attributes is a dictionary-mapping string to any object.
If m is an object of type message, then you can use the commands m.body and m.attributes to access the fields initialized in the class constructor. The attributes argument is optional in the message constructor. If you want an empty attributes string, you can construct your message using the format Message(body).
Therefore, SAP recommends to always prefer dictionaries over messages inside the body of a message, because it won't change type during the communication.
# DO NOT DO THE FOLLOWING:
inner_msg = Message("body_of_inner_msg")
outer_msg = Message(body=inner_msg, attributes={})
# If you want to have a message as the body of another message, do this instead:
inner_msg = {"body": "body_of_inner_msg"}
outer_msg = Message(inner_msg)
Methods to Create Python Operators
-
Normal usage: To create normal Python subengines, use only the Modeler user interface.
-
Advanced usage: To create new Python operators, use the advanced method, which shows you how to use your own machine and then upload the new operators to SAP Data Intelligence. The advanced usage method of creating operators is useful when you want to code in your own IDE and create unit tests for your operators.