...
Code Block | ||
---|---|---|
| ||
{ "streams": [ { "slot": 0, "name": "rest", "eof": false, "descriptor": { "Transport": { "secured": false, "roundtrip": true, "port": 9003, "Type": "REST", "Mode": "simple" }, "Schema": "$inherit", "Name": "rest", "Encoding": "JSON", "Description": "Application Restful Endpoint" } }, { "slot": 1, "name": "rest_out", "eof": false, "descriptor": { "Transport": { "Type": "synthetic" }, "Schema": "$inherit", "Encoding": "JSON" } } ], "state": "running", "model": { "source": "[model source code...]", "snapshots": "none", "slots": [ { "slot": 0, "schema": null, "recordsets": false, "action": "action" }, { "slot": 1, "schema": null, "recordsets": false, "action": null } ], "name": "test_model.py", "mtype": "python3", "attachments": [] }, "jets": [ { "sandbox": "123472369", "pid": 55, "busy": false } ], "initialTags": [], "group": "modelop" } |
Model Definition Injection
Both the python and R runners support an optional parameter for the init function. Normally, the init function is defined with 0 arguments, but if a single argument is defined, the runner will populate that argument with a ‘model definition’ object. In python, this object is a dictionary. In R, this object is a list. In both cases, the object has two keys. There will be a ‘rawJson’ key that contains the unparsed json string that contains either the job or the deployedModel object in its serialized form. There will also be either a ‘job’ or a ‘deployedModel' key, the value of which will either be a deserialized job or deployedModel object. In python, the deserialized job or deployedModel will be the result of calling json.loads()
on the contents of the ‘rawJson’ field. In R, it will be the result of calling the jsonlite fromJSON
function.
Python:
Code Block | ||
---|---|---|
| ||
def begin(model_def):
print(model_def['rawJson'])
print(model_def['job']) |
R:
Code Block | ||
---|---|---|
| ||
begin <- function(model_def) {
print(model_def$rawJson)
print(model_def$deployedModel)
} |
To see an example of the above, go to https://github.com/merhi-odg/model_definition_test.
Adding Endpoints to the ModelOp Runtime
To add endpoints to the ModelOp Runtime:
Open the ModelOp Runtime to which you want to add endpoints
Select the “Create Endpoint” button for either the input or output endpoints
...
3. Select to add an endpoint, either REST or Kafka
...
4. Add a Name, optional Description, Encoding type, and optional port. Select “Save Endpoint”
...
5. Repeat for the Output Endpoint, as required.
Adding Tags to a ModelOp Runtime
Open the ModelOp Runtime to which you want to add tag(s).
In the “tags” section begin typing the tag that you would like to add:
...
3. Once done typing, either hit enter on your keyboard or click your mouse in any other location on the screen.
4. Select the “Update Engine” button in the top right to save changes.