Skip to content

Commit 0a9a2d3

Browse files
committed
update ans
1 parent 790e5d9 commit 0a9a2d3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

examples/tuning/check_sweep.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,22 @@
1010
parser.add_argument("--sweep_id", type=str, default="c3yy5fd3")
1111
args = parser.parse_args()
1212
sweep_id = args.sweep_id
13-
sweep = wandb.Api(timeout=1000).sweep(f"{entity}/{project}/{sweep_id}")
13+
1414
import time
1515

1616

17-
def delete_unfinished_runs(sweep, max_attempts=3, check_interval=1):
17+
def delete_unfinished_runs(sweep_id, max_attempts=3, check_interval=1):
1818
"""删除所有未完成的运行,并确保删除成功.
1919
2020
参数:
21-
- sweep: sweep对象
21+
- sweep_id: sweep对象的id
2222
- max_attempts: 最大重试次数
2323
- check_interval: 每次检查间隔的秒数
2424
2525
"""
2626
attempt = 0
2727
while attempt < max_attempts:
28+
sweep = wandb.Api(timeout=1000).sweep(f"{entity}/{project}/{sweep_id}")
2829
# 检查是否还有未完成的运行
2930
unfinished_runs = [run for run in sweep.runs if run.state != 'finished']
3031

@@ -54,7 +55,7 @@ def delete_unfinished_runs(sweep, max_attempts=3, check_interval=1):
5455

5556

5657
# 使用示例
57-
success = delete_unfinished_runs(sweep)
58+
success = delete_unfinished_runs(sweep_id)
5859
if success:
5960
print("所有未完成的运行已成功删除")
6061
else:

0 commit comments

Comments
 (0)