chore(scripts): 存档删除5个老MiniMax模型脚本(M2/M2.1/M2.1-highspeed/M2.5/M2.5-highspeed,用户定夺老模型删除;走模块守卫函数+产品映射一并清+共享模板保留,已备份可回滚)
This commit is contained in:
parent
9cb6b5abdf
commit
681b4c46b7
76
scripts/delete_old_minimax_models_20260907.py
Normal file
76
scripts/delete_old_minimax_models_20260907.py
Normal file
@ -0,0 +1,76 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""删除5个老MiniMax模型(2026-09-07用户定夺:老模型删除)。
|
||||
|
||||
已备份:/d/pipeline/backup_minimax_old_models_20260907_180449.sql(10行INSERT)
|
||||
引用面查证:无策略引用/无流水/无ppid;共享适配模板 jXdSjfg81Fy1oJQsljA-Q 保留
|
||||
(另2个模型在用)。产品映射5条一并删除。
|
||||
删除走模块函数 delete_llm_model(自带「被设为主模型禁止删」守卫)。
|
||||
用法:py3/bin/python tmp_delete_models.py [--dry]
|
||||
"""
|
||||
import asyncio
|
||||
import json
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '/d/pipeline/pipeline-app')
|
||||
|
||||
from sqlor.dbpools import DBPools # noqa: E402
|
||||
from appPublic.jsonConfig import getConfig # noqa: E402
|
||||
|
||||
DRY = '--dry' in sys.argv
|
||||
IDS = ['L2_7OmH132ukEzjQ1Z3Of', 'dg02wkcwatBOoXz8g6Gt1', 'qcBXJr71kWhpfwpgzHBex',
|
||||
'qDIgEkBEa2MDZOZ9LL7Np', 'UWGfXRSg3XE-t97cDrf35']
|
||||
|
||||
|
||||
async def main():
|
||||
cfg = getConfig()
|
||||
DBPools(cfg.databases)
|
||||
db = DBPools()
|
||||
log = []
|
||||
|
||||
# 1. 模型删除:走模块函数(带守卫)
|
||||
from pipeline_llm.init import delete_llm_model
|
||||
for mid in IDS:
|
||||
if DRY:
|
||||
log.append('dry: 将删 llm_model id=%s' % mid)
|
||||
continue
|
||||
r = json.loads(await delete_llm_model({'id': mid}))
|
||||
log.append('llm_model %s: %s %s' % (mid, '✓' if r.get('success') else '✗',
|
||||
r.get('message', '')))
|
||||
|
||||
# 2. 产品映射删除
|
||||
async with db.sqlorContext('pipeline') as sor:
|
||||
if not DRY:
|
||||
for mid in IDS:
|
||||
await sor.sqlExe(
|
||||
"DELETE FROM product WHERE resource_ref_id=${r}$", {"r": mid})
|
||||
await sor.sqlExe("COMMIT", {})
|
||||
log.append('product: 5条映射已删')
|
||||
else:
|
||||
log.append('dry: 将删 product 5条映射')
|
||||
|
||||
# 3. 复核:目标模型/产品应清零;共享模板应还在;M2.7系/M3不受影响
|
||||
recs = await sor.sqlExe(
|
||||
"SELECT COUNT(*) AS c FROM llm_model WHERE id IN ('%s')" % "','".join(IDS), {})
|
||||
await sor.sqlExe("COMMIT", {})
|
||||
left_m = int(recs[0].c) if recs else -1
|
||||
recs2 = await sor.sqlExe(
|
||||
"SELECT COUNT(*) AS c FROM product WHERE resource_ref_id IN ('%s')" % "','".join(IDS), {})
|
||||
await sor.sqlExe("COMMIT", {})
|
||||
left_p = int(recs2[0].c) if recs2 else -1
|
||||
recs3 = await sor.sqlExe(
|
||||
"SELECT COUNT(*) AS c FROM llm_api_profile WHERE id='jXdSjfg81Fy1oJQsljA-Q'", {})
|
||||
await sor.sqlExe("COMMIT", {})
|
||||
prof = int(recs3[0].c) if recs3 else -1
|
||||
recs4 = await sor.sqlExe(
|
||||
"SELECT name, status, COALESCE(ppid,'') AS ppid FROM llm_model "
|
||||
"WHERE vendor_model_id LIKE ${kw}$ ORDER BY name", {"kw": "MiniMax%"})
|
||||
await sor.sqlExe("COMMIT", {})
|
||||
remain = [{'name': r.name, 'status': r.status, 'ppid': '有' if r.ppid else '无'}
|
||||
for r in (recs4 or [])]
|
||||
print(json.dumps({'dry': DRY, 'log': log,
|
||||
'left_models(应0)': left_m, 'left_products(应0)': left_p,
|
||||
'shared_profile(应1)': prof, 'remaining_minimax': remain},
|
||||
ensure_ascii=False, indent=1))
|
||||
|
||||
|
||||
asyncio.run(main())
|
||||
Loading…
x
Reference in New Issue
Block a user