2 Commits
v2.4.1 ... main

Author SHA1 Message Date
z3st
3eed33f0d8 chore: increase submit limit from 2 to 5 2026-07-24 20:30:10 +08:00
z3st
a2ef82d954 fix: fix SQLite INSERT column count, fix architecture check for all arch types 2026-07-24 20:24:26 +08:00

32
main.py
View File

@@ -157,7 +157,7 @@ def search_models(keyword: str) -> list:
def check_architecture(model_id: str) -> tuple: def check_architecture(model_id: str) -> tuple:
"""检查模型架构""" """检查模型是否有有效的 config.json不限架构类型"""
try: try:
cfg_url = f"{MODELSCOPE_API}/models/{model_id}/repo?Revision=master&FilePath=config.json" cfg_url = f"{MODELSCOPE_API}/models/{model_id}/repo?Revision=master&FilePath=config.json"
resp = requests.get(cfg_url, timeout=10) resp = requests.get(cfg_url, timeout=10)
@@ -165,20 +165,13 @@ def check_architecture(model_id: str) -> tuple:
cfg = resp.json() cfg = resp.json()
archs = cfg.get('architectures', []) archs = cfg.get('architectures', [])
mtype = cfg.get('model_type', '') mtype = cfg.get('model_type', '')
arch_str = str(archs) if archs or mtype:
for special in SUPPORTED_SPECIAL_ARCHS: return True, f"arch={archs} type={mtype}"
if special in arch_str: return False, "empty config"
return True, special
for kw in SUPPORTED_ARCH_KEYWORDS:
if kw in arch_str:
return True, kw
if mtype in SUPPORTED_MODEL_TYPES:
return True, mtype
return False, f"arch={archs} type={mtype}"
mid_upper = model_id.upper() mid_upper = model_id.upper()
if 'QWEN3' in mid_upper or 'QWEN2' in mid_upper: if 'LLAMA' in mid_upper:
return True, "GGUF" return True, "Llama(GGUF)"
return False, "no config, not Qwen" return False, "no config"
except Exception as e: except Exception as e:
return True, f"check error: {e}" return True, f"check error: {e}"
@@ -321,7 +314,7 @@ def submit_model(model_url: str) -> tuple:
# 主流程 # 主流程
# ============================================================ # ============================================================
def run_pipeline(submit_limit: int = 2): def run_pipeline(submit_limit: int = 5):
"""完整流程搜索→筛选→提交只针对目标GPU""" """完整流程搜索→筛选→提交只针对目标GPU"""
init_db() init_db()
log("=" * 50) log("=" * 50)
@@ -425,8 +418,9 @@ def run_pipeline(submit_limit: int = 2):
submitted += 1 submitted += 1
log(f"{m['model_id']}") log(f"{m['model_id']}")
db_conn.execute( db_conn.execute(
'INSERT OR REPLACE INTO submitted VALUES (?,?,?,?)', 'INSERT OR REPLACE INTO submitted VALUES (?,?,?,?,?,?)',
(m['model_id'], TARGET_GPU, str(task_id), datetime.now().isoformat()) (m['model_id'], TARGET_GPU, str(task_id), 'submitted',
datetime.now().isoformat(), None)
) )
else: else:
log(f"{m['model_id']}: {msg}") log(f"{m['model_id']}: {msg}")
@@ -493,7 +487,7 @@ class AgentHandler(BaseHTTPRequestHandler):
if content_len > 0: if content_len > 0:
body = json.loads(self.rfile.read(content_len)) body = json.loads(self.rfile.read(content_len))
limit = body.get('limit', 2) limit = body.get('limit', 5)
self._json({'status': 'started', 'gpu': TARGET_GPU, 'limit': limit}) self._json({'status': 'started', 'gpu': TARGET_GPU, 'limit': limit})
@@ -710,7 +704,7 @@ def main():
try: try:
state['running'] = True state['running'] = True
state['last_run'] = datetime.now().isoformat() state['last_run'] = datetime.now().isoformat()
count = run_pipeline(submit_limit=2) count = run_pipeline(submit_limit=5)
state['last_result'] = {'submitted': count, 'success': True} state['last_result'] = {'submitted': count, 'success': True}
except Exception as e: except Exception as e:
log(f"流程异常: {traceback.format_exc()}") log(f"流程异常: {traceback.format_exc()}")