jd_train/wipe_wandb_by_run_group.sh

41 lines
1.3 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export WB_ENTITY=hailin
export WANDB_BASE_URL=https://wandb.szaiai.com
export WANDB_API_KEY=local-701636f51b4741d3862007df5cf7f12cca53d8d1
export WANDB_PROJECT=ds-qwen3
export WANDB_GROUP=q3-32b-ds4-2025-09-05 # 如果训练时没用 WANDB_RUN_GROUP这里只是“期望值”
export MATCH_NAME_REGEX='^q3-32b-ds4' # 回退方案:按名字匹配
python3 - <<'PY'
import os, re, wandb
api = wandb.Api(overrides={"base_url": os.environ["WANDB_BASE_URL"]})
path = f'{os.environ["WB_ENTITY"]}/{os.environ["WANDB_PROJECT"]}'
group = os.environ.get("WANDB_GROUP","").strip()
name_pat = os.environ.get("MATCH_NAME_REGEX","").strip()
name_rx = re.compile(name_pat) if name_pat else None
runs = list(api.runs(path=path))
cand = []
# 1) 优先按 group
if group:
cand = [r for r in runs if (getattr(r, "group", None) == group)]
# 2) 回退:按名字正则
if not cand and name_rx:
cand = [r for r in runs if (r.name and name_rx.search(r.name))]
print(f"Matched {len(cand)} runs to delete:")
for r in cand:
print(" -", r.id, r.name, "group=", getattr(r, "group", None))
# 安全起见:把下面的 True 改成 False 可以先 dry-run
DO_DELETE = True
if DO_DELETE:
for r in cand:
try:
r.delete(delete_artifacts=True)
except TypeError:
r.delete()
print("Done.")
PY