示例#1
0
 def testFilterByNumber(self):
     root = models.TestEntityGroupRoot(id="root")
     models.TestModel(parent=root.key).put()
     models.TestModel(number=17, parent=root.key).put()
     query = models.TestModel.query(ancestor=root.key).filter(
         models.TestModel.number == 42)
     results = query.fetch(2)
     self.assertEqual(1, len(results))
     self.assertEqual(42, results[0].number)
 def get(self):
     try:
         testModel = models.TestModel(name='hello world')
         self.db.add(testModel)
         self.db.commit()
     except Exception as e:
         self.db.rollback()
     finally:
         self.write({'init': testModel.id})
         self.db.close()
示例#3
0
    def do_POST(self):
        content_length = int(self.headers['Content-Length'])
        body = self.rfile.read(content_length)
        self.send_response(200)
        self.end_headers()

        data = json.loads(body)  # save json data
        model = models.TestModel(data['modelId'])
        question = data['question']
        response = data['questionResponse']
        prediction = float(model.predict(question, response))

        score = min([0, 0.5, 1], key=lambda x: abs(x - prediction))
        response_data = {"score": score}
        print(response_data)
        self.wfile.write(json.dumps(response_data).encode())
示例#4
0
def x():
	t = models.TestModel()
	t.test()
示例#5
0
 def testLocalModel(self):
     print "Ejecutando test con model local"
     model = models.TestModel()
     self.useModel(model, "LOCAL: ")
示例#6
0
 def testInsertEntity(self):
     models.TestModel().put()
     self.assertEqual(1, len(models.TestModel.query().fetch(2)))