使用执行上下文加载神经轴管道时出错

问题描述

当我保存一个与 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 的上下文属性将被用于加载的任何上下文替换。

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

干杯

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...