Running code using the REST API

The Container Core

Core is the only container doing code execution. Also ModelsAPI uses the Core container to execute the code. The core may compile if necessary and create a runtime session if necessary.

Calling Core

Calling Core has four possible forms as explained in Function calls. Two forms for getting the result from either calling exec from a block or a query (a constant included in the API call). Also, the same two forms but assigning the result to a block in a container.

Bases in Core

Bop has four bases, three of them are the same bebop, bop and compile. The fourth is onnx that tells the Core that the snippet has no source code, it is just an ONNX model created with any tool that can export to ONNX. In that case, the snippet can be just a block with a vector of bytes (a file).

Fields in Core

The Core uses Fields (a Service that supports basic persisted key/value functionality) to store the snippets in namespaces (each namespace is a field, Fields is the service that stores them all). These spaces are persisted in a configurable database. You create a new space with //bop/field_name.new like in any other container.

Snippets in Core

Snippets are persisted as a Snippet object and either compiled or decompiled at creation. From source (compiled), just use the bebop, bop or compile and pass the source as text as a const or in a block. From an ONNX model (decompiled), use the onnx base and pass the model as a block containing a vector of bytes (a file).

ONNX-runtime session management

A call that runs a snippet is using an ONNX runtime session. Sessions are created and destroyed as needed. The number of sessions is limited by a configurable parameter. From inside Bebop, it is possible to control how a function call is executed (use/deploy a session or merge the source code of the function with the caller). From the API, it is always using a session, creating it if necessary.

Configuring Core

Core has configurable parameters:

Property description
FIELD_STORAGE_ENTITY Name of the database where the Core stores the Fields data.
SNIPPET_STORAGE_ENTITY Name of the database where the Core stores the Snippet data.
ONNXRT_MAX_NUM_SESSIONS The maximum number of simultaneously open ONNX runtime sessions.