Konduit Serving supports specifying server configurations as YAML files. This allows you to serve simple server configurations using the Konduit Python CLI and the konduit.load module.
YAML components
A Konduit Serving YAML configuration file has three top-level entities:
serving
steps
client
The following is a sample YAML file for serving a Python script located at simple.py which takes a NumPy array first as input and returns a NumPy array second as output:
The server configuration, serving takes the following arguments:
http_port: specify the port number
listen_host: the host of the Konduit Serving instance. Defaults to http://localhost.
Additional arguments include:
uploads_directory: Directory to store file uploads. Defaults to 'file-uploads/'.
jar_path: Path to the Konduit Serving uberjar. Defaults to the KONDUIT_JAR_PATH environment variable, or if unavailable, ~/.konduit/konduit-serving/konduit.jar.
log_timings: Whether to log timings for this config. Defaults to False.
extra_start_args: Java Virtual Machine (JVM) arguments. In this case, -Xmx8g specifies that the maximum memory allocation for the JVM is 8GB.
Refer to the Server documentation for other arguments.
Client
The client configuration takes the following arguments:
port: specify the same HTTP port as serving.
host: defaults to http://localhost. Ignore this argument for local instances.
Typically it is sufficient to specify the port and hostas the remaining attributes are obtained from the Server. Refer to the Client documentation for details.
input_names, output_names: names of the first and final nodes of the Konduit Serving pipeline configuration defined in the Server.
output_data_format: the format of the server's input and output. Specify one of the following: JSON, NUMPY, ARROW, IMAGE, ND4J.
Steps
Python steps
Python steps run code specified in the python_code (a string) or python_code_path (a .py script) argument. Python steps defined in the YAML configuration default to input name and output name "default".
Importantly, the python_inputs argument maps each input and output variable to the respective data type. Accepted data types are INT, STR, FLOAT, BOOL, NDARRAY.
If no Python path is specified, NumPy will still be available in the environment where the Python step is run.
To further customize Python steps, refer to the YAML configuration section of the Python pipeline steps page.
On the server, start a Konduit Serving instance by:
creating a Server object using server_from_file,
starting the server using the .start() method.
After the server has started, on the client:
create a Client object using client_from_file; and
use the .predict() method to perform inference on a NumPy array (note that the input name of this Server configuration is default, therefore we can pass a NumPy array directly to the .predict() method.).
Finally, stop the server with the .stop() method:
This can also be run in the command line. In the root folder of konduit-serving-examples, initialize the Konduit Serving instance with
Send the NPY file to the server for inference with