From 681b4c46b777f674202639c5807d25c5f68a3bf9 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 7 Sep 2026 18:05:55 +0800 Subject: [PATCH] =?UTF-8?q?chore(scripts):=20=E5=AD=98=E6=A1=A3=E5=88=A0?= =?UTF-8?q?=E9=99=A45=E4=B8=AA=E8=80=81MiniMax=E6=A8=A1=E5=9E=8B=E8=84=9A?= =?UTF-8?q?=E6=9C=AC(M2/M2.1/M2.1-highspeed/M2.5/M2.5-highspeed,=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=AE=9A=E5=A4=BA=E8=80=81=E6=A8=A1=E5=9E=8B=E5=88=A0?= =?UTF-8?q?=E9=99=A4;=E8=B5=B0=E6=A8=A1=E5=9D=97=E5=AE=88=E5=8D=AB?= =?UTF-8?q?=E5=87=BD=E6=95=B0+=E4=BA=A7=E5=93=81=E6=98=A0=E5=B0=84?= =?UTF-8?q?=E4=B8=80=E5=B9=B6=E6=B8=85+=E5=85=B1=E4=BA=AB=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E4=BF=9D=E7=95=99,=E5=B7=B2=E5=A4=87=E4=BB=BD?= =?UTF-8?q?=E5=8F=AF=E5=9B=9E=E6=BB=9A)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/delete_old_minimax_models_20260907.py | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 scripts/delete_old_minimax_models_20260907.py diff --git a/scripts/delete_old_minimax_models_20260907.py b/scripts/delete_old_minimax_models_20260907.py new file mode 100644 index 0000000..cb1e47c --- /dev/null +++ b/scripts/delete_old_minimax_models_20260907.py @@ -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())