MLaaS.tfaas_client

File : tfaas_client.py Author : Valentin Kuznetsov Description: simple python client to communicate with TFaaS server

Module Contents

Classes

OptionParser

HTTPSClientAuthHandler

Simple HTTPS client authentication class based on provided key/ca information

MultiPartForm

Accumulate the data to be used when posting a form.

Functions

x509

Helper function to get x509 either from env or tmp file

check_auth

Check if user runs das_client with key/cert and warn users to switch

fullpath

Expand path to full path

choose_boundary

Helper function to replace deprecated mimetools.choose_boundary https://stackoverflow.com/questions/27099290/where-is-mimetools-choose-boundary-function-in-python3 https://docs.python.org/2.7/library/mimetools.html?highlight=choose_boundary#mimetools.choose_boundary

models

models API shows models from TFaaS server

delete

delete API deletes given model in TFaaS server

bundle

bundle API uploads given bundle model files to TFaaS server

upload

upload API uploads given model to TFaaS server

predict

predict API get predictions from TFaaS server

predictImage

predict API get predictions from TFaaS server

getdata

helper function to use in predict/upload APIs, it place given URL call to the server

main

Main function

Data

TFAAS_CLIENT

API

MLaaS.tfaas_client.TFAAS_CLIENT

None

class MLaaS.tfaas_client.OptionParser

Initialization

User based option parser

class MLaaS.tfaas_client.HTTPSClientAuthHandler(key=None, cert=None, capath=None, level=0)

Bases: urllib.request.HTTPSHandler

Simple HTTPS client authentication class based on provided key/ca information

Initialization

https_open(req)

Open request method

get_connection(host, timeout=300)

Connection method

MLaaS.tfaas_client.x509()

Helper function to get x509 either from env or tmp file

MLaaS.tfaas_client.check_auth(key)

Check if user runs das_client with key/cert and warn users to switch

MLaaS.tfaas_client.fullpath(path)

Expand path to full path

MLaaS.tfaas_client.choose_boundary()

Helper function to replace deprecated mimetools.choose_boundary https://stackoverflow.com/questions/27099290/where-is-mimetools-choose-boundary-function-in-python3 https://docs.python.org/2.7/library/mimetools.html?highlight=choose_boundary#mimetools.choose_boundary

mimetools.choose_boundary() ‘192.168.1.191.502.42035.1678979116.376.1’

class MLaaS.tfaas_client.MultiPartForm

Bases: object

Accumulate the data to be used when posting a form.

Initialization

get_content_type()
add_field(name, value)

Add a simple field to the form data.

add_file(fieldname, filename, fileHandle, mimetype=None)

Add a file to be uploaded.

__str__()

Return a string representing the form data, including attached files.

MLaaS.tfaas_client.models(host, verbose=None, ckey=None, cert=None, capath=None)

models API shows models from TFaaS server

MLaaS.tfaas_client.delete(host, model, verbose=None, ckey=None, cert=None, capath=None)

delete API deletes given model in TFaaS server

MLaaS.tfaas_client.bundle(host, ifile, verbose=None, ckey=None, cert=None, capath=None)

bundle API uploads given bundle model files to TFaaS server

MLaaS.tfaas_client.upload(host, ifile, verbose=None, ckey=None, cert=None, capath=None)

upload API uploads given model to TFaaS server

MLaaS.tfaas_client.predict(host, ifile, model, verbose=None, ckey=None, cert=None, capath=None)

predict API get predictions from TFaaS server

MLaaS.tfaas_client.predictImage(host, ifile, model, verbose=None, ckey=None, cert=None, capath=None)

predict API get predictions from TFaaS server

MLaaS.tfaas_client.getdata(url, headers, encoded_data, ckey, cert, capath, verbose=None, method='POST')

helper function to use in predict/upload APIs, it place given URL call to the server

MLaaS.tfaas_client.main()

Main function