|
|
|
@ -5,7 +5,7 @@ import os
|
|
|
|
|
from sqlalchemy import text
|
|
|
|
|
|
|
|
|
|
from website import consts
|
|
|
|
|
from website import db
|
|
|
|
|
from website import db_mysql
|
|
|
|
|
from website import errors
|
|
|
|
|
from website import settings
|
|
|
|
|
from website.handler import APIHandler, authenticated
|
|
|
|
@ -69,7 +69,7 @@ class ClassificationListHandler(APIHandler):
|
|
|
|
|
def post(self):
|
|
|
|
|
with self.app_mysql.connect() as conn:
|
|
|
|
|
cur = conn.execute(text("""select id, name from model_classification"""))
|
|
|
|
|
result = db.to_json_list(cur)
|
|
|
|
|
result = db_mysql.to_json_list(cur)
|
|
|
|
|
|
|
|
|
|
self.finish({"data": result})
|
|
|
|
|
|
|
|
|
@ -125,7 +125,7 @@ class ListHandler(APIHandler):
|
|
|
|
|
param["offset"] = (pageNo - 1) * pageSize
|
|
|
|
|
|
|
|
|
|
cur = conn.execute(text(sql), param)
|
|
|
|
|
result = db.to_json_list(cur)
|
|
|
|
|
result = db_mysql.to_json_list(cur)
|
|
|
|
|
|
|
|
|
|
count = conn.execute(text(sql_count), param_count).fetchone()[0]
|
|
|
|
|
|
|
|
|
@ -227,7 +227,7 @@ class InfoHandler(APIHandler):
|
|
|
|
|
{"id": mid}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
result = db.to_json(cur)
|
|
|
|
|
result = db_mysql.to_json(cur)
|
|
|
|
|
if not result:
|
|
|
|
|
raise errors.HTTPAPIError(errors.ERROR_BAD_REQUEST, "模型不存在")
|
|
|
|
|
|
|
|
|
@ -403,7 +403,7 @@ class VersionListHandler(APIHandler):
|
|
|
|
|
{"mid": model_id, "offset": (pageNo - 1) * pageSize, "limit": pageSize}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
result = db.to_json(cur)
|
|
|
|
|
result = db_mysql.to_json(cur)
|
|
|
|
|
|
|
|
|
|
# 获取记录数量
|
|
|
|
|
count = conn.execute(
|
|
|
|
@ -479,7 +479,7 @@ class VersionInfoHandler(APIHandler):
|
|
|
|
|
{"id": version_id}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
result = db.to_json(cur)
|
|
|
|
|
result = db_mysql.to_json(cur)
|
|
|
|
|
if not result:
|
|
|
|
|
raise errors.HTTPAPIError(errors.ERROR_BAD_REQUEST, "模型版本不存在")
|
|
|
|
|
|
|
|
|
@ -497,7 +497,7 @@ class VersionInfoHandler(APIHandler):
|
|
|
|
|
cur_model_file = conn.execute(
|
|
|
|
|
text("select filename, filesize from files where md5_str=:md5_str"), {"md5_str": model_file}
|
|
|
|
|
)
|
|
|
|
|
model_file_info = db.to_json(cur_model_file)
|
|
|
|
|
model_file_info = db_mysql.to_json(cur_model_file)
|
|
|
|
|
response["model_file_name"] = model_file_info["filename"]
|
|
|
|
|
response["model_file_size"] = model_file_info["filesize"]
|
|
|
|
|
|
|
|
|
@ -505,7 +505,7 @@ class VersionInfoHandler(APIHandler):
|
|
|
|
|
cur_config_file = conn.execute(
|
|
|
|
|
text("select filename, filesize from files where md5_str=:md5_str"), {"md5_str": config_file}
|
|
|
|
|
)
|
|
|
|
|
config_file_info = db.to_json(cur_config_file)
|
|
|
|
|
config_file_info = db_mysql.to_json(cur_config_file)
|
|
|
|
|
response["config_file_name"] = config_file_info["filename"]
|
|
|
|
|
response["config_file_size"] = config_file_info["filesize"]
|
|
|
|
|
|
|
|
|
@ -568,7 +568,7 @@ class VersionDeleteHandler(APIHandler):
|
|
|
|
|
with self.app_mysql.connect() as conn:
|
|
|
|
|
cur = conn.execute(text("select model_id, model_file, config_file from model_version where id=:id"),
|
|
|
|
|
{"id": version_id})
|
|
|
|
|
row = db.to_json(cur)
|
|
|
|
|
row = db_mysql.to_json(cur)
|
|
|
|
|
|
|
|
|
|
if not row:
|
|
|
|
|
raise errors.HTTPAPIError(errors.ERROR_BAD_REQUEST, "模型版本不存在")
|
|
|
|
|