YAML configurations
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:
Serving
The server configuration, serving
takes the following arguments:
http_port
: specify the port numberlisten_host
: the host of the Konduit Serving instance. Defaults tohttp://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 theKONDUIT_JAR_PATH
environment variable, or if unavailable,~/.konduit/konduit-serving/konduit.jar
.log_timings
: Whether to log timings for this config. Defaults toFalse
.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 asserving
.host
: defaults tohttp://localhost
. Ignore this argument for local instances.
Typically it is sufficient to specify the port
and host
as 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.
Python pipeline stepsA more comprehensive example is available on the following page:
Open Neural Network Exchange (ONNX)Model steps
Use model steps when you want to use pre-packaged modules such as TensorFlow, DL4J and PMML for inference.
The following parameters should be specified:
type
: one ofTENSORFLOW
,KERAS
,COMPUTATION_GRAPH
,MULTI_LAYER_NETWORK
,PMML
,SAMEDIFF
;model_loading_path
: location of your model file;input_names
: list of the names of input nodes of your model file;output_names
: list of the names of output nodes of your model file;input_data_types
: map each of the input nodes to one of the following data types using the input names as keys:INT
,STR
,FLOAT
,BOOL
,NDARRAY
.
Refer to the model-specific example for details on configuring model steps.
TensorFlow (1.x)Keras (TensorFlow 2.0)Usage
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
; anduse the
.predict()
method to perform inference on a NumPy array (note that the input name of this Server configuration isdefault
, 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
and finally, stop the server with
Resources
Some resources on the YAML format:
Last updated