metaphor.api_client
¶
Low level client interface for Metaphor server.
This module expose procedures that call directly the metaphor server through the RESTful interface implemented with Sanic.
-
meta_client.api_client.
add_user
(user_ame='')[source]¶ Add a user to the registered user list.
parameter:
user_ame -> name of the user to add
-
meta_client.api_client.
check_user
(username='', getID=False)[source]¶ Check the user situation.
return :
user registered
no
yes
getID True
-1
ID
getID False
warning
3-tuple : name, ID, belongings dictionary
-
meta_client.api_client.
contact
()[source]¶ Establish a first contact with the metaphor server. It returns a welcome message.
parameters:
application (optional) -> the application name get in contact with. Defaul metaphor
-
meta_client.api_client.
create_model
(userid, data='', raw=False)[source]¶ create a new model.
data -> dictionary describing creation parameters.
training -> boolean giving the purpose of creation
source -> data file or data file content
modelname -> name imposed to the model
trainable -> training capacity (default True)
inputs -> input number (default 1)
outputs -> output number (default 1)
hidden -> number of hidden neurons (default 2)
activfunc -> activation fonction (default TANH)
statelayer -> state layer (default -1 )
statenodeindex index of state node (default -1)
order order of the network default 0)
nosynapse -> build model without any synapses (default False)
existingnode -> already existing nodes (default 0)
polytype -> type de polynome (default 0)
classif -> classifier (deafult False)
verbose=0,
data=None,
dataformat=None,
normalize=False,
weights=None,
disp=0,
callback=None unused
raw -> If True, return raw request
-
meta_client.api_client.
delete_models
(userid, modelid)[source]¶ Delete a registered model.
parameters:
userid -> user ID
modelid -> model ID belonging to the designed user. modelid may be “*” to delete all the user’s models.
-
meta_client.api_client.
delete_user
(user_name='')[source]¶ Unregister the designed user.
All the user belongings are destroyed.
parameter:
user_name -> name of the user to unregister. If this name is “*”, all the registered users are unregistered.
-
meta_client.api_client.
get_function
(userid, modelid, root_func_name, data='')[source]¶ Call a function to apply to the designed model. The function called may not modify the sate of the designed model.
parameters:
userid -> user ID
modelid -> model ID belonging to the designed user
root_func_name, data -> function to call. data is related to function:
function name
data
paramCount
None
dataCount
None
newWeights
{‘stddev’: stddev, ‘bias0’: bias0}
getTrainingData
{‘prefix’: None}
inputNames
None
outputNames
None
inputs
None
outputs
None
inputNorm
None
outputNorm
None
targets
None
getWeights
{‘prefix’: None}
-
meta_client.api_client.
get_model_attribute
(userid, modelid, data='')[source]¶ Retrieve model attributes.
parameters:
userid -> user ID
modelid -> model ID belonging to the designed user.
data -> dictionary describing the attribute to read.
{‘attributes’: <attribute name>}
return depending on the attribute.
-
meta_client.api_client.
get_model_list
(userid)[source]¶ Retrieve the list of models belongings to the given user.
parameter:
userid -> ID of the user to examine.
-
meta_client.api_client.
get_user_name
(user_ID)[source]¶ Retrieve user name.
parameter:
user_ID -> ID to find
return user name if found, else empty string.
-
meta_client.api_client.
get_users
()[source]¶ Retrieve registered user dictionary.
keys -> user ID(s)
values -> user names
-
meta_client.api_client.
initiate_connection
(server='0.0.0.0', port=5005, application='metaphor', APIver=1.0)[source]¶ Initiate metaphor client interface routes and establish contact.
parameters:
server -> IP address or name of the server machine. default “0.0.0.0”
port -> Number of port. default 5005
application -> Application name. default ‘metaphor’
APIver -> Version of the interface. default APIversion
return the server welcome message if success, otherwise an error message.
-
meta_client.api_client.
load_model
(userid, data='', getID=False, raw=False)[source]¶ load a new model from file.
datas :
source -> file or file content
‘modelname’ -> name imposed to the model
‘descriptor’ -> smiles code or similar descriptor
‘docompile’ ->
raw -> If True, return raw request
-
meta_client.api_client.
post_file
(userid, filepath=None, dest='', extra={})[source]¶ Upload a file to the server.
parameters:
filepath -> path of the file to upload
dest -> relative destination path in the server
extra -> unused
-
meta_client.api_client.
post_function
(userid, modelid, root_func_name, data='')[source]¶ Call a function to apply to the designed model. The function called may modify the sate of the designed model.
parameters:
userid -> user ID
modelid -> model ID belonging to the designed user
root_func_name -> function to call. Availables functions are:
transfer
train
reverse_train
setWeights
data -> a dictionary depending upon the called function:
transfer:
inputs -> input vector.
index -> index of training data to use as inputs.
weights -> parameters to use. If None, current parameters are used.
train ->
startWeights -> starting parameter set to strat training with.
epochs -> maximum number of epochs allowed to training job
trainstyle -> unused
callback -> unused
reverse_train ->
outputtarget -> output value to target
inputs -> starting inputs
fixedinputs -> vector of boolean giving the input mobility freedom
epochs -> maximum number of epochs allowed to training job
setWeights ->
weights -> parameter vector to affect
prefix -> None
-
meta_client.api_client.
set_model_attribute
(userid, modelid, data='')[source]¶ Write an attribute to the model. Can be used for user defined attributes.
parameters:
userid -> user ID
modelid -> model ID belonging to the designed user
- data -> dictionary describing the attribute to write
{‘attributes’: <attribute name>}
metaphor.client_toolbox
¶
This module defines the routes for metaphor server.
-
meta_client.client_toolbox.
initiate_routes
(server='0.0.0.0', port=5005, appli='metaphor', APIver=1.0)[source]¶ Initiate metaphor client interface routes.
parameters:
server -> IP address or name of the server machine. default “0.0.0.0”
port -> Number of port. default 5005
application -> Application name. default ‘metaphor’
APIversion -> Version of the interface. default APIversion