Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3b52848c2 | ||
|
|
d6e9f2e7a0 | ||
|
|
821edbc8f5 | ||
|
|
5e2df178e1 |
28
main.py
28
main.py
@@ -121,12 +121,12 @@ def init_db():
|
|||||||
# ModelScope 搜索
|
# ModelScope 搜索
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
||||||
def search_models(keyword: str, limit: int = 100) -> list:
|
def search_models(keyword: str, limit: int = 50) -> list:
|
||||||
"""从 ModelScope 搜索模型"""
|
"""从 ModelScope 搜索模型"""
|
||||||
url = "https://modelscope.cn/openapi/v1/models"
|
url = "https://modelscope.cn/openapi/v1/models"
|
||||||
params = {
|
params = {
|
||||||
'search': keyword,
|
'search': keyword,
|
||||||
'page_size': limit,
|
'page_size': min(limit, 50), # API 上限 50
|
||||||
'page_number': 1,
|
'page_number': 1,
|
||||||
'sort': 'downloads',
|
'sort': 'downloads',
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,11 @@ def search_models(keyword: str, limit: int = 100) -> list:
|
|||||||
headers={'User-Agent': 'Mozilla/5.0'})
|
headers={'User-Agent': 'Mozilla/5.0'})
|
||||||
data = resp.json()
|
data = resp.json()
|
||||||
if data.get('success'):
|
if data.get('success'):
|
||||||
return data.get('data', {}).get('models', [])
|
models = data.get('data', {}).get('models', [])
|
||||||
|
log(f" 搜索 [{keyword}]: status={resp.status_code} models={len(models)}")
|
||||||
|
return models
|
||||||
|
else:
|
||||||
|
log(f" 搜索 [{keyword}]: success=false, data={str(data)[:200]}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log(f" 搜索失败 [{keyword}]: {e}")
|
log(f" 搜索失败 [{keyword}]: {e}")
|
||||||
return []
|
return []
|
||||||
@@ -191,7 +195,8 @@ def check_platform_verify(model_id: str) -> dict:
|
|||||||
resp = requests.get(url, headers=headers, params={'modelId': model_id}, timeout=10)
|
resp = requests.get(url, headers=headers, params={'modelId': model_id}, timeout=10)
|
||||||
data = resp.json()
|
data = resp.json()
|
||||||
if data.get('code') == 0:
|
if data.get('code') == 0:
|
||||||
return data.get('data', {}).get('verifyResult', {})
|
result = data.get('data', {}).get('verifyResult', {})
|
||||||
|
return result if isinstance(result, dict) else {}
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return {}
|
return {}
|
||||||
@@ -728,9 +733,22 @@ def main():
|
|||||||
log(f"[ModelHub提交] ❌ error={e}")
|
log(f"[ModelHub提交] ❌ error={e}")
|
||||||
|
|
||||||
log("=" * 50)
|
log("=" * 50)
|
||||||
log("连通性测试完成,请查看上方结果")
|
log("连通性测试完成")
|
||||||
log("=" * 50)
|
log("=" * 50)
|
||||||
|
|
||||||
|
# 开始正式提交流程
|
||||||
|
log("\n自动触发提交流程...")
|
||||||
|
try:
|
||||||
|
state['running'] = True
|
||||||
|
state['last_run'] = datetime.now().isoformat()
|
||||||
|
count = run_pipeline(submit_limit=30)
|
||||||
|
state['last_result'] = {'submitted': count, 'success': True}
|
||||||
|
except Exception as e:
|
||||||
|
log(f"流程异常: {traceback.format_exc()}")
|
||||||
|
state['last_result'] = {'error': str(e), 'success': False}
|
||||||
|
finally:
|
||||||
|
state['running'] = False
|
||||||
|
|
||||||
threading.Thread(target=_startup_test, daemon=True).start()
|
threading.Thread(target=_startup_test, daemon=True).start()
|
||||||
|
|
||||||
while not shutdown_requested:
|
while not shutdown_requested:
|
||||||
|
|||||||
Reference in New Issue
Block a user