def POST(self):
global modelCache
params = json.loads(web.data())
requestInput = web.input()
id = requestInput["id"]
# We will always return the active cells because they are cheap.
returnSnapshots = [TM_SNAPS.ACT_CELLS]
from pprint import pprint; pprint(params)
tm = TM(**params)
tmFacade = TmFacade(tm, ioClient, modelId=id)
modelId = tmFacade.getId()
modelCache[modelId]["tm"] = tmFacade
modelCache[modelId]["classifier"] = SDRClassifierFactory.create(implementation="py")
modelCache[modelId]["recordsSeen"] = 0
print "Created TM {}".format(modelId)
payload = {
"meta": {
"id": modelId,
"saving": returnSnapshots
}
}
tmState = tmFacade.getState(*returnSnapshots)
for key in tmState:
payload[key] = tmState[key]
web.header("Content-Type", "application/json")
return json.dumps(payload)
评论列表
文章目录