Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

fix: draw function vs init parameters #115

Merged
merged 2 commits into from
Sep 27, 2023
Merged

fix: draw function vs init parameters #115

merged 2 commits into from
Sep 27, 2023

Conversation

ZanSara
Copy link
Contributor

@ZanSara ZanSara commented Sep 26, 2023

Why

We recently discovered that many Haystack components break the draw function due to the complexity of their init parameters.

What

  • Replaces a deepcopy step that was breaking PromptBuilder with a shallower copy (see comments)
  • Removes the drawing of optional inputs, replaced with a better representation within the component's box.
  • Remove the init parameters from the diagram
  • Renames mermaid-img to mermaid-image to be consistent with mermaid-text
  • Fixes tests

Tests

  • Local unit tests
  • Tested on Haystack RAG pipelines successfully

Results

Example RAG:

test

@@ -95,7 +95,7 @@ def _prepare_for_drawing(graph: networkx.MultiDiGraph, style_map: Dict[str, str]
graph.add_node("input")
for node, in_sockets in _find_pipeline_inputs(graph).items():
for in_socket in in_sockets:
if in_socket.sender is None:
if in_socket.sender is None and not in_socket.is_optional:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevents optional inputs from being drawn

_draw(graph=deepcopy(self.graph), path=path, engine=engine)
_draw(graph=networkx.MultiDiGraph(self.graph), path=path, engine=engine)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deepcopy replaced with the initialization of a new graph (shallow copy). Less safe in theory, however the draw functions only affect the graph edges, so no harm should be done to the components.

@ZanSara ZanSara changed the title fix: draw function fix: draw function vs init parameters Sep 26, 2023
@ZanSara ZanSara merged commit e2f5187 into main Sep 27, 2023
16 checks passed
@ZanSara ZanSara deleted the fix-draw branch September 27, 2023 07:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants