使用执行上下文加载 neuraxle 管道时出错

Error loading neuraxle pipeline with execution context

当我保存一个有关联的 ExecutionContext 的管道并尝试再次加载它时,我收到如下所示的错误。

from neuraxle.base import ExecutionContext, Identity
from neuraxle.pipeline import Pipeline

PIPELINE_NAME = 'saved_pipeline_name'
cache_folder = 'cache_folder'

pipeline = Pipeline([
    Identity()
]).with_context(ExecutionContext(cache_folder))

pipeline.set_name(PIPELINE_NAME).save(ExecutionContext(cache_folder), full_dump=True)
loaded_pipeline = ExecutionContext(cache_folder).load(PIPELINE_NAME)

错误信息:

Traceback (most recent call last):
  File "save_example.py", line 12, in <module>
    loaded_pipeline = ExecutionContext(cache_folder).load(PIPELINE_NAME)
  File ".env/lib/python3.7/site-packages/neuraxle/base.py", line 555, in load
    ).load(context_for_loading, True)
  File ".env/lib/python3.7/site-packages/neuraxle/base.py", line 3621, in load
    return loaded_self.load(context, full_dump)
  File ".env/lib/python3.7/site-packages/neuraxle/base.py", line 1708, in load
    return self._load_step(context, savers)
  File ".env/lib/python3.7/site-packages/neuraxle/base.py", line 1717, in _load_step
    loaded_self = saver.load_step(loaded_self, context)
  File ".env/lib/python3.7/site-packages/neuraxle/base.py", line 3644, in load_step
    step.apply('_assert_has_services', context=context)
  File ".env/lib/python3.7/site-packages/neuraxle/base.py", line 2316, in apply
    results: RecursiveDict = self._apply_childrens(results=results, method=method, ra=ra)
  File ".env/lib/python3.7/site-packages/neuraxle/base.py", line 2327, in _apply_childrens
    for children in self.get_children():
  File ".env/lib/python3.7/site-packages/neuraxle/base.py", line 2530, in get_children
    return [self.wrapped]
AttributeError: 'StepWithContext' object has no attribute 'wrapped'

没有 with_context(ExecutionContext(cache_folder)) 加载工作正常。这是预期的行为,还是错误?使用执行上下文时,保存管道的最佳做法是什么?

StepWithContext 的保护程序中的函数调用错误。大约在第二天左右,将在 Neuraxle 的主存储库上推送一个修补程序。如果您可以等到那时,您的代码应该可以毫无问题地执行。

如果没有,我建议您通过直接在 StepWithContext 的包装步骤(即您的管道实例)上调用保存来绕过 StepWithContext:

pipeline.wrapped.set_name(PIPELINE_NAME).save(ExecutionContext(cache_folder), full_dump=True)
loaded_pipeline = ExecutionContext(cache_folder).load(PIPELINE_NAME)

然后您必须使用 .with_context() 调用使用 StepWithContext 重新包装 loaded_pipeline 实例。

当修补程序可用时,请记住,ExecutionContext 实例根本不会被保存,并且在加载时,StepWithContext 的上下文属性将替换为用于加载的任何上下文。

如有任何其他问题,请随时问我!我很乐意回答他们。

干杯