切换为mysql数据库
This commit is contained in:
parent
e2879b44a8
commit
c4c008d034
|
@ -64,19 +64,19 @@ def battle_logic(baseline : Baseline, battle : Battle):
|
|||
challenger_baseline['farmer_adp'] = farmer_adp
|
||||
challenger_baseline['create_time'] = datetime.now()
|
||||
Baseline.create(**challenger_baseline)
|
||||
else:
|
||||
onnx_path = str(battle.challenger_path) + '.onnx'
|
||||
if os.path.exists(onnx_path):
|
||||
os.remove(onnx_path)
|
||||
os.remove(str(battle.challenger_path))
|
||||
battle.challenger_wp = landlord_wp if battle.challenger_position == 'landlord' else farmer_wp
|
||||
battle.challenger_adp = landlord_adp if battle.challenger_position == 'landlord' else farmer_adp
|
||||
battle.status = 1 if challenge_success else 2
|
||||
battle.save()
|
||||
if not challenge_success:
|
||||
onnx_path = str(battle.challenger_path) + '.onnx'
|
||||
if os.path.exists(onnx_path):
|
||||
os.remove(onnx_path)
|
||||
os.remove(str(battle.challenger_path))
|
||||
|
||||
def tick():
|
||||
try:
|
||||
battles = Battle.select().where(Battle.status == 0).order_by(Battle.id.desc()).limit(2)
|
||||
battles = Battle.select().where(Battle.status == 0).order_by(Battle.id.desc()).limit(10)
|
||||
for battle in battles:
|
||||
battle.status = -1
|
||||
battle.save()
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
# -*- coding:utf8 -*-
|
||||
from peewee import *
|
||||
db = SqliteDatabase('model.db', pragmas={
|
||||
'journal_mode': 'wal',
|
||||
'cache_size': -1 * 64000, # 64MB
|
||||
'foreign_keys': 1,
|
||||
'ignore_check_constraints': 0,
|
||||
'synchronous': 0})
|
||||
|
||||
db = MySQLDatabase('dou_model', host='192.168.1.88', user='douzero', passwd='VwjT6e0qf2t9iOH0')
|
||||
|
||||
class BaseModel(Model):
|
||||
class Meta:
|
||||
|
|
|
@ -49,18 +49,22 @@ def metrics():
|
|||
metrics = {}
|
||||
for i in range(len(baselines)):
|
||||
baseline = baselines[i]
|
||||
baseline_metric = {}
|
||||
baseline_metric = {
|
||||
'landlord': {},
|
||||
'landlord_up': {},
|
||||
'landlord_front': {},
|
||||
'landlord_down': {}
|
||||
}
|
||||
models = Model.select(Model.frame, Model.path).where(
|
||||
Model.type == type,
|
||||
Model.create_time >= baseline.create_time,
|
||||
Model.create_time >= end_time
|
||||
Model.create_time <= end_time
|
||||
).order_by(Model.create_time.asc())
|
||||
end_time = baseline.create_time
|
||||
for model in models:
|
||||
battle = Battle.get_or_none(Battle.challenger_path == model.path, Battle.status > 0, Battle.status != 3)
|
||||
if battle is not None:
|
||||
baseline_metric[model.frame] = {
|
||||
'position': battle.challenger_position,
|
||||
baseline_metric[str(battle.challenger_position)][model.frame] = {
|
||||
'wp': '%.4f' % float(battle.challenger_wp),
|
||||
'adp': '%.4f' % float(battle.challenger_adp)
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
flask==1.1
|
||||
flask-cors
|
||||
peewee
|
||||
pymysql
|
||||
|
|
Loading…
Reference in New Issue