The Server module manages connections via HTTP. It is especially tuned to work well with multiple engine instances at once. Initiated via with a Server config. Here’s a basic config:

#!returnn/ task = “server” port = 10687 max_engines = 2 network = {“out” : { “class” : “softmax”, “loss” : “ce”, “target”:”classes” }}

class Server.ClassificationRequest(data)[source]
class Server.Model(config_file)[source]
class Server.Server(global_config)[source]

Initializes the server with an empty config. :param global_config: Basic config of server. Requires a network paramater.

class Server.ClassifyHandler(application, request, **kwargs)[source]
initialize(models, **kwargs)[source]
post(*args, **kwargs)[source]

Method for handling classification via HTTP Post request. The following must be defined in the URL paramaters: engine_hash (engine hash which points to which engine to use), and the data itself in the body. If using binary data, the following URL paramaters must also be supplied: data_format=’binary’, data_shape=(<dim1,dim2>). If using a specific data type, you can supply it as the url parameter data_type. :param args: :param kwargs: :return: Either JSON with error or JSON list of generated outputs.

class Server.ConfigHandler(application, request, **kwargs)[source]
load_config_lock = <Lock _block=<tornado.locks.BoundedSemaphore object at 0x7f21e74cf898 [unlocked,value:1]>>[source]
initialize(config_dir, models, **kwargs)[source]
post(*args, **kwargs)[source]

Handles the creation of a new engine based on a slightly modified config, supplied via HTTP Post. The request requires 1 URL parameter: new_config_url, which points to a URL (can be local) from where to download the config. This call is blocking.

WARNING All configs must have the following added: extract_output_layer_name = “<OUTPUT LAYER ID>” :param args: :param kwargs: :return: ASCII encoded hash of the new engine based on the provided config.