@@ -630,19 +630,24 @@ def output_names(self):
630630
631631 @version_requires ("3.0" )
632632 def connect_with (self , left_workflow , output_input_names = None ):
633- """Chain 2 workflows together so that they become one workflow.
633+ """Prepend a given workflow to the current workflow.
634634
635- The one workflow contains all the operators, inputs, and outputs
636- exposed in both workflows.
635+ Updates the current workflow to include all the operators of the workflow given as argument.
636+ Outputs of the given workflow are connected to inputs of the current workflow according to
637+ the map.
638+ All outputs of the given workflow become outputs of the current workflow.
637639
638640 Parameters
639641 ----------
640642 left_workflow : core.Workflow
641- Second workflow's outputs to chained with this workflow's inputs.
643+ The given workflow's outputs are chained with the current workflow's inputs.
642644 output_input_names : str tuple, str dict optional
643- Input name of the left_workflow to be cained with the output name of this workflow.
644- The default is ``None``, in which case the inputs in the left_workflow with the same
645- names as the outputs of this workflow are chained.
645+ Map used to connect the outputs of the given workflow to the inputs of the current
646+ workflow.
647+ Check the names of available inputs and outputs for each workflow using
648+ `Workflow.input_names` and `Workflow.output_names`.
649+ The default is ``None``, in which case it tries to connect each output of the
650+ left_workflow with an input of the current workflow with the same name.
646651
647652 Examples
648653 --------
@@ -663,6 +668,38 @@ def connect_with(self, left_workflow, output_input_names=None):
663668 |"mesh_scoping" -> |____| -> "output" |
664669 +-------------------------------------------------------------------------------------------------+ # noqa: E501
665670
671+ >>> import ansys.dpf.core as dpf
672+ >>> left_wf = dpf.Workflow()
673+ >>> op1 = dpf.operators.utility.forward()
674+ >>> left_wf.set_input_name("op1_input", op1.inputs.any)
675+ >>> left_wf.set_output_name("op1_output", op1.outputs.any)
676+ >>> op2 = dpf.operators.utility.forward()
677+ >>> left_wf.set_input_name("op2_input", op2.inputs.any)
678+ >>> left_wf.set_output_name("op2_output", op2.outputs.any)
679+ >>> left_wf.add_operators([op1, op2])
680+ >>> print(f"{left_wf.input_names=}")
681+ left_wf.input_names=['op1_input', 'op2_input']
682+ >>> print(f"{left_wf.output_names=}")
683+ left_wf.output_names=['op1_output', 'op2_output']
684+ >>> current_wf = dpf.Workflow()
685+ >>> op3 = dpf.operators.utility.forward()
686+ >>> current_wf.set_input_name("op3_input", op3.inputs.any)
687+ >>> current_wf.set_output_name("op3_output", op3.outputs.any)
688+ >>> op4 = dpf.operators.utility.forward()
689+ >>> current_wf.set_input_name("op4_input", op4.inputs.any)
690+ >>> current_wf.set_output_name("op4_output", op4.outputs.any)
691+ >>> current_wf.add_operators([op3, op4])
692+ >>> print(f"{current_wf.input_names=}")
693+ current_wf.input_names=['op3_input', 'op4_input']
694+ >>> print(f"{current_wf.output_names=}")
695+ current_wf.output_names=['op3_output', 'op4_output']
696+ >>> output_input_names = {"op2_output": "op3_input"}
697+ >>> current_wf.connect_with(left_wf, output_input_names)
698+ >>> print(f"New {current_wf.input_names=}")
699+ New current_wf.input_names=['op1_input', 'op2_input', 'op4_input']
700+ >>> print(f"New {current_wf.output_names=}")
701+ New current_wf.output_names=['op1_output', 'op2_output', 'op3_output', 'op4_output']
702+
666703 Notes
667704 -----
668705 Function available with server's version starting at 3.0.
0 commit comments