Server

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

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

class Server.ClassifyHandler(application, request, **kwargs)[source]
executor = <concurrent.futures.thread.ThreadPoolExecutor object>[source]
max_workers = 4[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]
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.

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.TrainingHandler(application, request, **kwargs)[source]
get()[source]
post(*args, **kwargs)[source]

Handles training of an engine based on new supplied data via HTTP Post. WIP, lots of internal bugs right now. Requires that the config is already loaded in, and that the training and dev data are supplied in the h5 format. :param args: :param kwargs: :return: JSON of training results.