Commit 8441f3e9 authored by ymir's avatar ymir

manage trainer

parent 8513714f
#Here are some examples for each possible resource and actions
set -xe
# ***** CLEAN TEST *****
python3 neuralnetworktrainercli.py delete trainingsession
python3 neuralnetworktrainercli.py delete trainingset
python3 neuralnetworktrainercli.py delete perceptron
#***** PERCEPTRON *****
PERCEPTRON_ARCHIVE=/tmp/perceptron.gz
#-> randomize
rm ${PERCEPTRON_ARCHIVE}
rm -f ${PERCEPTRON_ARCHIVE}
python3 neuralnetworktrainercli.py randomize perceptron -d 10 2 -c "randomized perceptron" -a ${PERCEPTRON_ARCHIVE}
ls -lh ${PERCEPTRON_ARCHIVE}
#-> create
PERCEPTRON_ID=`python3 neuralnetworktrainercli.py create perceptron -a ${PERCEPTRON_ARCHIVE}`
echo ${PERCEPTRON_ID}
#-> read single
rm ${PERCEPTRON_ARCHIVE}
rm -f ${PERCEPTRON_ARCHIVE}
python3 neuralnetworktrainercli.py read perceptron -i ${PERCEPTRON_ID} -a ${PERCEPTRON_ARCHIVE}
ls -lh ${PERCEPTRON_ARCHIVE}
#-> update
......@@ -32,7 +36,7 @@ python3 neuralnetworktrainercli.py read perceptron
python3 neuralnetworktrainercli.py delete perceptron
#***** TRAINING SET *****
TRAININGSET_ARCHIVE=/tmp/trainingset.gz
rm ${TRAININGSET_ARCHIVE}
rm -f ${TRAININGSET_ARCHIVE}
echo '{
"trainingElements":[
{
......@@ -49,7 +53,7 @@ echo '{
TRAININGSET_ID=`python3 neuralnetworktrainercli.py create trainingset -a ${TRAININGSET_ARCHIVE}`
echo ${TRAININGSET_ID}
#-> read single
rm ${TRAININGSET_ARCHIVE}
rm -f ${TRAININGSET_ARCHIVE}
python3 neuralnetworktrainercli.py read trainingset -i ${TRAININGSET_ID} -a ${TRAININGSET_ARCHIVE}
ls -lh ${TRAININGSET_ARCHIVE}
#-> update
......@@ -75,13 +79,13 @@ TRAININGSET_ID=`python3 neuralnetworktrainercli.py create trainingset -a ${TRAIN
echo ${TRAININGSET_ID}
TRAININGSESSION_ARCHIVE=/tmp/trainingsession.gz
#-> randomize
rm ${TRAININGSESSION_ARCHIVE}
rm -f ${TRAININGSESSION_ARCHIVE}
python3 neuralnetworktrainercli.py randomize trainingsession -i ${PERCEPTRON_ID} -t ${TRAININGSET_ID} -z 1 -s 4 -r 0 -c "randomized training session" -a ${TRAININGSESSION_ARCHIVE}
ls -lh ${TRAININGSESSION_ARCHIVE}
#-> create
python3 neuralnetworktrainercli.py create trainingsession -i ${PERCEPTRON_ID} -a ${TRAININGSESSION_ARCHIVE}
#-> read single
rm ${TRAININGSESSION_ARCHIVE}
rm -f ${TRAININGSESSION_ARCHIVE}
python3 neuralnetworktrainercli.py read trainingsession -i ${PERCEPTRON_ID} -a ${TRAININGSESSION_ARCHIVE}
ls -lh ${TRAININGSESSION_ARCHIVE}
#-> update
......@@ -103,4 +107,20 @@ python3 neuralnetworktrainercli.py read trainingsession
#-> delete all
python3 neuralnetworktrainercli.py delete trainingsession
#***** TRAINER *****
PERCEPTRON_ID=`python3 neuralnetworktrainercli.py create perceptron -a ${PERCEPTRON_ARCHIVE}`
echo ${PERCEPTRON_ID}
TRAININGSET_ID=`python3 neuralnetworktrainercli.py create trainingset -a ${TRAININGSET_ARCHIVE}`
echo ${TRAININGSET_ID}
python3 neuralnetworktrainercli.py create trainingsession -i ${PERCEPTRON_ID} -a ${TRAININGSESSION_ARCHIVE}
#-> start
python3 neuralnetworktrainercli.py start trainer -i ${PERCEPTRON_ID}
#-> stop
python3 neuralnetworktrainercli.py stop trainer -i ${PERCEPTRON_ID}
# ***** CLEAN TEST *****
python3 neuralnetworktrainercli.py delete trainingsession
python3 neuralnetworktrainercli.py delete trainingset
python3 neuralnetworktrainercli.py delete perceptron
rm -f ${TRAININGSESSION_ARCHIVE}
rm -f ${TRAININGSET_ARCHIVE}
rm -f ${PERCEPTRON_ARCHIVE}
#-------------------------------------------------------------
\ No newline at end of file
......@@ -61,7 +61,6 @@ def randomizePerceptron(dimensions,comments,archive):
response = post(URL, data=data, headers=ContentType.GZIP.value)
checkresponse(response)
dumpArchive(archive, response.content)
pass
# create
def createPerceptron(archive):
URL=baseURL+"/perceptron"
......@@ -69,54 +68,46 @@ def createPerceptron(archive):
response = post(URL, data=data, headers=ContentType.GZIP.value)
checkresponse(response)
print(response.text)
pass
# read single
def readSinglePerceptron(id,archive):
URL=baseURL+"/perceptron/"+str(id)
response = get(URL, headers=ContentType.GZIP.value)
checkresponse(response)
dumpArchive(archive, response.content)
pass
# read all
def readAllPerceptron():
URL=baseURL+"/perceptron"
response = get(URL)
checkresponse(response)
print(response.text)
pass
# update
def updatePerceptron(id,archive):
URL=baseURL+"/perceptron/"+str(id)
data=loadArchive(archive)
response = put(URL, data=data, headers=ContentType.GZIP.value)
checkresponse(response)
pass
# patch
def patchPerceptron(id,comments):
URL=baseURL+"/perceptron/"+str(id)
data=dumps({"comments":comments})
response = patch(URL, data=data)
checkresponse(response)
pass
# summarize
def summarizePerceptron(id):
URL=baseURL+"/perceptron/"+str(id)+"/summary"
response = get(URL)
checkresponse(response)
print(response.text)
pass
# delete
def deleteSinglePerceptron(id):
URL=baseURL+"/perceptron/"+str(id)
response = delete(URL)
checkresponse(response)
pass
# delete
def deleteAllPerceptron():
URL=baseURL+"/perceptron"
response = delete(URL)
checkresponse(response)
pass
# ***** TRAINING SET *****
# create
def createTrainingSet(archive):
......@@ -125,54 +116,46 @@ def createTrainingSet(archive):
response = post(URL, data=data, headers=ContentType.GZIP.value)
checkresponse(response)
print(response.text)
pass
# read single
def readSingleTrainingSet(id,archive):
URL=baseURL+"/trainingset/"+str(id)
response = get(URL, headers=ContentType.GZIP.value)
checkresponse(response)
dumpArchive(archive, response.content)
pass
# read all
def readAllTrainingSet():
URL=baseURL+"/trainingset"
response = get(URL)
checkresponse(response)
print(response.text)
pass
# update
def updateTrainingSet(id,archive):
URL=baseURL+"/trainingset/"+str(id)
data=loadArchive(archive)
response = put(URL, data=data, headers=ContentType.GZIP.value)
checkresponse(response)
pass
# patch
def patchTrainingSet(id,comments):
URL=baseURL+"/trainingset/"+str(id)
data=dumps({"comments":comments})
response = patch(URL, data=data)
checkresponse(response)
pass
# summarize
def summarizeTrainingSet(id):
URL=baseURL+"/trainingset/"+str(id)+"/summary"
response = get(URL)
checkresponse(response)
print(response.text)
pass
# delete
def deleteSingleTrainingSet(id):
URL=baseURL+"/trainingset/"+str(id)
response = delete(URL)
checkresponse(response)
pass
# delete
def deleteAllTrainingSet():
URL=baseURL+"/trainingset"
response = delete(URL)
checkresponse(response)
pass
# ***** TRAINING SESSION *****
# randomize
def randomizeTrainingsession(id,trainingSetId,trainingChunkSize,saveInterval,testRatio,comments,archive):
......@@ -181,61 +164,64 @@ def randomizeTrainingsession(id,trainingSetId,trainingChunkSize,saveInterval,tes
response = post(URL, data=data, headers=ContentType.GZIP.value)
checkresponse(response)
dumpArchive(archive, response.content)
pass
# create
def createTrainingsession(id,archive):
URL=baseURL+"/perceptron/"+str(id)+"/trainingsession"
data=loadArchive(archive)
response = post(URL, data=data, headers=ContentType.GZIP.value)
checkresponse(response)
pass
# read single
def readSingleTrainingsession(id,archive):
URL=baseURL+"/perceptron/"+str(id)+"/trainingsession"
response = get(URL, headers=ContentType.GZIP.value)
checkresponse(response)
dumpArchive(archive, response.content)
pass
# read all
def readAllTrainingsession():
URL=baseURL+"/perceptron/trainingsession"
response = get(URL)
checkresponse(response)
print(response.text)
pass
# update
def updateTrainingsession(id,archive):
URL=baseURL+"/perceptron/"+str(id)+"/trainingsession"
data=loadArchive(archive)
response = put(URL, data=data, headers=ContentType.GZIP.value)
checkresponse(response)
pass
# patch
def patchTrainingsession(id,trainingChunkSize,saveInterval,comments):
URL=baseURL+"/perceptron/"+str(id)+"/trainingsession"
data=dumps({"trainingChunkSize":trainingChunkSize,"saveInterval":saveInterval,"comments":comments})
response = patch(URL, data=data)
checkresponse(response)
pass
# summarize
def summarizeTrainingsession(id):
URL=baseURL+"/perceptron/"+str(id)+"/trainingsession/summary"
response = get(URL)
checkresponse(response)
print(response.text)
pass
# delete
def deleteSingleTrainingsession(id):
URL=baseURL+"/perceptron/"+str(id)+"/trainingsession"
response = delete(URL)
checkresponse(response)
pass
# delete
def deleteAllTrainingsession():
URL=baseURL+"/perceptron/trainingsession"
response = delete(URL)
checkresponse(response)
pass
# ***** TRAINER *****
# start
def startTrainer(id):
URL=baseURL+"/perceptron/"+str(id)+"/trainer?action=start"
response = get(URL)
checkresponse(response)
print(response.text)
# stop
def stopTrainer(id):
URL=baseURL+"/perceptron/"+str(id)+"/trainer?action=stop"
response = get(URL)
checkresponse(response)
# parse arguments
def dispatchRequest(arguments):
# ***** PERCEPTRON *****
......@@ -293,13 +279,15 @@ def dispatchRequest(arguments):
elif arguments.action.upper()=="DELETE" and arguments.resource.upper()=="TRAININGSESSION" and arguments.id: deleteSingleTrainingsession(arguments.id)
# delete all
elif arguments.action.upper()=="DELETE" and arguments.resource.upper()=="TRAININGSESSION": deleteAllTrainingsession()
# ***** TRAINER *****
# start
elif arguments.action.upper() == "START" and arguments.resource.upper() == "TRAINER": startTrainer(arguments.id)
# stop
elif arguments.action.upper() == "STOP" and arguments.resource.upper() == "TRAINER": stopTrainer(arguments.id)
# ***** error in command line positional arguments *****
else: raise Exception("couple action/resource does not match : " + arguments.action + "/" + arguments.resource)
pass
# run program
if __name__ == "__main__":
if len(sys.argv)==1 or sys.argv[1].upper() in ("-H","--HELP",): displayExtraHelp()
arguments = parser.parse_args()
dispatchRequest(arguments)
pass
pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment