fix(gpt): check the grant, check the rsp code.
This commit is contained in:
parent
79876a1f2f
commit
32d48a8e85
|
@ -371,6 +371,11 @@ static int32_t mndProcessCreateAnodeReq(SRpcMsg *pReq) {
|
|||
SAnodeObj *pObj = NULL;
|
||||
SMCreateAnodeReq createReq = {0};
|
||||
|
||||
if ((code = grantCheck(TSDB_GRANT_TD_GPT)) != TSDB_CODE_SUCCESS) {
|
||||
mError("failed to create anode, code:%s", tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
TAOS_CHECK_GOTO(tDeserializeSMCreateAnodeReq(pReq->pCont, pReq->contLen, &createReq), NULL, _OVER);
|
||||
|
||||
mInfo("anode:%s, start to create", createReq.url);
|
||||
|
|
|
@ -41,9 +41,12 @@ class _GPTService(AbstractForecastService):
|
|||
app_logger.log_inst.error(f"failed to connect the service: {self.service_host} ", str(e))
|
||||
raise e
|
||||
|
||||
if response.status_code != 200:
|
||||
if response.status_code == 404:
|
||||
app_logger.log_inst.error(f"failed to connect the service: {self.service_host} ")
|
||||
raise ValueError("invalid host url")
|
||||
elif response.status_code != 200:
|
||||
app_logger.log_inst.error(f"failed to request the service: {self.service_host}, reason: {response.text}")
|
||||
raise ValueError(f"failed to request the service, {response.text}")
|
||||
|
||||
pred_y = response.json()['output']
|
||||
|
||||
|
|
|
@ -257,3 +257,54 @@ class RestfulTest(TestCase):
|
|||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.json["rows"], -1)
|
||||
|
||||
|
||||
def test_gpt_restful_service(self):
|
||||
response = self.client.post('/forecast', json={
|
||||
"schema": [
|
||||
["ts", "TIMESTAMP", 8],
|
||||
["val", "INT", 4]
|
||||
],
|
||||
"data": [
|
||||
[
|
||||
1577808000000, 1577808001000, 1577808002000, 1577808003000, 1577808004000,
|
||||
1577808005000, 1577808006000, 1577808007000, 1577808008000, 1577808009000,
|
||||
1577808010000, 1577808011000, 1577808012000, 1577808013000, 1577808014000,
|
||||
1577808015000, 1577808016000, 1577808017000, 1577808018000, 1577808019000,
|
||||
1577808020000, 1577808021000, 1577808022000, 1577808023000, 1577808024000,
|
||||
1577808025000, 1577808026000, 1577808027000, 1577808028000, 1577808029000,
|
||||
1577808030000, 1577808031000, 1577808032000, 1577808033000, 1577808034000,
|
||||
1577808035000, 1577808036000, 1577808037000, 1577808038000, 1577808039000,
|
||||
1577808040000, 1577808041000, 1577808042000, 1577808043000, 1577808044000,
|
||||
1577808045000, 1577808046000, 1577808047000, 1577808048000, 1577808049000,
|
||||
1577808050000, 1577808051000, 1577808052000, 1577808053000, 1577808054000,
|
||||
1577808055000, 1577808056000, 1577808057000, 1577808058000, 1577808059000,
|
||||
1577808060000, 1577808061000, 1577808062000, 1577808063000, 1577808064000,
|
||||
1577808065000, 1577808066000, 1577808067000, 1577808068000, 1577808069000,
|
||||
1577808070000, 1577808071000, 1577808072000, 1577808073000, 1577808074000,
|
||||
1577808075000, 1577808076000, 1577808077000, 1577808078000, 1577808079000,
|
||||
1577808080000, 1577808081000, 1577808082000, 1577808083000, 1577808084000,
|
||||
1577808085000, 1577808086000, 1577808087000, 1577808088000, 1577808089000,
|
||||
1577808090000, 1577808091000, 1577808092000, 1577808093000, 1577808094000,
|
||||
1577808095000
|
||||
],
|
||||
[
|
||||
13, 14, 8, 10, 16, 26, 32, 27, 18, 32, 36, 24, 22, 23, 22, 18, 25, 21, 21,
|
||||
14, 8, 11, 14, 23, 18, 17, 19, 20, 22, 19, 13, 26, 13, 14, 22, 24, 21, 22,
|
||||
26, 21, 23, 24, 27, 41, 31, 27, 35, 26, 28, 36, 39, 21, 17, 22, 17, 19, 15,
|
||||
34, 10, 15, 22, 18, 15, 20, 15, 22, 19, 16, 30, 27, 29, 23, 20, 16, 21, 21,
|
||||
25, 16, 18, 15, 18, 14, 10, 15, 8, 15, 6, 11, 8, 7, 13, 10, 23, 16, 15, 25
|
||||
]
|
||||
],
|
||||
"option": "algo=td_gpt_fc",
|
||||
"algo": "td_gpt_fc",
|
||||
"prec": "ms",
|
||||
"wncheck": 0,
|
||||
"return_conf": 0,
|
||||
"forecast_rows": 10,
|
||||
"conf": 95,
|
||||
"start": 1577808096000,
|
||||
"every": 1000,
|
||||
"rows": 21,
|
||||
"protocol": 1.0
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue