Skip to content

Commit e78dd47

Browse files
authored
fix: callback execution order in _create_operator (#1154)
User-provided callbacks are now executed before official callbacks by adjusting the order in the callbacks list. This ensures user callbacks are called prior to those managed by SwanLabRun's lifecycle.
1 parent 9693129 commit e78dd47

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

swanlab/data/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,5 +191,6 @@ def _create_operator(
191191
raise ValueError(f"Unknown mode: {mode}, please use one of {SwanLabMode.list()}")
192192

193193
# 2. 合并用户传递的回调函数并注册到 SwanLabRunOperator 中使其可被调用
194-
callbacks = c + cbs
194+
# WARNING: 因为官方回调接管了 SwanLabRun 的生命周期,所以用户传递的回调函数必须在官方回调函数之前执行,也就是排在列表前面
195+
callbacks = cbs + c
195196
return SwanLabRunOperator(callbacks)

0 commit comments

Comments
 (0)