tomaat.server package

Submodules

tomaat.server.service module

class tomaat.server.service.TomaatApp(preprocess_fun, inference_fun, postprocess_fun)[source]

Bases: object

A TomaatApp is an object that implements the functionality of the user application. More specifically, this object implements the workflow that is needed by the app. It requires the following arguments

class tomaat.server.service.TomaatService(config, app, input_interface, output_interface)[source]

Bases: object

announcement_task = None
gpu_lock = <twisted.internet.defer.DeferredLock object>
interface(request)[source]
klein_app

L{Klein} is an object which is responsible for maintaining the routing configuration of our application.

@ivar _url_map: A C{werkzeug.routing.Map} object which will be used for
routing resolution.

@ivar _endpoints: A C{dict} mapping endpoint names to handler functions.

make_error_response(message)[source]

Create simple error message to be returned to the client as plain text :type message: str error message to be returned to the client :return: response to be returned to client

make_response(data, savepath)[source]

This function takes in the post-processed results of inference and creates a message for the client. The message is created according to the directives specified in the output_interface dictionary passed during instantiation of TomaatService object. :type request: dict containing the inference results (stored in the appropriate fields) :return: JSON containing response that can be returned to the client

parse_request(request, savepath)[source]

This function takes in the content of the client message and creates a dictionary containing data. The service interface, that was specified in the input_interface dictionary specified at init, contains the specifications of the data that is needed to run this service and the fields of the dictionary returned by this function where the client data should be stored. :type request: dict request sent by the client :return: dict containing data that can be fed to the pre-processing, inference, post-processing pipeline

predict(**kwargs)[source]
received_data_handler(request)[source]
run()[source]
start_service_announcement(fun=<function do_announcement>, announcement_server_url='http://tomaat.cloud:8001/announce', delay=1600)[source]
stop_service_announcement()[source]
class tomaat.server.service.TomaatServiceDelayedResponse(no_concurrent_thread_execution=True, **kwargs)[source]

Bases: tomaat.server.service.TomaatService

announcement_task = None
gpu_lock = <twisted.internet.defer.DeferredLock object>
interface(request)[source]
klein_app

L{Klein} is an object which is responsible for maintaining the routing configuration of our application.

@ivar _url_map: A C{werkzeug.routing.Map} object which will be used for
routing resolution.

@ivar _endpoints: A C{dict} mapping endpoint names to handler functions.

multiprocess_lock = <Lock(owner=None)>
multiprocess_manager = <multiprocessing.managers.SyncManager object>
predict(**kwargs)[source]
received_data_handler(request)[source]
reqest_list = <ListProxy object, typeid 'list'>
responses(**kwargs)[source]
responses_data_handler(request)[source]
result_dict = <DictProxy object, typeid 'dict'>
tomaat.server.service.do_announcement(announcement_server_url, message)[source]
tomaat.server.service.is_base64(s)[source]

Module contents