haystack icon indicating copy to clipboard operation
haystack copied to clipboard

feat: add rendering options for `Pipeline.draw()`

Open ZanSara opened this issue 1 year ago • 3 comments

Related Issues

@bilgeyucel and I agree to simplify the diagrams shown in the future tutorials https://colab.research.google.com/drive/1eMfxnsY22NC6nXhh9kBlVK1dgsUurjV6#scrollTo=Tu1bPY3_O5Me and https://colab.research.google.com/drive/1cbHRSSrkadTv-prhnFiG5d9d9RDPCIqu#scrollTo=ze6CrSJSbAl_

Proposed Changes:

Introduces a few parameters to make the pipeline diagram more readable when many components are involved:

  • show_component_names: whether the name of the component should be shown
  • show_optional_inputs: whether the optional inputs of the component should be shown
  • show_connection_types: whether the type of the connections should be shown
  • direction: whether the plot should be drawn top-down or left-right

Results:

pipe.draw("pipeline.png")

pipeline

pipe.draw("pipeline.png", show_component_names=False, show_optional_inputs=False, show_connection_types=False)

pipeline

pipe.draw("pipeline.png", show_component_names=False, show_optional_inputs=False, show_connection_types=False, direction="left-right")

pipeline

(admittedly not the best example pipeline, but you get the point :smile: )

How did you test it?

Colab notebook, local runs

Notes for the reviewer

n/a

Checklist

ZanSara avatar Feb 09 '24 16:02 ZanSara

Really cool to have these options 🚀

vblagoje avatar Feb 10 '24 09:02 vblagoje

Pull Request Test Coverage Report for Build 7930614764

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 9 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.02%) to 89.18%

Files with Coverage Reduction New Missed Lines %
core/pipeline/draw.py 4 94.44%
core/pipeline/pipeline.py 5 94.23%
<!-- Total: 9
Totals Coverage Status
Change from base Build 7930236372: -0.02%
Covered Lines: 4970
Relevant Lines: 5573

💛 - Coveralls

coveralls avatar Feb 12 '24 15:02 coveralls

I would prefer that @silvanocerza also take a look, as he has recently worked on this part and has better context than I do.

anakin87 avatar Feb 16 '24 13:02 anakin87