Skip to content

Commit 3de24f1

Browse files
committed
fix: _instantiate_algorithm 调用不存在的 get_algorithm_by_id,改用 get_algorithm + adapter 解包
1 parent d5ddadc commit 3de24f1

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

algorithms/training/trainer.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,13 @@ def _instantiate_algorithm(algo_id: str):
436436
logger.error("无法导入 AlgorithmRegistry: %s", e)
437437
return None
438438
AlgorithmRegistry.initialize()
439-
algo = AlgorithmRegistry.get_algorithm_by_id(algo_id)
440-
if algo is not None:
441-
return algo
442-
return None
439+
algo = AlgorithmRegistry.get_algorithm(algo_id)
440+
if algo is None:
441+
return None
442+
# 解包 ModelAlgorithmAdapter → 底层算法实例,以访问 build_model / get_loss_fn 等
443+
if hasattr(algo, "algo"):
444+
return algo.algo
445+
return algo
443446

444447

445448
def _default_preprocess(batch):

0 commit comments

Comments
 (0)