Closed younesdessia closed 7 months ago
Hi, In the Workflow object, if we have export blocks, we must pass index_block to the export method
@GhislainJ
here is a simple example to reproduce this issue !
from dessia_common.core import DessiaObject
class ObjectTest(DessiaObject):
def __init__(self, name: str = "", measure: float = 1.1):
self.measure = measure
DessiaObject.__init__(self, name=name)
class InstantiateObject(DessiaObject):
def __init__(self, name: str = ""):
DessiaObject.__init__(self, name=name)
def compute(self, measure: float = 1):
return ObjectTest(measure=measure)
from dessia_common.typings import MethodType
from dessia_common.workflow.blocks import InstantiateModel, ModelMethod, Export
from dessia_common.workflow.core import Pipe, Workflow
from dessia_common.export_test import InstantiateObject
block_0 = InstantiateModel(model_class=InstantiateObject, name="InstantateObject")
block_1 = ModelMethod(method_type=MethodType(InstantiateObject, 'compute'), name="compute")
txt_method = MethodType(class_=InstantiateObject, name="save_to_stream")
export_txt = Export(method_type=txt_method, text=True, filename="export_json", extension="json", name="Export JSON")
blocks = [block_0, block_1, export_txt]
pipe_1 = Pipe(block_0.outputs[0], block_1.inputs[0])
pipe_2 = Pipe(block_0.outputs[0], export_txt.inputs[0])
workflow = Workflow(blocks, [pipe_1, pipe_2], output=block_1.outputs[0], name="test")
input_values = {
}
workflow_export_run = workflow.run(input_values)
workflow_export_run.zip_settings() # error block index when evaluate txt_method export method (block_index!)
What kind of changes does this PR introduce?
[x] Bug fix
[ ] new features
[ ] performance
[ ] docs update
Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
[ ] Yes:
[x] No
Other information: