Workflow example with Python processing and Python Connector agents
Workflow Configuration
The sections below provide descriptions of agent configurations for this example workflow.
WS_Handler
The Analysis agent is configured to handle requests from the web services agent. The request is translated into a format required by the machine learned model. Responses from the model are sent back to the web services agent as the result of the prediction.
The Python processing agent processes UDRs by defining a consume block, and uses the selected Interpreter profile that is used to configure the Python executables.
...
Info
title
Example - Code for Predict
Code Block
import pickle
model = None
targets = None
def consume(input):
if isinstance(input, InstallModel):
global model, targets
model = pickle.loads(input.model)
targets = input.targets
elif isinstance(input, PredictObservation):
if model:
idx = model.predict([input.observation])[0]
input.prediction = targets[idx]
else:
input.prediction = 'please install model'
if input.testing:
debug(input)
udrRoute(input, 'test_prediction')
else:
udrRoute(input, 'prediction')
Python_Connector
The Python Connector agent is configured to bind on port 3810 from which the data will be received. The types accepted for routing are PredictObservation (Iris.UFL_Types) and InstallModel (Iris.UFL_Types) on route r_1.